-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Feature request:
Recommendation from Node core is to output mjs alongside js files so that the package.json main field can be ambiguous. Since babel only outputs .js files when used with the -d directory flag, it becomes complicated to make this work. I'd like to see an option available to specify the extension the same as with parsing/consuming mjs.
Current Behavior
This is the most elegant solution I've found so far, which involves building all files into a temporary directory, renaming all the files to mjs, copying them into the dist/node destination, and then removing the temp directory.
"build-node-esm": "babel lib -d dist/node-es && rename -v .js .mjs dist/node-es/*.js && rename -v .js .mjs dist/node-es/**/*.js && cp -R dist/node-es/* dist/node && rm -rf dist/node-es",Possible Solution
My suggestion would be to add a new CLI flag option to specify the output extension. This will allow developers to easily support both Node-based ESM/CJS.
babel lib -d dist/node --ext ".mjs"Context
I'm trying to figure out how to build a library that will be ready to take advantage of the new Node ESM semantics.
Your Environment
| software | version(s) |
|---|---|
| node | v9.0.0-pre |