Skip to content

Commit 83933fa

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 #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 babel-plugin-debug-macros processing ember-source, the init is tree-shaken while the `assert` predicate still evaluates eagerly, so `COMPUTED_GETTERS` is undefined at runtime. Alias `@glimmer/env` to a local shim that exports `DEBUG = true` so the init and the use stay consistent (ember-source >= 6 switched to `isDevelopingApp()` from `@embroider/macros`, which `buildMacros()` already handles — hence the problem is specific to the older Ember versions exercised by the compat scenarios). 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 83933fa

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

test-app/glimmer-env-shim.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Force DEBUG=true for test builds. ember-source <= 5.x uses
2+
// `import { DEBUG } from '@glimmer/env'` paired with `if (DEBUG)`-guarded
3+
// init (e.g. COMPUTED_GETTERS = new WeakSet()) alongside `assert()` calls
4+
// whose predicate reads those same variables. Without
5+
// babel-plugin-debug-macros processing these, the default export
6+
// `DEBUG = false` from @glimmer/env tree-shakes the init away while the
7+
// assert still runs, producing "Cannot read properties of undefined
8+
// (reading 'has')" at runtime.
9+
export const DEBUG = true;
10+
export const CI = false;

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
}

test-app/vite.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'vite';
22
import { extensions, ember, hbs, classicEmberSupport } from '@embroider/vite';
33
import { babel } from '@rollup/plugin-babel';
4+
import { fileURLToPath } from 'node:url';
45

56
export default defineConfig({
67
plugins: [
@@ -11,4 +12,11 @@ export default defineConfig({
1112
extensions,
1213
}),
1314
],
15+
resolve: {
16+
alias: {
17+
'@glimmer/env': fileURLToPath(
18+
new URL('./glimmer-env-shim.mjs', import.meta.url),
19+
),
20+
},
21+
},
1422
});

0 commit comments

Comments
 (0)