https://codeburst.io/the-javascript-modules-limbo-585eedbb182e
A possible pattern to move forward
Forget about
.mjs
, keep.js
and code happily ever after via@std/esm
configuring it viapackage.json
as such:
"@std/esm": {"esm": "js"}
or simply
"@std/esm": "js"
Once you鈥檝e done that, everything problematic mentioned in this post will disappear. You now rename both index.mjs and module.mjs files into index.js and module.js and launch your program like this:
node -r @std/esm index.js
At this point you have .js extensions that will work with every one-off server side spinner you have, you can finally import test from "./module.js"; specifying the entire file name and that will work out of the box in browsers, JSC, SpiderMonkey, and whatever other environment you want.
I wonder if the Node-compatible parts of CKEditor 5 (e.g. the engine's model or utils) can be loaded in Node.js without any transpilation.
cc @czerwonkabartosz, did you try this?
Ooo I'll try this!
It looks like it works - https://github.com/czerwonkabartosz/std-esm-test/blob/master/index.js
So cool!
Most helpful comment
It looks like it works - https://github.com/czerwonkabartosz/std-esm-test/blob/master/index.js