Docs and REPL support for sourceType: "commonjs"#3106
Merged
nicolo-ribaudo merged 2 commits intobabel:mainfrom Jul 2, 2025
Merged
Docs and REPL support for sourceType: "commonjs"#3106nicolo-ribaudo merged 2 commits intobabel:mainfrom
nicolo-ribaudo merged 2 commits intobabel:mainfrom
Conversation
✅ Deploy Preview for babel-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for babel ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1682b39 to
4e02926
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docs PR for babel/babel#17390
This pull request introduces support for the
"commonjs"mode in thesourceTypeconfiguration across various parts of the codebase and documentation. The"commonjs"mode is designed for parsing code intended to run in CommonJS environments, such as Node.js, and includes syntax differences from the"script"mode. The changes update documentation, types, and UI elements to incorporate this new mode.Documentation Updates:
docs/options.md: Added"commonjs"to the list of valid values forsourceType, with an explanation of its compatibility with CommonJS environments and syntax differences.docs/parser.md: Updated thesourceTypedescription to include"commonjs"and clarified its behavior, including compatibility with"script"mode and additional syntax support. Also noted the addition of"commonjs"in versionv7.28.0. [1] [2]Code Updates:
js/repl/types.ts: Extended theSourceTypetype to include"commonjs".js/repl/ReplOptions.tsx: Added"CommonJS"as an option in the REPL dropdown for selecting thesourceType.