From 944fd43cc3e6d705c1eed8fb18356bfad5fb41d5 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 18 Apr 2026 20:15:56 -0400 Subject: [PATCH] Conditionally import legacy-inspector-support per ember-source version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- test-app/app/app.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test-app/app/app.js b/test-app/app/app.js index d084bd2..3f55325 100644 --- a/test-app/app/app.js +++ b/test-app/app/app.js @@ -1,8 +1,26 @@ import Application from 'ember-strict-application-resolver'; import { entries as serviceEntries } from 'ember-page-title/service-registry'; import { entries as templateEntries } from 'ember-page-title/template-registry'; +import { + dependencySatisfies, + importSync, + macroCondition, +} from '@embroider/macros'; -import setupInspector from "@embroider/legacy-inspector-support/ember-source-4.12"; +let setupInspector; +if (macroCondition(dependencySatisfies('ember-source', '>= 4.12.0'))) { + setupInspector = importSync( + '@embroider/legacy-inspector-support/ember-source-4.12', + ).default; +} else if (macroCondition(dependencySatisfies('ember-source', '>= 4.8.0'))) { + setupInspector = importSync( + '@embroider/legacy-inspector-support/ember-source-4.8', + ).default; +} else { + setupInspector = importSync( + '@embroider/legacy-inspector-support/ember-source-3.28', + ).default; +} export default class App extends Application { inspector = setupInspector(this);