Skip to content

Commit 2a2dc1e

Browse files
clydinhansl
authored andcommitted
fix(@ngtools/webpack): normalize lazy route names and paths
1 parent 7ce6523 commit 2a2dc1e

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
@@ -450,19 +450,20 @@ export class AngularCompilerPlugin implements Tapable {
450450
.forEach(lazyRouteKey => {
451451
const [lazyRouteModule, moduleName] = lazyRouteKey.split('#');
452452

453-
if (!lazyRouteModule || !moduleName) {
453+
if (!lazyRouteModule) {
454454
return;
455455
}
456456

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

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

468469
if (moduleKey in this._lazyRoutes) {

0 commit comments

Comments
 (0)