@@ -106,6 +106,7 @@ export interface AngularCompilerPluginOptions {
106
106
107
107
// added to the list of lazy routes
108
108
additionalLazyModules ?: { [ module : string ] : string } ;
109
+ additionalLazyModuleResources ?: string [ ] ;
109
110
110
111
// The ContextElementDependency of correct Webpack compilation.
111
112
// This is needed when there are multiple Webpack installs.
@@ -663,15 +664,19 @@ export class AngularCompilerPlugin {
663
664
// APFv6 does not have single FESM anymore. Instead of verifying if we're pointing to
664
665
// FESMs, we resolve the `@angular/core` path and verify that the path for the
665
666
// module starts with it.
666
-
667
667
// This may be slower but it will be compatible with both APF5, 6 and potential future
668
668
// versions (until the dynamic import appears outside of core I suppose).
669
669
// We resolve any symbolic links in order to get the real path that would be used in webpack.
670
- const angularCoreDirname = fs . realpathSync ( path . dirname ( angularCorePackagePath ) ) ;
670
+ const angularCoreResourceRoot = fs . realpathSync ( path . dirname ( angularCorePackagePath ) ) ;
671
671
672
672
cmf . hooks . afterResolve . tapPromise ( 'angular-compiler' , async result => {
673
- // Alter only request from Angular.
674
- if ( ! result || ! this . done || ! result . resource . startsWith ( angularCoreDirname ) ) {
673
+ // Alter only existing request from Angular or one of the additional lazy module resources.
674
+ const isLazyModuleResource = ( resource : string ) =>
675
+ resource . startsWith ( angularCoreResourceRoot ) ||
676
+ ( this . options . additionalLazyModuleResources &&
677
+ this . options . additionalLazyModuleResources . includes ( resource ) ) ;
678
+
679
+ if ( ! result || ! this . done || ! isLazyModuleResource ( result . resource ) ) {
675
680
return result ;
676
681
}
677
682
0 commit comments