Making npm CommonJS based modules available in NodeJS ESM.
Use @std/esm and configure it as such:
"@std/esm": {
"cjs": true,
"esm": "js"
}
You can install it either globally or locally, and use it in latter case via npm
scripts.
npm install -g mjs-require
Require the module before launching your ESM based project.
node -r mjs-require --experimental-modules index.mjs
Right now there's no conditional, dynamic, synchronous way to require CJS modules.
So now require
is back.
Happy ESM Migration 🎉