Skip to content

feat: add bytes-modules and text-modules to standalone - #18643

Open
JLHwung wants to merge 3 commits into
mainfrom
jlhwung/standalone-add-bytes-text-modules
Open

JLHwung wants to merge 3 commits into
mainfrom
jlhwung/standalone-add-bytes-text-modules

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 17, 2026

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? No
License MIT

In this PR we add the bytes-modules and text-modules to babel-standalone, such that it can work on Babel REPL. We should have added in 8.1 but somehow we missed that.

@JLHwung JLHwung added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Nov 17, 2026
@babel-bot

babel-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

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

babelPlugins.proposalFunctionSent,
babelPlugins.proposalThrowExpressions,
babelPlugins.syntaxModuleBlocks,
babelPlugins.proposalBytesModules,

@JLHwung JLHwung Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not quite willing to create a preset-stage-2.7.ts so this is what we got. 🤷🏻

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

commit: 043b9c7

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The added stage-2 and stage-3 plugins break AMD/SystemJS transforms even for ordinary modules without text or bytes imports because the shared visitor resolves its helper prematurely.

1 open issue
What changed in this PR

Adds bytes-module and text-module support to Babel Standalone so these proposals can be used in the Babel REPL.

Changes:

  • Registers both proposal plugins and adds their workspace dependencies.
  • Includes text modules in stage-3 and bytes modules in stage-2.
  • Adds tests for transforming text and bytes imports through those presets.
File Description
yarn.lock Records the new standalone workspace dependencies.
packages/​babel-standalone/​tsconfig.json Adds project references for both plugins.
packages/​babel-standalone/​test/​preset-stage-1.test.js Tests text and bytes imports through stage presets.
packages/​babel-standalone/​src/​preset-stage-3.ts Enables text modules in stage-3.
packages/​babel-standalone/​src/​preset-stage-2.ts Enables bytes modules in stage-2.
packages/​babel-standalone/​src/​generated/​plugins.ts Imports, exports, and registers both plugins.
packages/​babel-standalone/​scripts/​pluginConfig.json Includes both plugins in registry generation.
packages/​babel-standalone/​package.json Declares both plugin dependencies.

Review effort: Balanced

`@babel/plugin-proposal-bytes-modules` and
`@babel/plugin-proposal-text-modules` were not included in standalone,
so the REPL had to fetch them from an external bundler and failed with
"Plugin ... could not be loaded".

Assisted-by: Claude Opus 5.5
Add `proposal-bytes-modules` to `stage-2` and `proposal-text-modules`
to `stage-3`.

Assisted-by: Claude Opus 5.5
`createImportTypeAsDefaultPlugin` resolved its helper, which throws for
AMD/SystemJS output, before looking for imports with a matching `type`.
Every module compiled to AMD or SystemJS therefore failed with the JSON,
text or bytes modules plugin enabled, which also broke the standalone
`stage-2` and `stage-3` presets now that they include these plugins.

Assisted-by: Claude Opus 5.5
@JLHwung
JLHwung force-pushed the jlhwung/standalone-add-bytes-text-modules branch from 00c5254 to 043b9c7 Compare November 20, 2026 18:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: New Feature 🚀 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants