Skip to content

Commit

Permalink
feat (new app-boot): the entry point exports the fastbootOnlyModules,…
Browse files Browse the repository at this point in the history
… which are then define in app.js, d is no longer needed in the virtual entry template
  • Loading branch information
BlueCutOfficial committed Jun 26, 2024
1 parent e49d8c2 commit 0789167
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/virtual-entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = {};
Expand All @@ -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}}
Expand Down Expand Up @@ -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 }[];
Expand Down
5 changes: 2 additions & 3 deletions tests/app-template/app/app.js
Original file line number Diff line number Diff line change
@@ -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;
});
Expand Down

0 comments on commit 0789167

Please sign in to comment.