diff --git a/packages/core/src/module-resolver.ts b/packages/core/src/module-resolver.ts index 12032e9cb..d938065a5 100644 --- a/packages/core/src/module-resolver.ts +++ b/packages/core/src/module-resolver.ts @@ -453,18 +453,18 @@ export class Resolver { private resolveComponent(path: string, inEngine: EngineConfig, request: R): R { let target = this.parseGlobalPath(path, inEngine); - let hbsModule: string | null = null; - let jsModule: string | null = null; + let hbsModule: { requested: string; found: string } | null = null; + let jsModule: { requested: string; found: string } | null = null; // first, the various places our template might be. for (let candidate of this.componentTemplateCandidates(target.packageName)) { - let candidateSpecifier = `${target.packageName}${candidate.prefix}${target.memberName}${candidate.suffix}`; + let candidateSpecifier = `${target.packageName}${candidate.prefix}${target.memberName}${candidate.suffix}.hbs`; let resolution = this.nodeResolve( `${target.packageName}${candidate.prefix}${target.memberName}${candidate.suffix}`, target.from ); if (resolution.type === 'real') { - hbsModule = candidateSpecifier; + hbsModule = { requested: candidateSpecifier, found: resolution.filename }; break; } } @@ -478,7 +478,7 @@ export class Resolver { // It matches as a priority lower than .js, so finding an .hbs means // there's definitely not a .js. if (resolution.type === 'real' && !resolution.filename.endsWith('.hbs')) { - jsModule = candidateSpecifier; + jsModule = { requested: candidateSpecifier, found: resolution.filename }; break; } } @@ -487,10 +487,14 @@ export class Resolver { return logTransition( `resolveComponent found legacy HBS`, request, - request.virtualize(virtualPairComponent(hbsModule, jsModule)) + request.virtualize(virtualPairComponent(hbsModule.found, jsModule?.found)) ); } else if (jsModule) { - return logTransition(`resolveComponent found only JS`, request, request.alias(jsModule).rehome(target.from)); + return logTransition( + `resolveComponent found only JS`, + request, + request.alias(jsModule.requested).rehome(target.from) + ); } else { return logTransition(`resolveComponent failed`, request); } diff --git a/packages/core/src/virtual-content.ts b/packages/core/src/virtual-content.ts index 02d428d28..c4c23c2f2 100644 --- a/packages/core/src/virtual-content.ts +++ b/packages/core/src/virtual-content.ts @@ -110,7 +110,7 @@ function decodeVirtualExternalCJSModule(filename: string) { const pairComponentMarker = '/embroider-pair-component'; const pairComponentPattern = /^(?.*)\/(?[^\/]*)\/embroider-pair-component$/; -export function virtualPairComponent(hbsModule: string, jsModule: string | null): string { +export function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string { let relativeJSModule = ''; if (jsModule) { // The '/j/' here represents the relativeJSModule itself that we're about to