Support Babel 8 alongside Babel 7 - #242
Open
wagenet wants to merge 1 commit into
Open
Conversation
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>
Author
Actions don't appear to be running on this repo ( https://github.com/wagenet/broccoli-babel-transpiler/actions/runs/31645509456
|
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.
Widens the
@babel/corepeer 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: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 testandnpm run test:sloware 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/coresurface here istransformAsync(lib/parallel-api.js,lib/worker.js) plusrequire('@babel/core/package.json').versionfor the worker pool cache key. Both are unchanged in Babel 8, and./package.jsonis still exported from the package.Babel 8 ships as ESM, but
require('@babel/core')still works from CJS viarequire(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,getModuleIdandmoduleRootoptions; they're read from the module transform plugin now. This plugin passes user options straight through, so anyone setting them getsUnknown option: .moduleIdand has to move them:That also takes out the
moduleId: trueshorthand inindex.js, which derives the module id from the file's relative path and then sets Babel's root-levelmoduleId. There's no root option left to set, and the plugin can't guess which entry in a user'spluginsarray is the module transform, so the shorthand is Babel 7 only. ThemoduleId === truetest 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:
readExpectation(), which preferstests/expectations/babel8/<name>when Babel 8 is installed. Three files needed a Babel 8 variant: source map key ordering plus the newignoreListfield,var foo = _exports.foo = 5instead of two statements, and the interop helper's parameter name.moduleIds/getModuleId/moduleIdon@babel/plugin-transform-modules-amdon Babel 8 and at the root on Babel 7. Plugin order is preserved either way. The parallel variant still round-trips a_parallelBabelobject, now nested inside plugin options —serialize/deserializealready handle that depth.CI
Adds a
Babel 8 - Node 22/24job.npm run use-babel-8installs Babel 8 over a normalnpm citree with--no-save --no-package-lock, sopackage.jsonand the lockfile keep pinning Babel 7 and the existing jobs are untouched.npm run test:babel-8does 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
enginesstays at16.* || >= 18. Babel 7 still works on those, and Babel 8 enforces its own floor through itsengines.🤖 Generated with Claude Code