File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,9 @@ export class Version {
94
94
if ( v . isLocal ( ) ) {
95
95
console . warn ( yellow ( 'Using a local version of angular. Proceeding with care...' ) ) ;
96
96
} 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 ) {
98
100
console . error ( bold ( red ( stripIndents `
99
101
This version of CLI is only compatible with angular version 2.3.1 or better. Please
100
102
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 {
269
269
270
270
// Add lazy modules to the context module for @angular /core/src/linker
271
271
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
+
272
281
cmf . plugin ( 'after-resolve' , ( result : any , callback : ( err ?: any , request ?: any ) => void ) => {
273
282
if ( ! result ) {
274
283
return callback ( ) ;
275
284
}
276
285
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 ) ) ) {
279
292
return callback ( null , result ) ;
280
293
}
281
294
You can’t perform that action at this time.
0 commit comments