Skip to content
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

Avoid dynamic import when it's not needed #14192

Merged
merged 1 commit into from Jan 22, 2022

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jan 21, 2022

Q                       A
Fixed Issues? Fixes #14186
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This fixes #14186. It's the annoying segfault; the one that affects Babel/Webpack/Jest but V8 doesn't fix. In #14110 I added a workaround just for Jest, but since it also affects other projects this PR replaces the Jest workaround with another one. It will still crash in some cases, but only when using the --experimental-import-meta-resolve experimental flag with Jest or Webpack (hopefully no one relies on this combination, but otherwise there is not much that we can do other than 👍 the Node.js issue and the V8 bug).

@jlowcs Could you also try replacing line 26 of https://unpkg.com/browse/@babel/core@7.16.10/lib/config/files/import-meta-resolve.js with the following code, trigger a few CI runs, and see if it still works (it's a better fix from the one I already asked you to verify, because it doesn't affect the current Babel behavior other than avoiding crashes):

const resolveP = import_ && process.execArgv.includes("--experimental-import-meta-resolve")
    ? import_("data:text/javascript,export default import.meta.resolve").then(m => m.default || _importMetaResolve.resolve, () => _importMetaResolve.resolve)
    : Promise.resolve(_importMetaResolve.resolve);

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories i: regression labels Jan 21, 2022
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50858/

@nicolo-ribaudo
Copy link
Member Author

Confirmed that this works - #14186 (comment).

Thanks everyone!

@nicolo-ribaudo nicolo-ribaudo merged commit 2ea9054 into babel:main Jan 22, 2022
@nicolo-ribaudo nicolo-ribaudo deleted the fix-14186 branch January 22, 2022 09:12
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Random segfaults when running webpack and using @babel/core 7.16.10
3 participants