From 0691d3fa8daa388008a65620151a83e70e1f5730 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 18 Apr 2026 22:34:55 -0400 Subject: [PATCH 1/2] Make ember-lts-4.12 compat scenario runnable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two stacked runtime issues were blocking ember-lts-4.12 once the `require` import issue from #321 cleared. Both only affect the compat path (ENABLE_COMPAT_BUILD=true, ember4 deps overrides) and are hidden for ember-source >= 6 because the upstream code was rewritten. 1. "Cannot read properties of undefined (reading 'has')" at `makeComputedDecorator` → `COMPUTED_GETTERS.has(...)`. ember-source <= 5.x's `@ember/-internals/metal` has `let COMPUTED_GETTERS; if (DEBUG) { COMPUTED_GETTERS = new WeakSet(); }` paired with `assert(..., !COMPUTED_GETTERS.has(...))`. `DEBUG` comes from `@glimmer/env`, whose published default is `DEBUG = false`. Without something resolving `DEBUG` at compile time, rollup tree-shakes the init but the `assert` predicate still runs eagerly, so `COMPUTED_GETTERS` is undefined at runtime. Conditionally add `babel-plugin-debug-macros` (only when ENABLE_COMPAT_BUILD is set) with `flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }]` so the plugin inlines `DEBUG = true` in ember-source. The init and the use stay consistent. Non-compat scenarios don't need the plugin — modern ember-source uses `isDevelopingApp()` from `@embroider/macros`, which `buildMacros()` already handles. 2. ember-qunit@8 + @ember/test-helpers@4 rely on classic-Ember globals that don't exist in a vite build: `start()` auto-calls `loadTests()` which iterates `requirejs.entries`, and `visit` reads `global.EmberENV._APPLICATION_TEMPLATE_WRAPPER`. Both were removed in ember-qunit@9 and @ember/test-helpers@5 respectively. Bump those two pins in the ember4 deps stanza so the scenario exercises the same surface modern scenarios do: ember-qunit: ^8.0.0 -> ^9.0.0 @ember/test-helpers: ^4.0.0 -> ^5.0.0 Both peer `ember-source >= 4.0.0`, so Ember 4.12 is still within the supported range. ember-qunit@9 peers `@ember/test-helpers >=3.0.3`, so the test-helpers bump stays within bounds. Co-Authored-By: Claude Opus 4.7 (1M context) --- pnpm-lock.yaml | 3 +++ test-app/.try.mjs | 4 ++-- test-app/babel.config.mjs | 12 ++++++++++++ test-app/package.json | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 97ea165..3688977 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -278,6 +278,9 @@ importers: '@rollup/plugin-babel': specifier: ^6.1.0 version: 6.1.0(@babel/core@7.29.0)(rollup@4.60.1) + babel-plugin-debug-macros: + specifier: ^0.3.4 + version: 0.3.4(@babel/core@7.29.0) babel-plugin-ember-template-compilation: specifier: ^3.1.0 version: 3.1.0 diff --git a/test-app/.try.mjs b/test-app/.try.mjs index 085d877..a04a1d9 100644 --- a/test-app/.try.mjs +++ b/test-app/.try.mjs @@ -17,10 +17,10 @@ module.exports = async function (defaults) { }; const ember4 = { - '@ember/test-helpers': '^4.0.0', + '@ember/test-helpers': '^5.0.0', '@ember/test-waiters': '^3.1.0', '@embroider/compat': '^4.0.3', - 'ember-qunit': '^8.0.0', + 'ember-qunit': '^9.0.0', 'ember-cli': '~4.12.0', }; diff --git a/test-app/babel.config.mjs b/test-app/babel.config.mjs index 441415c..7559820 100644 --- a/test-app/babel.config.mjs +++ b/test-app/babel.config.mjs @@ -4,6 +4,8 @@ import { buildMacros } from '@embroider/macros/babel'; const macros = buildMacros(); +const isCompatBuild = !!process.env.ENABLE_COMPAT_BUILD; + export default { plugins: [ [ @@ -44,6 +46,16 @@ export default { }, ], ...macros.babelMacros, + ...(isCompatBuild + ? [ + [ + 'babel-plugin-debug-macros', + { + flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }], + }, + ], + ] + : []), ], generatorOpts: { diff --git a/test-app/package.json b/test-app/package.json index aa70314..ba31398 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -35,6 +35,7 @@ "@babel/eslint-parser": "^7.23.3", "@babel/plugin-transform-runtime": "^7.29.0", "@babel/plugin-transform-typescript": "^7.28.6", + "babel-plugin-debug-macros": "^0.3.4", "@ember/string": "^4.0.1", "@ember/test-helpers": "^5.4.1", "@embroider/core": "^4.4.7", From 3d044e174cb8db9eeae1dda8d892d38a8cdaf064 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 18 Apr 2026 23:09:55 -0400 Subject: [PATCH 2/2] Polyfill @ember/owner imports for min-supported scenario `min-supported` installs `ember-source: ~4.2.0` but the test-app's default `@glimmer/component@2.1.1` has `import { setOwner } from '@ember/owner'`. `@ember/owner` didn't ship as a module path until ember-source 4.10, so rollup fails with: [vite]: Rollup failed to resolve import "@ember/owner" from ".../@glimmer/component@2.1.1/node_modules/@glimmer/component/dist/index.js" Use `babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner` to rewrite those imports back to `@ember/application` (which had `getOwner` /`setOwner` in every 4.x release). The plugin only runs when `ENABLE_COMPAT_BUILD` is set, next to babel-plugin-debug-macros. It's a no-op for scenarios that still resolve `@ember/owner` natively (ember-lts-5.12 and later) because `@ember/application` re-exports the same symbols there. Co-Authored-By: Claude Opus 4.7 (1M context) --- pnpm-lock.yaml | 12 ++++++++++++ test-app/babel.config.mjs | 1 + test-app/package.json | 1 + 3 files changed, 14 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3688977..479d31f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -281,6 +281,9 @@ importers: babel-plugin-debug-macros: specifier: ^0.3.4 version: 0.3.4(@babel/core@7.29.0) + babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner: + specifier: ^1.0.4 + version: 1.0.4(@babel/core@7.29.0) babel-plugin-ember-template-compilation: specifier: ^3.1.0 version: 3.1.0 @@ -2161,6 +2164,11 @@ packages: resolution: {integrity: sha512-pJajN/DkQUnStw0Az8c6khVcMQHgzqWr61lLNtVeu0g61LRW0k9jyK7vaedrHDWGe/Qe8sxG5wpiyW9NsMqFzA==} engines: {node: 6.* || 8.* || >= 10.*} + babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner@1.0.4: + resolution: {integrity: sha512-kZQdMKC0Ec+SsDZ/Lv/Ic1f23FJkZI5rDjRz+00l3JWbEeU9/tex0aCYs16VvuT1O1XG8c3xJNx6+ZXliBkYPQ==} + peerDependencies: + '@babel/core': ^7.0.0 + babel-plugin-ember-template-compilation@3.1.0: resolution: {integrity: sha512-kk7cGyblE9n4MB98rqw2wuUW7YLD5FM+Tr97gNSYL4e8DBMQndLuWaWNx1wfd7o00NjFhhoTR+HZs2nj23g2Lw==} engines: {node: '>= 18.*'} @@ -7746,6 +7754,10 @@ snapshots: dependencies: ember-rfc176-data: 0.3.18 + babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner@1.0.4(@babel/core@7.29.0): + dependencies: + '@babel/core': 7.29.0 + babel-plugin-ember-template-compilation@3.1.0: dependencies: '@glimmer/syntax': 0.95.0 diff --git a/test-app/babel.config.mjs b/test-app/babel.config.mjs index 7559820..c0f7b2a 100644 --- a/test-app/babel.config.mjs +++ b/test-app/babel.config.mjs @@ -54,6 +54,7 @@ export default { flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }], }, ], + 'babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner', ] : []), ], diff --git a/test-app/package.json b/test-app/package.json index ba31398..6919dee 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -36,6 +36,7 @@ "@babel/plugin-transform-runtime": "^7.29.0", "@babel/plugin-transform-typescript": "^7.28.6", "babel-plugin-debug-macros": "^0.3.4", + "babel-plugin-ember-polyfill-get-and-set-owner-from-ember-owner": "^1.0.4", "@ember/string": "^4.0.1", "@ember/test-helpers": "^5.4.1", "@embroider/core": "^4.4.7",