Skip to content

Commit 8219380

Browse files
Alan Agiusalexeagle
authored andcommitted
fix(@ngtools/webpack): replace bootstrap code under Ivy unless running in JIT mode
The bootstrap code always needs to be replaced if not running in JIT mode as other wise the entire compiler will be pulled in because we will not replace the bootstrapping code to use `platform-browser` instead of `platform-browser-dynamic`.
1 parent 2b23454 commit 8219380

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,13 +948,13 @@ export class AngularCompilerPlugin {
948948
this._normalizedLocale));
949949
}
950950

951-
if (this._useFactories) {
952-
// Replace bootstrap in browser AOT.
951+
if (!this._JitMode) {
952+
// Replace bootstrap in browser non JIT Mode.
953953
this._transformers.push(replaceBootstrap(
954954
isAppPath,
955955
getEntryModule,
956956
getTypeChecker,
957-
!!this._compilerOptions.enableIvy,
957+
this._useFactories,
958958
));
959959
}
960960
} else if (this._platform === PLATFORM.Server) {

packages/ngtools/webpack/src/transformers/replace_bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function replaceBootstrap(
1717
shouldTransform: (fileName: string) => boolean,
1818
getEntryModule: () => { path: string, className: string } | null,
1919
getTypeChecker: () => ts.TypeChecker,
20-
enableIvy?: boolean,
20+
useFactories = true,
2121
): ts.TransformerFactory<ts.SourceFile> {
2222

2323
const standardTransform: StandardTransform = function (sourceFile: ts.SourceFile) {
@@ -82,7 +82,7 @@ export function replaceBootstrap(
8282
let modulePath = `./${relativeEntryModulePath}`.replace(/\\/g, '/');
8383
let bootstrapIdentifier = 'bootstrapModule';
8484

85-
if (!enableIvy) {
85+
if (useFactories) {
8686
className += 'NgFactory';
8787
modulePath += '.ngfactory';
8888
bootstrapIdentifier = 'bootstrapModuleFactory';

packages/ngtools/webpack/src/transformers/replace_bootstrap_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('@ngtools/webpack transformers', () => {
5252
expect(tags.oneLine`${result}`).toEqual(tags.oneLine`${output}`);
5353
});
5454

55-
it('should replace bootstrap for Ivy without referencing ngFactory', () => {
55+
it('should replace bootstrap without referencing ngFactory when useFactories is false', () => {
5656
const input = tags.stripIndent`
5757
import { enableProdMode } from '@angular/core';
5858
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
@@ -87,7 +87,7 @@ describe('@ngtools/webpack transformers', () => {
8787
() => true,
8888
() => ({ path: '/project/src/app/app.module', className: 'AppModule' }),
8989
() => program.getTypeChecker(),
90-
true,
90+
false,
9191
);
9292
const result = transformTypescript(undefined, [transformer], program, compilerHost);
9393

0 commit comments

Comments
 (0)