Skip to content

Commit

Permalink
use await import() for fastbootModules
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Dec 5, 2023
1 parent b6040d7 commit 4edab14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,17 @@ let d = w.define;
{{#if fastbootOnlyAmdModules}}
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
let fastbootModules = {};
{{#each fastbootOnlyAmdModules as |amdModule| ~}}
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
{{/each}}
const resolvedValues = await Promise.all(Object.values(fastbootModules));
Object.keys(fastbootModules).forEach((k, i) => {
d(k, function(){ return resolvedValues[i];});
})
}
{{/if}}
Expand Down
4 changes: 4 additions & 0 deletions packages/webpack/src/ember-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ const Webpack: PackagerConstructor<Options> = class Webpack implements Packager
'style-loader': require.resolve('style-loader'),
},
},
experiments: {
// this is needed because fasboot-only modules need to use await import()
topLevelAwait: true,
},
};
}

Expand Down

0 comments on commit 4edab14

Please sign in to comment.