Skip to content

Commit 944fd43

Browse files
NullVoxPopuliclaude
andcommitted
Conditionally import legacy-inspector-support per ember-source version
The min-supported try-scenario was failing with: [vite]: Rollup failed to resolve import "@ember/enumerable/mutable" from ".../@embroider/legacy-inspector-support/src/modules-4-12.js" `@embroider/legacy-inspector-support` ships three entry points sharded by ember-source range: - ember-source-3.28 → Ember < 4.8 (uses legacy mutable-enumerable path) - ember-source-4.8 → Ember 4.8–4.11 (adds @ember/enumerable/mutable) - ember-source-4.12 → Ember >= 4.12 (also adds @ember/owner) test-app/app/app.js was hard-coded to the 4.12 entry, so the min-supported scenario (ember-source ~4.2.0) pulled in modules-4-12.js, which imports `@ember/enumerable/mutable` — a module that doesn't exist in Ember 4.2. Use macroCondition + dependencySatisfies + importSync from @embroider/macros to pick the right entry at build time based on the installed ember-source. The macros compile the untaken branches away, so each try scenario only pulls in the import graph it can actually resolve. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 1512bf9 commit 944fd43

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

test-app/app/app.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
import Application from 'ember-strict-application-resolver';
22
import { entries as serviceEntries } from 'ember-page-title/service-registry';
33
import { entries as templateEntries } from 'ember-page-title/template-registry';
4+
import {
5+
dependencySatisfies,
6+
importSync,
7+
macroCondition,
8+
} from '@embroider/macros';
49

5-
import setupInspector from "@embroider/legacy-inspector-support/ember-source-4.12";
10+
let setupInspector;
11+
if (macroCondition(dependencySatisfies('ember-source', '>= 4.12.0'))) {
12+
setupInspector = importSync(
13+
'@embroider/legacy-inspector-support/ember-source-4.12',
14+
).default;
15+
} else if (macroCondition(dependencySatisfies('ember-source', '>= 4.8.0'))) {
16+
setupInspector = importSync(
17+
'@embroider/legacy-inspector-support/ember-source-4.8',
18+
).default;
19+
} else {
20+
setupInspector = importSync(
21+
'@embroider/legacy-inspector-support/ember-source-3.28',
22+
).default;
23+
}
624

725
export default class App extends Application {
826
inspector = setupInspector(this);

0 commit comments

Comments
 (0)