Skip to content

Commit 4b507fd

Browse files
committed
fix(@ngtools/webpack): normalize lazy route names and paths
1 parent 6075f9c commit 4b507fd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/@ngtools/webpack/src/angular_compiler_plugin.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -449,19 +449,20 @@ export class AngularCompilerPlugin implements Tapable {
449449
.forEach(lazyRouteKey => {
450450
const [lazyRouteModule, moduleName] = lazyRouteKey.split('#');
451451

452-
if (!lazyRouteModule || !moduleName) {
452+
if (!lazyRouteModule) {
453453
return;
454454
}
455455

456-
const lazyRouteTSFile = discoveredLazyRoutes[lazyRouteKey];
456+
const lazyRouteTSFile = discoveredLazyRoutes[lazyRouteKey].replace(/\\/g, '/');
457457
let modulePath: string, moduleKey: string;
458458

459459
if (this._JitMode) {
460460
modulePath = lazyRouteTSFile;
461-
moduleKey = lazyRouteKey;
461+
moduleKey = `${lazyRouteModule}${moduleName ? '#' + moduleName : ''}`;
462462
} else {
463463
modulePath = lazyRouteTSFile.replace(/(\.d)?\.ts$/, `.ngfactory.js`);
464-
moduleKey = `${lazyRouteModule}.ngfactory#${moduleName}NgFactory`;
464+
const factoryModuleName = moduleName ? `#${moduleName}NgFactory` : '';
465+
moduleKey = `${lazyRouteModule}.ngfactory${factoryModuleName}`;
465466
}
466467

467468
if (moduleKey in this._lazyRoutes) {

0 commit comments

Comments
 (0)