File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,9 @@ export class Version {
9494 if ( v . isLocal ( ) ) {
9595 console . warn ( yellow ( 'Using a local version of angular. Proceeding with care...' ) ) ;
9696 } else {
97- if ( ! v . isGreaterThanOrEqualTo ( new SemVer ( '2.3.1' ) ) ) {
97+ // Check if major is not 0, so that we stay compatible with local compiled versions
98+ // of angular.
99+ if ( ! v . isGreaterThanOrEqualTo ( new SemVer ( '2.3.1' ) ) && v . major != 0 ) {
98100 console . error ( bold ( red ( stripIndents `
99101 This version of CLI is only compatible with angular version 2.3.1 or better. Please
100102 upgrade your angular version, e.g. by running:
Original file line number Diff line number Diff line change @@ -269,13 +269,26 @@ export class AotPlugin implements Tapable {
269269
270270 // Add lazy modules to the context module for @angular /core/src/linker
271271 compiler . plugin ( 'context-module-factory' , ( cmf : any ) => {
272+ const angularCorePackagePath = require . resolve ( '@angular/core/package.json' ) ;
273+ const angularCorePackageJson = require ( angularCorePackagePath ) ;
274+ const angularCoreModulePath = path . resolve ( path . dirname ( angularCorePackagePath ) ,
275+ angularCorePackageJson [ 'module' ] ) ;
276+ // Pick the last part after the last node_modules instance. We do this to let people have
277+ // a linked @angular /core or cli which would not be under the same path as the project
278+ // being built.
279+ const angularCoreModuleDir = path . dirname ( angularCoreModulePath ) . split ( / n o d e _ m o d u l e s / ) . pop ( ) ;
280+
272281 cmf . plugin ( 'after-resolve' , ( result : any , callback : ( err ?: any , request ?: any ) => void ) => {
273282 if ( ! result ) {
274283 return callback ( ) ;
275284 }
276285
277- // alter only request from @angular /core/src/linker
278- if ( ! result . resource . endsWith ( path . join ( '@angular/core/src/linker' ) ) ) {
286+ // Alter only request from Angular;
287+ // @angular /core/src/linker matches for 2.*.*,
288+ // The other logic is for flat modules and requires reading the package.json of angular
289+ // (see above).
290+ if ( ! result . resource . endsWith ( path . join ( '@angular/core/src/linker' ) )
291+ && ( angularCoreModuleDir && ! result . resource . endsWith ( angularCoreModuleDir ) ) ) {
279292 return callback ( null , result ) ;
280293 }
281294
You can’t perform that action at this time.
0 commit comments