https://github.com/dy/autoesm
Import esm in node@13+ based on source, not package.json
https://github.com/dy/autoesm
Last synced: 11 months ago
JSON representation
Import esm in node@13+ based on source, not package.json
- Host: GitHub
- URL: https://github.com/dy/autoesm
- Owner: dy
- License: mit
- Created: 2020-04-30T00:13:04.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-21T02:19:33.000Z (about 6 years ago)
- Last Synced: 2025-07-17T12:21:39.366Z (11 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 23
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://ghub.io/esm) is broken for node@13+, so this is the replacement.
## Usage
[](https://npmjs.org/package/autoesm/)
Providing node@13+ is used:
```sh
node --experimental-loader autoesm ./test.js
```
ॐ