Support Babel 8 alongside Babel 7 - #537
Draft
wagenet wants to merge 1 commit into
Draft
Conversation
Every @babel/* package ember-cli-babel depends on now has a Babel 8 release, so supporting both majors is a matter of the options we pass. Four of them changed: - @babel/plugin-proposal-decorators removed `.legacy` and requires an explicit `version`. Babel 7 understands `version: "legacy"` too, so no branch is needed. - `moduleIds`/`getModuleId` are no longer read from the root options; the module transform reads them from its own options instead. Without this every module is emitted as an anonymous `define([...])` that the AMD loader can't resolve. Babel 7 already prefers the plugin-level values, so these move rather than fork. - @babel/plugin-transform-runtime dropped `regenerator`, `useESModules` and `helpers`. `useESModules` still matters on Babel 7, so this is the one spot that checks the installed major. - `loadPartialConfig` is callback-based in Babel 8; `loadPartialConfigSync` has existed since 7.8. Projects using `useBabelConfig: true` with a hand-configured AMD transform have to pass `moduleIds`/`getModuleId` themselves on Babel 8, since we can no longer inject them at the root. `buildEmberPlugins` handles it for everyone else. Documented in the README. CI gains a job that runs the node tests against Babel 8. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 12, 2026
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.
Towards #535.
What this does
Makes
ember-cli-babelwork on Babel 7 and Babel 8 from one codebase, and widens the@babel/*ranges to^7.x || ^8.0.0(peer@babel/coreto^7.12.0 || ^8.0.0).pnpm test:nodeis green on both: 106/106 on Babel 7, 106/106 on Babel 8.0.1.The four things Babel 8 actually broke
@babel/plugin-proposal-decoratorsrequiresversion. Babel 8 removed.legacyand errors without an explicitversion.{ legacy: true }→{ version: "legacy" }; Babel 7 accepts that spelling too, so there's no branch.moduleIds/getModuleIdare no longer root options. This is the one that would be easy to miss. Babel 8 reads them only from the module transform's own options, so with the current code every module compiles to an anonymousdefine([...])and the AMD loader can't find any of them. Babel 7'sgetModuleNamealready prefers plugin-level values over root ones, so these move into@babel/plugin-transform-modules-amdrather than forking.@babel/plugin-transform-runtimedroppedregenerator,useESModules, andhelpers. All three now throw.useESModules: truestill changes behavior on Babel 7 (without it you get CJS helpers), so this is the only place that checks the installed major. On Babel 8 it's unnecessary —@babel/runtimeresolves ESM helpers viapackage.json#exports.loadPartialConfigbecame callback-based. TheuseBabelConfig: truepath called it synchronously.loadPartialConfigSynchas existed since Babel 7.8.Behavior change worth a release note
Projects using
useBabelConfig: truethat configure the AMD transform by hand have to passmoduleIds/getModuleIdthemselves on Babel 8, because we can no longer inject them at the root:buildEmberPluginsnow does this itself, so only hand-rolled config is affected. It's documented in the README. The failure mode is silent at build time, which is why it's called out.This can't merge yet
broccoli-babel-transpiler@8.0.2declares"@babel/core": "^7.17.9"as a peer, which npm treats as a hard failure:The constraint looks stale rather than real — its whole Babel surface is
transformAsyncplus reading@babel/core/package.jsonfor a cache key, and the suite passes against Babel 8 with the peer check relaxed. It needs^7.17.9 || ^8.0.0and a release before any of this is reachable by users. There's no open Babel 8 issue or PR on that repo.Notes for reviewers
Node: Babel 8job.scripts/use-babel-8.jsrewritespackage.jsonwith pnpm overrides before install; its comments explain each one. Two are workarounds, not requirements:code-equality-assertions(a test-only assertion helper that callstransformsynchronously — it keeps its own Babel 7 copy in a normal install) and relaxing thebroccoli-babel-transpilerpeer check described above.@babel/runtimeis left pinned at7.12.18. It looked deliberately exact-pinned, and it feeds the helpers tree intreeForAddon, so I didn't touch it. Worth deciding separately whether Babel 8 apps should get@babel/runtime@8helpers.loosedeprecation warnings appear on Babel 8 for-private-methodsand-private-property-in-object, which want theprivateFieldsAsProperties/setPublicClassFieldsassumptions instead. Left alone: assumptions are global rather than per-plugin, so it's a semantic change that seemed like a maintainer decision.babel-plugin-ember-modules-api-polyfill@3.5.0uses uppercase@babel/typesbuilders, deprecated in@babel/types@8. Warning only, and only reached onember-source < 3.27.🤖 Generated with Claude Code