autoesm

Import esm in node@13+ based on source, not package.json

MIT License

Downloads
16
Stars
22
Committers
1

autoesm

Node@13+ supports ES modules natively, but doesn't let importing arbitrary modules − it requires either "type": "module" in package.json or .mjs file extension to indicate that the file is ESM.

autoesm resolves that by detecting ESM based on source, (not extension), allowing to import any ESM files (like existing ESM ecosystem with "module" field in package.json for unpkg/pikacdn).

Slow? Maybe. Runtime flag is a bummer too. In long term all ESM packages will get "type": "module" flag, but for now it saves nerves and time for running tests.

Also - the esm is broken for node@13+, so this is the replacement.

Usage

Providing node@13+ is used:

node --experimental-loader autoesm ./test.js