-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Don't load plugins synchronously in tests #14679
Don't load plugins synchronously in tests #14679
Conversation
b5eaeec
to
e76e707
Compare
e76e707
to
6833e13
Compare
d67eda0
to
0adbb6a
Compare
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52311/ |
var innerScope = true; | ||
var res = transform(code, { | ||
return transformAsync(code, { |
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.
Q: why do we need returning the promise?
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.
Otherwise the test runner cannot know if it was resolved successfully or rejected.
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.
Can we move the runCodeInThisContext
wrapper
const src = `(function(exports, require, module, __filename, __dirname, opts) {\n${code}\n});`; |
before the Babel transform?
babel.transformAsync(execCode, execOpts), |
So that we don't have to change test options and return
in exec.js
is automatically valid.
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.
That's a good idea, but there are manylre tests that return a promise and thus I'd prefer to do it as a separate PR.
Ref #13414. When migrating to ESM, plugins must either be pre-loaded before calling
transformSync
or you must usetransformAsync
so that Babel can internally use dynamic import.In most cases this is fine because Babel already runs asynchronously, but there were a few places in our tests that needed to be updated. Note that this is the biggest breaking change of the ESM migration, but:
@babel/core
rfcs#10, we could mitigate this change by making sure that at least@babel/preset-env
can be used synchronously if necessary