Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2da72e5

Browse files
filipesilvaBrocco
authored andcommittedSep 22, 2017
fix(@ngtools/webpack): fix Angular 5 lazy routes in es2015
Fix #7689
1 parent 4f0f652 commit 2da72e5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed
 

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,22 @@ export class AngularCompilerPlugin implements Tapable {
363363
// being built.
364364
const angularCoreModuleDir = path.dirname(angularCoreModulePath).split(/node_modules/).pop();
365365

366+
// Also support the es2015 in Angular versions that have it.
367+
let angularCoreEs2015Dir: string | undefined;
368+
if (angularCorePackageJson['es2015']) {
369+
const angularCoreEs2015Path = path.resolve(path.dirname(angularCorePackagePath),
370+
angularCorePackageJson['es2015']);
371+
angularCoreEs2015Dir = path.dirname(angularCoreEs2015Path).split(/node_modules/).pop();
372+
}
373+
366374
cmf.plugin('after-resolve', (result: any, callback: (err?: any, request?: any) => void) => {
367375
if (!result) {
368376
return callback();
369377
}
370378

371379
// Alter only request from Angular.
372-
if (angularCoreModuleDir && !result.resource.endsWith(angularCoreModuleDir)) {
380+
if (!(angularCoreModuleDir && result.resource.endsWith(angularCoreModuleDir))
381+
&& !(angularCoreEs2015Dir && result.resource.endsWith(angularCoreEs2015Dir))) {
373382
return callback(null, result);
374383
}
375384

‎packages/@ngtools/webpack/src/plugin.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,14 @@ export class AotPlugin implements Tapable {
358358
// being built.
359359
const angularCoreModuleDir = path.dirname(angularCoreModulePath).split(/node_modules/).pop();
360360

361+
// Also support the es2015 in Angular versions that have it.
362+
let angularCoreEs2015Dir: string | undefined;
363+
if (angularCorePackageJson['es2015']) {
364+
const angularCoreEs2015Path = path.resolve(path.dirname(angularCorePackagePath),
365+
angularCorePackageJson['es2015']);
366+
angularCoreEs2015Dir = path.dirname(angularCoreEs2015Path).split(/node_modules/).pop();
367+
}
368+
361369
cmf.plugin('after-resolve', (result: any, callback: (err?: any, request?: any) => void) => {
362370
if (!result) {
363371
return callback();
@@ -368,7 +376,8 @@ export class AotPlugin implements Tapable {
368376
// The other logic is for flat modules and requires reading the package.json of angular
369377
// (see above).
370378
if (!result.resource.endsWith(path.join('@angular/core/src/linker'))
371-
&& (angularCoreModuleDir && !result.resource.endsWith(angularCoreModuleDir))) {
379+
&& !(angularCoreModuleDir && result.resource.endsWith(angularCoreModuleDir))
380+
&& !(angularCoreEs2015Dir && result.resource.endsWith(angularCoreEs2015Dir))) {
372381
return callback(null, result);
373382
}
374383

0 commit comments

Comments
 (0)
Please sign in to comment.