From b4c320263a2692c6c16dc4f4f571ec00ae77db7d Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 12 Nov 2018 19:58:27 +0100 Subject: [PATCH 1/2] revert: fix(@ngtools/webpack): output consistent filename This reverts commit df172bdc8af4caa1a908592a8b9400d31c81eeb0. --- .../build_angular/test/browser/lazy-module_spec_large.ts | 4 ++-- packages/ngtools/webpack/src/angular_compiler_plugin.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/angular_devkit/build_angular/test/browser/lazy-module_spec_large.ts b/packages/angular_devkit/build_angular/test/browser/lazy-module_spec_large.ts index c6dbf303f186..001751bb86d2 100644 --- a/packages/angular_devkit/build_angular/test/browser/lazy-module_spec_large.ts +++ b/packages/angular_devkit/build_angular/test/browser/lazy-module_spec_large.ts @@ -142,7 +142,7 @@ describe('Browser Builder lazy modules', () => { tap((buildEvent) => expect(buildEvent.success).toBe(true)), tap(() => { expect(host.scopedSync() - .exists(join(outputPath, 'lazy-lazy-module.js'))).toBe(true); + .exists(join(outputPath, 'lazy-lazy-module-ngfactory.js'))).toBe(true); }), ).toPromise().then(done, done.fail); }); @@ -301,7 +301,7 @@ describe('Browser Builder lazy modules', () => { runTargetSpec(host, browserTargetSpec, overrides, DefaultTimeout * 2).pipe( tap((buildEvent) => expect(buildEvent.success).toBe(true)), tap(() => expect(host.scopedSync() - .exists(join(outputPath, 'src-app-lazy-lazy-module.js'))) + .exists(join(outputPath, 'src-app-lazy-lazy-module-ngfactory.js'))) .toBe(true)), ).toPromise().then(done, done.fail); }); diff --git a/packages/ngtools/webpack/src/angular_compiler_plugin.ts b/packages/ngtools/webpack/src/angular_compiler_plugin.ts index af5a4c78ea69..0204021e8f37 100644 --- a/packages/ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/ngtools/webpack/src/angular_compiler_plugin.ts @@ -698,7 +698,7 @@ export class AngularCompilerPlugin { const modulePath = this._lazyRoutes[key]; const importPath = key.split('#')[0]; if (modulePath !== null) { - const name = importPath.replace(/(\.ngfactory)?(\.(js|ts))?$/, ''); + const name = importPath.replace(/(\.ngfactory)?\.(js|ts)$/, ''); return new this._contextElementDependencyConstructor(modulePath, name); } else { From 542e86262ba4ba0a968a069d856114920ceeaad0 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 12 Nov 2018 20:19:47 +0100 Subject: [PATCH 2/2] 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 --- packages/ngtools/webpack/src/angular_compiler_plugin.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/ngtools/webpack/src/angular_compiler_plugin.ts b/packages/ngtools/webpack/src/angular_compiler_plugin.ts index 0204021e8f37..bc8c4daf2e01 100644 --- a/packages/ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/ngtools/webpack/src/angular_compiler_plugin.ts @@ -696,9 +696,8 @@ export class AngularCompilerPlugin { const dependencies = Object.keys(this._lazyRoutes) .map((key) => { const modulePath = this._lazyRoutes[key]; - const importPath = key.split('#')[0]; if (modulePath !== null) { - const name = importPath.replace(/(\.ngfactory)?\.(js|ts)$/, ''); + const name = key.split('#')[0]; return new this._contextElementDependencyConstructor(modulePath, name); } else {