Skip to content

Commit 81ef341

Browse files
NullVoxPopuliclaude
andcommitted
Don't run @ember/owner polyfill on ember-source itself
With ember-cli#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/[email protected]`'s `import { setOwner } from '@ember/owner'`, which is how min-supported started passing in ember-cli#323). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 62fbb6c commit 81ef341

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

test-app/babel.config.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,22 @@ export default {
5454
flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }],
5555
},
5656
],
57-
'babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner',
5857
]
5958
: []),
6059
],
6160

61+
overrides: isCompatBuild
62+
? [
63+
{
64+
test: (filename) =>
65+
filename !== undefined && !filename.includes('/ember-source/'),
66+
plugins: [
67+
'babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner',
68+
],
69+
},
70+
]
71+
: [],
72+
6273
generatorOpts: {
6374
compact: false,
6475
},

0 commit comments

Comments
 (0)