Skip to content

Commit

Permalink
Import ember-testing first thing in virtual content
Browse files Browse the repository at this point in the history
  • Loading branch information
lolmaus committed Jan 15, 2024
1 parent 2a6a486 commit c1451c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,6 @@ export class CompatAppBuilder {
// packagers to understand. It's better to express it here as a direct
// module dependency.
let eagerModules: string[] = [
'ember-testing',
explicitRelative(dirname(myName), this.topAppJSAsset(appFiles, prepared).relativePath),
];

Expand Down Expand Up @@ -1437,10 +1436,11 @@ let d = w.define;
{{#each eagerModules as |eagerModule| ~}}
i("{{js-string-escape eagerModule}}");
import("{{js-string-escape eagerModule}}");
{{/each}}
{{#if lazyRoutes}}
w._embroiderRouteBundles_ = [
{{#each lazyRoutes as |route|}}
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/virtual-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function renderAmdModules(
return amdModulesTemplate({
amdModules,
fastbootOnlyAmdModules: resolver.options.fastbootOnlyAmdModules,
isTest: type === 'amd-test-modules',
});
}

Expand Down Expand Up @@ -338,6 +339,10 @@ export default Object.assign(
`) as (params: { dependencyModules: string[]; ownModules: { runtime: string; buildtime: string }[] }) => string;

const amdModulesTemplate = compile(`
{{#if isTest}}
import 'ember-testing';
{{/if}}
import { getGlobalConfig, macroCondition } from '@embroider/macros';
{{#each amdModules as |amdModule index|~}}
Expand Down Expand Up @@ -365,7 +370,7 @@ const modules = {
{{~/if}}
export default modules;
`) as (params: { amdModules: AmdModule[]; fastbootOnlyAmdModules: AmdModule[] }) => string;
`) as (params: { amdModules: AmdModule[]; fastbootOnlyAmdModules: AmdModule[]; isTest: boolean }) => string;

// meta['renamed-modules'] has mapping from classic filename to real filename.
// This takes that and converts it to the inverst mapping from real import path
Expand Down

0 comments on commit c1451c2

Please sign in to comment.