Skip to content

Commit 115276a

Browse files
filipesilvaalexeagle
authored andcommitted
fix(@ngtools/webpack): don't load ngfactories for lazy routes with Ivy
Supersedes angular#13524
1 parent d0040fc commit 115276a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/angular_compiler_plugin.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,14 @@ export class AngularCompilerPlugin {
500500
const lazyRouteTSFile = discoveredLazyRoutes[lazyRouteKey].replace(/\\/g, '/');
501501
let modulePath: string, moduleKey: string;
502502

503-
if (this._JitMode) {
503+
if (this._JitMode ||
504+
// When using Ivy and not using allowEmptyCodegenFiles, factories are not generated.
505+
(this._compilerOptions.enableIvy && !this._compilerOptions.allowEmptyCodegenFiles)
506+
) {
504507
modulePath = lazyRouteTSFile;
505508
moduleKey = `${lazyRouteModule}${moduleName ? '#' + moduleName : ''}`;
506509
} else {
510+
// NgFactories are only used with AOT on ngc (legacy) mode.
507511
modulePath = lazyRouteTSFile.replace(/(\.d)?\.tsx?$/, '');
508512
modulePath += '.ngfactory.js';
509513
const factoryModuleName = moduleName ? `#${moduleName}NgFactory` : '';

0 commit comments

Comments
 (0)