Skip to content

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Apr 25, 2025

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#3081
Any Dependency Changes?
License MIT

People can just require(esm) it :)

@nicolo-ribaudo nicolo-ribaudo added the PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release label Apr 25, 2025
@babel-bot
Copy link
Collaborator

babel-bot commented Apr 25, 2025

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

@JLHwung
Copy link
Contributor

JLHwung commented Apr 25, 2025

Q: Do we need extra node flags if people are requiring @babel/parser in a Jest vm?

@nicolo-ribaudo
Copy link
Member Author

I guess people will need to use --experimental-vm-modules to enable ESM support in Jest, but that's already the case with all the other packages we'll publish.

@nicolo-ribaudo
Copy link
Member Author

Actually, looking at jestjs/jest#15275, the answer is: Jest doesn't support require(esm) at all. People require()ing Babel packages inside Jest will either have to use import(), or use jest-light-runner.

@JLHwung
Copy link
Contributor

JLHwung commented Apr 25, 2025

I wish require(esm) can support TLA, that's the last block that prevents us from removing the worker implementation of eslint-parser/register.

Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that Jest doesn't support require(esm).

@nicolo-ribaudo
Copy link
Member Author

nicolo-ribaudo commented Apr 25, 2025

I wish require(esm) can support TLA, that's the last block that prevents us from removing the worker implementation of eslint-parser/register.

Is it? Since now .parseSync also works with ESM plugins (thanks to require(esm)), it is probably good enough. It will not work with custom plugins that use TLA, but the solution in that case is to pre-load them and pass them in the ESLint config.

@nicolo-ribaudo nicolo-ribaudo merged commit 7f152ac into babel:main Apr 25, 2025
57 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the parser-drop-cjs branch April 25, 2025 17:27
JLHwung added a commit to babel/website that referenced this pull request Apr 25, 2025
@JLHwung
Copy link
Contributor

JLHwung commented Apr 25, 2025

I wish require(esm) can support TLA, that's the last block that prevents us from removing the worker implementation of eslint-parser/register.

Is it? Since now .parseSync also works with ESM plugins (thanks to require(esm)), it is probably good enough. It will not work with custom plugins that use TLA, but the solution in that case is to pre-load them and pass them in the ESLint config.

Yes. If a Babel config used import() to load a plugin, then require(@babel/core) will throw top level await is not supported, even if we removed the cjs proxy.

@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 Jul 26, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 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: Breaking Change 💥 A type of pull request used for our changelog categories for next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants