Skip to content

Commit 1dbd574

Browse files
alan-agius4Keen Yee Liau
authored andcommitted
fix(@ngtools/webpack): Fix lazy loading (#12945)
* revert: fix(@ngtools/webpack): output consistent filename This reverts commit df172bd. * refactor(@ngtools/webpack): remove RegExp for ngfactory This RegExp is not needed as if it actually works it will break lazy loading as in case of AOT, the name should always be suffixed with ngfactory https://github.com/angular/angular/blob/4c2ce4e8ba4c5ac5ce8754d67bc6603eaad4564a/packages/core/src/linker/system_js_ng_module_factory_loader.ts#L83
1 parent 0014186 commit 1dbd574

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/angular_devkit/build_angular/test/browser/lazy-module_spec_large.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('Browser Builder lazy modules', () => {
142142
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
143143
tap(() => {
144144
expect(host.scopedSync()
145-
.exists(join(outputPath, 'lazy-lazy-module.js'))).toBe(true);
145+
.exists(join(outputPath, 'lazy-lazy-module-ngfactory.js'))).toBe(true);
146146
}),
147147
).toPromise().then(done, done.fail);
148148
});
@@ -301,7 +301,7 @@ describe('Browser Builder lazy modules', () => {
301301
runTargetSpec(host, browserTargetSpec, overrides, DefaultTimeout * 2).pipe(
302302
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
303303
tap(() => expect(host.scopedSync()
304-
.exists(join(outputPath, 'src-app-lazy-lazy-module.js')))
304+
.exists(join(outputPath, 'src-app-lazy-lazy-module-ngfactory.js')))
305305
.toBe(true)),
306306
).toPromise().then(done, done.fail);
307307
});

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,8 @@ export class AngularCompilerPlugin {
690690
const dependencies = Object.keys(this._lazyRoutes)
691691
.map((key) => {
692692
const modulePath = this._lazyRoutes[key];
693-
const importPath = key.split('#')[0];
694693
if (modulePath !== null) {
695-
const name = importPath.replace(/(\.ngfactory)?(\.(js|ts))?$/, '');
694+
const name = key.split('#')[0];
696695

697696
return new this._contextElementDependencyConstructor(modulePath, name);
698697
} else {

0 commit comments

Comments
 (0)