WinterCG: Web-Interoperable Runtimes Community Group
wintercg.org
wintercg.org
But its way harder than it should be. Wasm-pack has a different target for nodejs and the browser for ridiculous reasons - like 'crypto' and 'WebSocket' being globally available objects in the browser but not in nodejs. And es modules working slightly differently in each environment. Npm is designed assuming packages will be isomorphic. I've ended up with separate -node and -web packages - which makes my code feel non-native.
You shouldn't need to care that a JS package uses wasm internally. But these little points of incompatibility really hurt wasm as a target for libraries to use.
CJS was node's solution to "modules" prior to ES modules, which was not interoperable with requirejs / AMD, the front end solution that came out of Dojo. UMD offered a way to have both, but was far too much boilerplate to support by hand, so it was mostly only adopted by libraries.
CJS won out for a very short time, right up until import / export became available via webpack. This short window is pretty much the only time that "isomorphic" really applied to NPM; by the time import / export had gained enough steam (thanks largely to both webpack and typescript for jump starting adoptation), there were enough browser modules that trying to write truly isomorphic code was limited to certain subsets of your application.
I imagine running isomorphic code under deno to be quite a bit less painful, as it was built from the ground up to mirror browser environments as closely as possible, but that's not much consolation if you still want to target node.
Huh? Most npm modules still work fine in both browser and native contexts. Bundlers generally support CJS modules, and modern npm modules can use esm just fine too if you set the "type": "module" field in package.json.
Even heavily browser based libraries like react usually work fine from nodejs too, to make server side rendering easier.
Isomorphic npm modules should still be the default.
I'll have to give deno a try. Node has increasingly diverged from the browser, and it causes real headaches.
The problem is that if you're using some node package in the browser that wouldn't typically be there, it'll need to be bundled for inclusion in the browser.
Nothing about npm's design implies or particularly facilitates that packages will be isomorphic.
See the 27:01 mark, https://syntax.fm/show/496/supper-club-headless-ecommerce-wi....