-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build: Add type module commonjs to the corresponding packages #15841
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gziolo for keeping this updated. I have no objection here.
* @return {boolean} Whether file is a directory. | ||
*/ | ||
function isModuleType( file ) { | ||
const { type = 'module' } = require( path.resolve( PACKAGES_DIR, file, 'package.json' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should confirm that 'module'
is the default here. I don't think it is.
This PR was discussed during Core JS chat yesterday (link requires registration on WordPress Slack): https://wordpress.slack.com/archives/C5UNMSU4R/p1559053012050000 There is also a related question from @aduth in #15841 (comment). I did some further research to clarify how this new feature is supposed to work. From https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff:
Also in nodejs/node#26745:
All our I can confirm based on http://2ality.com/2019/04/nodejs-esm-impl.html#filename-extensions that |
Opened #15879 as an alternative. |
Description
There was announced a new --experimental-modules support for Node. It contains also
package.json
“type” field:This PR marks all packages which contain
commonjs
syntax with its corresponding type.This allows us to use a more predictable way to filter out packages which don't need to be processed with Babel. It will also make it possible to use
src
subfolder in packages which don't need to transpiled.How has this been tested?
npm run dev
npm run build
Future considerations
This probably will have to be revisited once Node enables full support for modules. However, I don't think it's going to happen any time soon.