From 81ef341a7040dc44975a5897915ba277721c8e59 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 18 Apr 2026 23:22:18 -0400 Subject: [PATCH] Don't run @ember/owner polyfill on ember-source itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With #323 landed, `ember-lts-4.12` flips to: Uncaught ReferenceError: Cannot access 'getOwner' before initialization at app-*.js line N ember-source >= 4.12's `@ember/application/index.js` re-exports the real implementations from `@ember/owner` as aliases: import { getOwner as actualGetOwner, setOwner as actualSetOwner } from '@ember/owner'; export const getOwner = actualGetOwner; export const setOwner = actualSetOwner; `babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner` rewrote the source of that import to `@ember/application` — turning the module into a self-import that rollup then collapses into `const getOwner = getOwner` (TDZ). The plugin already tries to skip ember-source paths, but the guard only short-circuits when the file is outside `.embroider/`; in a vite compat build ember-source lives at `node_modules/.embroider/rewritten-packages/ember-source.*/` so it fell through and got rewritten. Gate the plugin through babel `overrides` with a `test` filter that excludes any path containing `/ember-source/`. The polyfill still runs where it needs to (e.g. `@glimmer/component@2.1.1`'s `import { setOwner } from '@ember/owner'`, which is how min-supported started passing in #323). Co-Authored-By: Claude Opus 4.7 (1M context) --- test-app/babel.config.mjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test-app/babel.config.mjs b/test-app/babel.config.mjs index c0f7b2a..bb0d9d0 100644 --- a/test-app/babel.config.mjs +++ b/test-app/babel.config.mjs @@ -54,11 +54,22 @@ export default { flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }], }, ], - 'babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner', ] : []), ], + overrides: isCompatBuild + ? [ + { + test: (filename) => + filename !== undefined && !filename.includes('/ember-source/'), + plugins: [ + 'babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner', + ], + }, + ] + : [], + generatorOpts: { compact: false, },