Build: Add type module commonjs to the corresponding packages#15841
Build: Add type module commonjs to the corresponding packages#15841
Conversation
| * @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.
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
commonjssyntax 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
srcsubfolder in packages which don't need to transpiled.How has this been tested?
npm run devnpm run buildFuture 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.