Skip to content

Commit 86d1df5

Browse files
committed
fix(@angular/build): include full metadata for AOT unit-testing
Include class metadata and JIT information in code built for development and/or test usage. All non-optimized builds will now contain this metadata (`optimization.scripts` is false). The Angular TestBed APIs require additional metadata for the Angular aspects of the application such as Components, Modules, Pipes, etc. TestBed may also leverage JIT capabilities during testing (e.g., overrideComponent). To support all these TestBed usage scenarios both the underlying `setClassMetadata` and `setNgModuleScope` class augmentation functions are now emitted when test metadata inclusion is enabled.
1 parent d16e358 commit 86d1df5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export interface CompilerPluginOptions {
3535
sourcemap: boolean | 'external';
3636
tsconfig: string;
3737
jit?: boolean;
38+
/**
39+
* Include class metadata and JIT information in built code.
40+
* The Angular TestBed APIs require additional metadata for the Angular aspects of the application
41+
* such as Components, Modules, Pipes, etc.
42+
* TestBed may also leverage JIT capabilities during testing (e.g., overrideComponent).
43+
*/
3844
includeTestMetadata?: boolean;
3945

4046
advancedOptimizations?: boolean;
@@ -89,7 +95,7 @@ export function createCompilerPlugin(
8995
sourcemap: !!pluginOptions.sourcemap,
9096
thirdPartySourcemaps: pluginOptions.thirdPartySourcemaps,
9197
advancedOptimizations: pluginOptions.advancedOptimizations,
92-
jit: pluginOptions.jit,
98+
jit: pluginOptions.jit || pluginOptions.includeTestMetadata,
9399
},
94100
maxWorkers,
95101
cacheStore?.createCache('jstransformer'),
@@ -718,6 +724,7 @@ function createCompilerOptionsTransformer(
718724
externalRuntimeStyles: pluginOptions.externalRuntimeStyles,
719725
_enableHmr: !!pluginOptions.templateUpdates,
720726
supportTestBed: !!pluginOptions.includeTestMetadata,
727+
supportJitMode: !!pluginOptions.includeTestMetadata,
721728
};
722729
};
723730
}

0 commit comments

Comments
 (0)