Skip to content

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

Merged
nicolo-ribaudo merged 6 commits into
babel:mainfrom
nicolo-ribaudo:tla-.js-ext-async-plugin
Oct 24, 2024
Merged

nicolo-ribaudo merged 6 commits into
babel:mainfrom
nicolo-ribaudo:tla-.js-ext-async-plugin

Conversation

@nicolo-ribaudo

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

Copy link
Copy Markdown
Member
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

babel-bot commented Oct 23, 2024 •

Copy link
Copy Markdown
Collaborator

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

@nicolo-ribaudo

Copy link
Copy Markdown
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
@nicolo-ribaudo
nicolo-ribaudo deleted the tla-.js-ext-async-plugin branch October 24, 2024 09:16
@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 Jan 24, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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 Priority: High

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants