diff --git a/packages/compat/src/compat-app-builder.ts b/packages/compat/src/compat-app-builder.ts
index d5b3051c4..fa101ade7 100644
--- a/packages/compat/src/compat-app-builder.ts
+++ b/packages/compat/src/compat-app-builder.ts
@@ -292,6 +292,7 @@ export class CompatAppBuilder {
// that the last one wins. Our resolver's order is the order to
// search, so first one wins.
.reverse(),
+ isLazy: appFiles.engine.package.isLazyEngine(),
})),
amdCompatibility: this.options.amdCompatibility,
@@ -526,7 +527,7 @@ export class CompatAppBuilder {
html.insertStyleLink(html.styles, `assets/${this.origAppPackage.name}.css`);
- const parentEngine = appFiles.find(e => !e.engine.parent)!;
+ const parentEngine = appFiles.find(e => e.engine.isApp)!;
let vendorJS = this.implicitScriptsAsset(prepared, parentEngine, emberENV);
if (vendorJS) {
html.insertScriptTag(html.implicitScripts, vendorJS.relativePath);
@@ -659,13 +660,12 @@ export class CompatAppBuilder {
}
}
- private partitionEngines(appJSPath: string): Engine[] {
+ private partitionEngines(): Engine[] {
let queue: Engine[] = [
{
package: this.appPackageWithMovedDeps,
addons: new Map(),
- parent: undefined,
- sourcePath: appJSPath,
+ isApp: true,
modulePrefix: this.modulePrefix(),
appRelativePath: '.',
},
@@ -684,8 +684,7 @@ export class CompatAppBuilder {
queue.push({
package: addon,
addons: new Map(),
- parent: current,
- sourcePath: addon.root,
+ isApp: !current,
modulePrefix: addon.name,
appRelativePath: explicitRelative(this.root, addon.root),
});
@@ -719,8 +718,8 @@ export class CompatAppBuilder {
private updateAppJS(appJSPath: string): AppFiles[] {
if (!this.engines) {
- this.engines = this.partitionEngines(appJSPath).map(engine => {
- if (engine.sourcePath === appJSPath) {
+ this.engines = this.partitionEngines().map(engine => {
+ if (engine.isApp) {
// this is the app. We have more to do for the app than for other
// engines.
let fastbootSync: SyncDir | undefined;
@@ -741,7 +740,7 @@ export class CompatAppBuilder {
// their files, not doing any actual copying or building.
return {
engine,
- appSync: new SyncDir(engine.sourcePath, undefined),
+ appSync: new SyncDir(engine.package.root, undefined),
// AFAIK, we've never supported a fastboot overlay directory in an
// engine. But if we do need that, it would go here.
@@ -1226,7 +1225,7 @@ export class CompatAppBuilder {
let styles = [];
// only import styles from engines with a parent (this excludeds the parent application) as their styles
// will be inserted via a direct tag.
- if (appFiles.engine.parent && appFiles.engine.package.isLazyEngine()) {
+ if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {
let implicitStyles = this.impliedAssets('implicit-styles', appFiles);
for (let style of implicitStyles) {
styles.push({
diff --git a/packages/compat/tests/audit.test.ts b/packages/compat/tests/audit.test.ts
index d8474cf03..478c7b7b2 100644
--- a/packages/compat/tests/audit.test.ts
+++ b/packages/compat/tests/audit.test.ts
@@ -48,6 +48,7 @@ describe('audit', function () {
fastbootFiles: {},
activeAddons: [],
root: app.baseDir,
+ isLazy: false,
},
],
resolvableExtensions,
diff --git a/packages/core/src/app-files.ts b/packages/core/src/app-files.ts
index 4bd825ed2..d3ec4fa6b 100644
--- a/packages/core/src/app-files.ts
+++ b/packages/core/src/app-files.ts
@@ -204,12 +204,10 @@ export interface Engine {
package: Package;
// the set of active addons in the engine. For each one we keep track of a file that can resolve the addon, because we'll need that later.
addons: Map;
- // the parent engine, if any
- parent: Engine | undefined;
- // where the engine's own V2 code comes from
- sourcePath: string;
+ // is this the top-level engine?
+ isApp: boolean;
// runtime name for the engine's own module namespace
modulePrefix: string;
- // this is destPath but relative to the app itself
+ // TODO: remove this after we remove the stage2 entrypoint
appRelativePath: string;
}
diff --git a/packages/core/src/module-resolver.ts b/packages/core/src/module-resolver.ts
index 53d4b2aa7..65a51d5c2 100644
--- a/packages/core/src/module-resolver.ts
+++ b/packages/core/src/module-resolver.ts
@@ -95,11 +95,14 @@ export interface Options {
amdCompatibility: Required;
}
-interface EngineConfig {
+// TODO: once we can remove the stage2 entrypoint this type can get streamlined
+// to the parts we actually need
+export interface EngineConfig {
packageName: string;
activeAddons: { name: string; root: string; canResolveFromFile: string }[];
fastbootFiles: { [appName: string]: { localFilename: string; shadowedFilename: string | undefined } };
root: string;
+ isLazy: boolean;
}
type MergeEntry =
diff --git a/tests/scenarios/compat-resolver-test.ts b/tests/scenarios/compat-resolver-test.ts
index 485c365da..cf6b46f28 100644
--- a/tests/scenarios/compat-resolver-test.ts
+++ b/tests/scenarios/compat-resolver-test.ts
@@ -81,6 +81,7 @@ Scenarios.fromProject(() => new Project())
root: app.dir,
activeAddons: [],
fastbootFiles: {},
+ isLazy: false,
},
],
modulePrefix: 'my-app',
diff --git a/tests/scenarios/core-resolver-test.ts b/tests/scenarios/core-resolver-test.ts
index b1c0dceee..96b25a5aa 100644
--- a/tests/scenarios/core-resolver-test.ts
+++ b/tests/scenarios/core-resolver-test.ts
@@ -101,6 +101,7 @@ Scenarios.fromProject(() => new Project())
engines: [
{
packageName: 'my-app',
+ isLazy: false,
root: app.dir,
fastbootFiles: opts?.fastbootFiles ?? {},
activeAddons: [