Skip to content

Commit 02ee393

Browse files
clydinhansl
authored andcommitted
fix(@ngtools/webpack): normalize lazy route names and paths
1 parent fd31afa commit 02ee393

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,19 +447,20 @@ export class AngularCompilerPlugin implements Tapable {
447447
.forEach(lazyRouteKey => {
448448
const [lazyRouteModule, moduleName] = lazyRouteKey.split('#');
449449

450-
if (!lazyRouteModule || !moduleName) {
450+
if (!lazyRouteModule) {
451451
return;
452452
}
453453

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

457457
if (this._JitMode) {
458458
modulePath = lazyRouteTSFile;
459-
moduleKey = lazyRouteKey;
459+
moduleKey = `${lazyRouteModule}${moduleName ? '#' + moduleName : ''}`;
460460
} else {
461461
modulePath = lazyRouteTSFile.replace(/(\.d)?\.ts$/, `.ngfactory.js`);
462-
moduleKey = `${lazyRouteModule}.ngfactory#${moduleName}NgFactory`;
462+
const factoryModuleName = moduleName ? `#${moduleName}NgFactory` : '';
463+
moduleKey = `${lazyRouteModule}.ngfactory${factoryModuleName}`;
463464
}
464465

465466
if (moduleKey in this._lazyRoutes) {

0 commit comments

Comments
 (0)