From 1c787efdbd2864cb0a99e9fc96026d9179db62de Mon Sep 17 00:00:00 2001 From: Marine Dunstetter Date: Wed, 26 Jun 2024 11:03:13 +0200 Subject: [PATCH] feat (new app-boot): the entry point exports the fastbootOnlyModules, which are then define in app.js, d is no longer needed in the virtual entry template --- packages/core/src/virtual-entrypoint.ts | 8 +++++--- tests/addon-template/tests/dummy/app/app.js | 5 ++--- tests/app-template/app/app.js | 5 ++--- tests/ts-app-template/app/app.ts | 5 ++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/core/src/virtual-entrypoint.ts b/packages/core/src/virtual-entrypoint.ts index 3d74dcc6e..989e06e29 100644 --- a/packages/core/src/virtual-entrypoint.ts +++ b/packages/core/src/virtual-entrypoint.ts @@ -154,7 +154,6 @@ export function renderEntrypoint( const entryTemplate = compile(` import { importSync as i, macroCondition, getGlobalConfig } from '@embroider/macros'; let w = window; -let d = w.define; import environment from './config/environment'; @@ -178,6 +177,8 @@ import environment from './config/environment'; import * as amdModule{{index}} from "{{js-string-escape amdModule.buildtime}}" {{/each}} +let exportFastbootModules = {}; + {{#if fastbootOnlyAmdModules}} if (macroCondition(getGlobalConfig().fastboot?.isRunning)) { let fastbootModules = {}; @@ -189,7 +190,7 @@ import environment from './config/environment'; const resolvedValues = await Promise.all(Object.values(fastbootModules)); Object.keys(fastbootModules).forEach((k, i) => { - d(k, function(){ return resolvedValues[i];}); + exportFasbootModules[k] = resolvedValues[i]; }) } {{/if}} @@ -223,12 +224,13 @@ w._embroiderEngineBundles_ = [ export default Object.assign( {}, + implicitModules, { {{#each amdModules as |amdModule index| ~}} "{{js-string-escape amdModule.runtime}}": amdModule{{index}}, {{/each}} }, - implicitModules + exportFastbootModules ); `) as (params: { amdModules: { runtime: string; buildtime: string }[]; diff --git a/tests/addon-template/tests/dummy/app/app.js b/tests/addon-template/tests/dummy/app/app.js index ebada6316..0856d883b 100644 --- a/tests/addon-template/tests/dummy/app/app.js +++ b/tests/addon-template/tests/dummy/app/app.js @@ -1,13 +1,12 @@ import Application from '@ember/application'; -import '@embroider/core/entrypoint'; -import coreModules from '@embroider/core/entrypoint'; +import compatModules from '@embroider/core/entrypoint'; import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'dummy/config/environment'; let d = window.define; -for (const [name, module] of Object.entries(coreModules)) { +for (const [name, module] of Object.entries(compatModules)) { d(name, function () { return module; }); diff --git a/tests/app-template/app/app.js b/tests/app-template/app/app.js index f9fb59da4..9f0c04383 100644 --- a/tests/app-template/app/app.js +++ b/tests/app-template/app/app.js @@ -1,13 +1,12 @@ import Application from '@ember/application'; -import '@embroider/core/entrypoint'; -import coreModules from '@embroider/core/entrypoint'; +import compatModules from '@embroider/core/entrypoint'; import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from './config/environment'; let d = window.define; -for (const [name, module] of Object.entries(coreModules)) { +for (const [name, module] of Object.entries(compatModules)) { d(name, function () { return module; }); diff --git a/tests/ts-app-template/app/app.ts b/tests/ts-app-template/app/app.ts index 667543e2c..df50bd33b 100644 --- a/tests/ts-app-template/app/app.ts +++ b/tests/ts-app-template/app/app.ts @@ -1,7 +1,6 @@ import Application from '@ember/application'; -import '@embroider/core/entrypoint'; // @ts-ignore -import coreModules from '@embroider/core/entrypoint'; +import compatModules from '@embroider/core/entrypoint'; import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'ts-app-template/config/environment'; @@ -9,7 +8,7 @@ import config from 'ts-app-template/config/environment'; // @ts-ignore let d = window.define; -for (const [name, module] of Object.entries(coreModules)) { +for (const [name, module] of Object.entries(compatModules)) { d(name, function () { return module; });