Skip to content

Support Babel 8 alongside Babel 7 - #242

Open
wagenet wants to merge 1 commit into
ember-cli:masterfrom
wagenet:wagenet/babel-8-peer-support
Open

Support Babel 8 alongside Babel 7#242
wagenet wants to merge 1 commit into
ember-cli:masterfrom
wagenet:wagenet/babel-8-peer-support

Conversation

@wagenet

@wagenet wagenet commented Aug 12, 2026

Copy link
Copy Markdown

Note: This PR was written by an AI agent (Claude, via Claude Code), run by @wagenet. The code and this description are the agent's work, not his.

Widens the @babel/core peer range to ^7.17.9 || ^8.0.0.

Right now "@babel/core": "^7.17.9" is a hard install failure for anyone on Babel 8, not a warning:

npm error code ERESOLVE
npm error peer @babel/core@"^7.17.9" from broccoli-babel-transpiler@8.0.2

That makes this package the blocker for Babel 8 across the Ember toolchain — emberjs/ember-cli-babel#537 is already Babel 7/8 compatible but can't be installed until this moves.

npm test and npm run test:slow are green on both: 102/102 on @babel/core@7.17.9, 102/102 on @babel/core@8.0.1 (checked on Node 22 and 24).

Why the constraint was safe to widen

The whole @babel/core surface here is transformAsync (lib/parallel-api.js, lib/worker.js) plus require('@babel/core/package.json').version for the worker pool cache key. Both are unchanged in Babel 8, and ./package.json is still exported from the package.

Babel 8 ships as ESM, but require('@babel/core') still works from CJS via require(esm) — it's available on every Node version Babel 8 itself supports (^22.18.0 || >=24.11.0).

The options this plugin injects on its own (filename, sourceFileName) are still valid root options in Babel 8. Nothing else it adds goes to Babel.

The one behavior change

Babel 8 removed the root-level moduleId, moduleIds, getModuleId and moduleRoot options; they're read from the module transform plugin now. This plugin passes user options straight through, so anyone setting them gets Unknown option: .moduleId and has to move them:

// Babel 8
esTranspiler(inputTree, {
  babel: {
    plugins: [
      ['@babel/plugin-transform-modules-amd', { moduleIds: true, getModuleId }]
    ]
  }
});

That also takes out the moduleId: true shorthand in index.js, which derives the module id from the file's relative path and then sets Babel's root-level moduleId. There's no root option left to set, and the plugin can't guess which entry in a user's plugins array is the module transform, so the shorthand is Babel 7 only. The moduleId === true test asserts that behavior on Babel 8 rather than skipping, so the limitation stays pinned. Both are documented in the README.

If you'd rather this fail early with a broccoli-level error naming the fix instead of letting Babel's message through, say so and I'll add it.

Test changes

Two mechanical things, no behavior changes to the plugin:

  • Expectations are read through readExpectation(), which prefers tests/expectations/babel8/<name> when Babel 8 is installed. Three files needed a Babel 8 variant: source map key ordering plus the new ignoreList field, var foo = _exports.foo = 5 instead of two statements, and the interop helper's parameter name.
  • The module ID tests put moduleIds/getModuleId/moduleId on @babel/plugin-transform-modules-amd on Babel 8 and at the root on Babel 7. Plugin order is preserved either way. The parallel variant still round-trips a _parallelBabel object, now nested inside plugin options — serialize/deserialize already handle that depth.

CI

Adds a Babel 8 - Node 22/24 job. npm run use-babel-8 installs Babel 8 over a normal npm ci tree with --no-save --no-package-lock, so package.json and the lockfile keep pinning Babel 7 and the existing jobs are untouched. npm run test:babel-8 does the same thing locally.

The main matrix stays on Node 16/18 — Babel 8 needs Node 22+, so it can't run there.

Not changed

engines stays at 16.* || >= 18. Babel 7 still works on those, and Babel 8 enforces its own floor through its engines.

🤖 Generated with Claude Code

Widen the @babel/core peer range to ^7.17.9 || ^8.0.0. The only Babel APIs
this plugin uses are transformAsync and @babel/core/package.json for the
cache key, both unchanged in Babel 8.

Test expectations that differ on Babel 8 (source map key order, export
assignment, interop helper naming) live in tests/expectations/babel8/. The
module ID tests pass moduleIds/getModuleId/moduleId to the module transform
plugin on Babel 8, which removed them as root-level options.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@wagenet

wagenet commented Aug 12, 2026

Copy link
Copy Markdown
Author

Comment written by an AI agent (Claude, via Claude Code), run by @wagenet.

Actions don't appear to be running on this repo (/actions/runs reports 0 total), so nothing will report on this PR. I ran the workflow on the fork instead to check the CI changes actually work — all 9 jobs green, including the two new Babel 8 ones:

https://github.com/wagenet/broccoli-babel-transpiler/actions/runs/31645509456

Job Result
Node 16 / 18 × ubuntu, windows, macOS ✅ (6 jobs, unchanged)
Floating dependencies
Babel 8 - Node 22
Babel 8 - Node 24

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant