From cabf7a5dbd9accd2c3173eea282dc44ec8740ad3 Mon Sep 17 00:00:00 2001 From: Ross Moody Date: Mon, 29 Jun 2026 12:24:15 -0700 Subject: [PATCH] Allow configuring Embroider macros via a `configure` option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ember-astro called buildMacros() with no options, so consumers couldn't supply macros config. Compiling Ember apps/libraries gated on getGlobalConfig() then failed — e.g. importing a library that depends on WarpDrive/ember-data, whose published code runs macroCondition(getGlobalConfig().WarpDriveMirror.env.PRODUCTION), throws 'Cannot read properties of undefined (reading env)'. Forward a `configure` callback to buildMacros({ configure }) (a documented buildMacros option). Backward compatible: omitting it behaves exactly as before. Co-Authored-By: Claude Opus 4.8 --- src/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 367d31d..e8f1e31 100644 --- a/src/index.js +++ b/src/index.js @@ -2,8 +2,6 @@ import { ember as emberVite, extensions } from "@embroider/vite"; import { babel } from "@rollup/plugin-babel"; import { buildMacros } from "@embroider/macros/babel"; -const macros = buildMacros(); - function getRenderer() { return { name: "ember-astro", @@ -19,7 +17,14 @@ export function getContainerRenderer() { }; } -function emberIntegration(/* options */) { +function emberIntegration(options = {}) { + // Forward a `configure` callback to buildMacros so consumers can register + // Embroider macros global config (e.g. WarpDrive/ember-data via `setConfig`). + // Needed when compiling apps/libs gated on `getGlobalConfig()..env` — + // without it the build throws on that value being undefined. Omitting + // `configure` is identical to the previous `buildMacros()` call. + const macros = buildMacros({ configure: options.configure }); + return { name: "ember-astro", hooks: {