Skip to content

Commit

Permalink
fix(@ngtools/webpack): normalize lazy route names and paths
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin authored and dond2clouds committed Apr 23, 2018
1 parent 35d6d68 commit c32c7d5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/@ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,19 +447,20 @@ export class AngularCompilerPlugin implements Tapable {
.forEach(lazyRouteKey => {
const [lazyRouteModule, moduleName] = lazyRouteKey.split('#');

if (!lazyRouteModule || !moduleName) {
if (!lazyRouteModule) {
return;
}

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

if (this._JitMode) {
modulePath = lazyRouteTSFile;
moduleKey = lazyRouteKey;
moduleKey = `${lazyRouteModule}${moduleName ? '#' + moduleName : ''}`;
} else {
modulePath = lazyRouteTSFile.replace(/(\.d)?\.ts$/, `.ngfactory.js`);
moduleKey = `${lazyRouteModule}.ngfactory#${moduleName}NgFactory`;
const factoryModuleName = moduleName ? `#${moduleName}NgFactory` : '';
moduleKey = `${lazyRouteModule}.ngfactory${factoryModuleName}`;
}

if (moduleKey in this._lazyRoutes) {
Expand Down

0 comments on commit c32c7d5

Please sign in to comment.