Support .mjs plugins/presets and async factories#12266
Conversation
af39433 to
c49a7a2
Compare
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/32270/ |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 52e0f20:
|
444b0c9 to
885e08d
Compare
packages/babel-core/test/async.js
Outdated
| // please publish Babel on a modernized node :) | ||
| const { stdout, stderr } = await util.promisify(cp.execFile)( | ||
| require.resolve(`./fixtures/babel-compile-${async ? "async" : "sync"}.mjs`), | ||
| { env: process.env }, |
There was a problem hiding this comment.
nit: By default env is passed with process.env. https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback
There was a problem hiding this comment.
Actually, I need someone with macOS to check if I need to do https://github.com/babel/babel/blame/31396b286daadee3c25c4891c8dd31a92d7f0604/packages/babel-core/test/config-chain.js#L63 for this test.
There was a problem hiding this comment.
make prepublish is passing as of dfa75fa on macOS.
6b433c0 to
52e0f20
Compare
|
I'm merging this PR to the |
This is the first step needed to migrate to native ECMAScript modules: we must support loading
.mjsplugins and presets 😛require()inside the preset factory, and this makes it possible to useawait import()instead..mjsplugins/presets. It's mostly functions being converted to generators to work withgensync.While preparing this PR, I noticed that we currently support this kind of presets:
which is the result of transpiling
However, we throw an error for
because presets must export a function, and not a plain object:
Since presets must export a function (so that they can properly configure caching), I didn't implement support for the named exports in
.mjsfiles.