0.1.0 • Published 4 years ago

dualmodule v0.1.0

Weekly downloads
3
License
ISC
Repository
-
Last release
4 years ago

Node.js Dual Modules

The minimal amount of effort needed to publish modules, for both ESM and CJS, without ever needing to write an .mjs, or .cjs file.

Test It !

You need node 13.10 or higher, and a test folder, such as ~/test/node-modules to perform this test:

mkdir -p ~/test/node-modules
cd ~/test/node-modules
npm i dualmodule
# test CommonJS
node -e 'console.log(require("dualmodule"))'; # read "CJS"
# test ESM
node --input-type=module -e 'import $ from "dualmodule"; console.log($)';

If you are in node < 13.10 you'll see an ExperimentalWarning, but the output is ESM.

If you are in node >= 13.10 you won't see the warning, just the ESM output.

If you'd like to test through any file.js in that folder, and you want to test the ESM version of the module:

echo '{"type":"module"}' > ~/test/node-modules/package.json
echo 'import $ from "dualmodule"; console.log($)' > test.js
node test.js # read "ESM"

And you are good to go 🎉

0.1.0

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago