Respect package.json#exports when resolving plugins#14110
Respect package.json#exports when resolving plugins#14110nicolo-ribaudo merged 2 commits intobabel:mainfrom
package.json#exports when resolving plugins#14110Conversation
| } | ||
| return res.value; | ||
| } | ||
| async function resolveStandardizedNameForImport( |
There was a problem hiding this comment.
I kept these two functions separated (rather than creating a gensync) because they are not simply a sync and an async version: the sync one is also used when Babel is called asynchronously.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50740/ |
|
The author of
I think we can first try the native |
70db994 to
0232e1f
Compare
|
|
66229ba to
ced9928
Compare
|
I can reproduce the Jest failure locally, using The failure is that it segfaluts 😢 |
|
I hate it, it's nodejs/node#35889 for the millionth time. It's the dynamic import used to get the built-in @SimenB Is there a way to detect if we are running in |
|
Currently, no. We could add something to
Definitely interested! Would you be able to open an issue over in the jest repo about it? If you meant a more private conversation that's possible as well, of course 🙂 Just DM me on twitter |
|
Maybe I can check if
Sure, I'll DM you (I might then open an issue, but it might end up being a lot of work for nothing)! |
|
We load some of our libraries inside of the sandbox, and in order to have access to the "real" globals in cases where users do |
* Use native import.meta.resolve when available
f29c2c4 to
ac045cf
Compare
I had a demo code like this:
and I noticed that it resolved to the CJS version of
babel-plugin-polyfill-corejs3, even if@babel/coreinternally usesimport()to load it.This PR fixes that, by using the correct resolution algorithm for ESM. I used
require.resolvefor CJS and https://github.com/wooorm/import-meta-resolve for ESM (which is an exact copy of the experimentalimport.meta.resolveNode.js API).Unfortunately that package is published as ESM, so we cannot directly depend on it. I added a gulp task to add it as a (
.gitignored) file in oursrcfolder, so that we can then compile it to CJS.The vendored file has this MIT license + copyright (inlined in a comment)