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

Fix loading of modules with TLA in Node.js 23 #16926

Merged
merged 6 commits into from
Oct 24, 2024

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Oct 23, 2024

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

In Node.js versions that support require(esm), require(esm-with-tla) throws ERR_REQUIRE_ASYNC_MODULE. Then our old wrong logic would see that e.code !== "ERR_REQUIRE_ESM", and thus re-throw the error rather than trying to load it with import().

This means that in Node.js 23 it's currently impossible to use plugins/presets/configs that use TLA, even when loading them with transformAsync.

When doing import() after a require() failed due to TLA Node.js currently fails an internal assertion (nodejs/node#55500), so this PR also includes a workaround for that.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Priority: High labels Oct 23, 2024
@babel-bot
Copy link
Collaborator

babel-bot commented Oct 23, 2024

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

@nicolo-ribaudo
Copy link
Member Author

The error is unrelated, probably there has been a new react-native release.

@nicolo-ribaudo nicolo-ribaudo merged commit 56658ac into babel:main Oct 24, 2024
54 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the tla-.js-ext-async-plugin branch October 24, 2024 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bug Fix 🐛 A type of pull request used for our changelog categories Priority: High
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants