Skip to content

Commit 953104e

Browse files
committed
refactor(@angular-devkit/build-angular): configure AOT compiler to skip NgModule scope metadata emit in esbuild
The esbuild plugin used within the esbuild-based browser application builder will now use the newly introduced internal `supportJitMode` AOT compiler option to disable the emit of NgModule scope metadata functions within the output code. This removes the need to perform an additional transformation of the AOT compiler generated code to immediately remove the metadata. The Angular CLI neither previously nor currently supports hybrid AOT/JIT mode. In the future if this support situation changes, additional behavior may be added control the internal `supportJitMode` option.
1 parent e0e844d commit 953104e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/angular_devkit/build_angular/src/builders/application/tests/behavior/angular-aot-metadata_spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,16 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
2121

2222
harness.expectFile('dist/main.js').content.not.toContain('setClassMetadata');
2323
});
24+
25+
it('should not emit any AOT NgModule scope metadata functions', async () => {
26+
harness.useTarget('build', {
27+
...BASE_OPTIONS,
28+
});
29+
30+
const { result } = await harness.executeOnce();
31+
expect(result?.success).toBe(true);
32+
33+
harness.expectFile('dist/main.js').content.not.toContain('setNgModuleScope');
34+
});
2435
});
2536
});

packages/angular_devkit/build_angular/src/tools/esbuild/angular/compilation/angular-compilation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export abstract class AngularCompilation {
4646
annotationsAs: 'decorators',
4747
enableResourceInlining: false,
4848
supportTestBed: false,
49+
supportJitMode: false,
4950
}),
5051
);
5152
}

0 commit comments

Comments
 (0)