Skip to content

Commit b60d722

Browse files
NullVoxPopuliclaude
andcommitted
Make ember-lts-4.12 compat scenario runnable
Three stacked runtime issues were blocking ember-lts-4.12 once the `require` import issue from ember-cli#321 cleared. All three 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 — so gating on ENABLE_COMPAT_BUILD keeps the default build untouched. 2. "ReferenceError: requirejs is not defined" from ember-qunit's auto-loadTests. ember-qunit@8's `start()` calls `loadTests()` which uses `requirejs.entries` — there's no loader.js in a vite build. ember-qunit@9 dropped that call entirely. Pass `{ loadTests: false }` so `start()` skips the requirejs-based loader; tests/index.html already uses `import.meta.glob` to discover them. The option is safely ignored by ember-qunit 9. 3. "Cannot read properties of undefined (reading '_APPLICATION_TEMPLATE_WRAPPER')" from `@ember/test-helpers`'s `visit` and `setup-rendering-context`. test-helpers 4.x reads `global.EmberENV._APPLICATION_TEMPLATE_WRAPPER` to decide whether to look inside the `.ember-view` wrapper. In classic ember-cli apps the global is populated from index.html; here we need to set it ourselves from config. Assign `globalThis.EmberENV` in `test-helper.js`. test-helpers 5.x no longer reads this at all, so the assignment is harmless for non-compat scenarios. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent e965739 commit b60d722

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-app/babel.config.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { buildMacros } from '@embroider/macros/babel';
44

55
const macros = buildMacros();
66

7+
const isCompatBuild = !!process.env.ENABLE_COMPAT_BUILD;
8+
79
export default {
810
plugins: [
911
[
@@ -44,6 +46,16 @@ export default {
4446
},
4547
],
4648
...macros.babelMacros,
49+
...(isCompatBuild
50+
? [
51+
[
52+
'babel-plugin-debug-macros',
53+
{
54+
flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }],
55+
},
56+
],
57+
]
58+
: []),
4759
],
4860

4961
generatorOpts: {

test-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@babel/eslint-parser": "^7.23.3",
3636
"@babel/plugin-transform-runtime": "^7.29.0",
3737
"@babel/plugin-transform-typescript": "^7.28.6",
38+
"babel-plugin-debug-macros": "^0.3.4",
3839
"@ember/string": "^4.0.1",
3940
"@ember/test-helpers": "^5.4.1",
4041
"@embroider/core": "^4.4.7",

test-app/tests/test-helper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import config, { enterTestMode } from 'test-app/config/environment';
33
import { setApplication } from '@ember/test-helpers';
44
import { start as qunitStart, setupEmberOnerrorValidation } from 'ember-qunit';
55

6+
globalThis.EmberENV = config.EmberENV;
7+
68
export function start() {
79
enterTestMode();
810
setApplication(Application.create(config.APP));
911

1012
setupEmberOnerrorValidation();
1113

12-
qunitStart();
14+
qunitStart({ loadTests: false });
1315
}

0 commit comments

Comments
 (0)