Docs and REPL support for sourceType: "commonjs" #3106
Merged
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.