Skip to content

Commit 578525e

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 8bfdd3d commit 578525e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

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

4047
advancedOptimizations?: boolean;
@@ -89,7 +96,7 @@ export function createCompilerPlugin(
8996
sourcemap: !!pluginOptions.sourcemap,
9097
thirdPartySourcemaps: pluginOptions.thirdPartySourcemaps,
9198
advancedOptimizations: pluginOptions.advancedOptimizations,
92-
jit: pluginOptions.jit,
99+
jit: pluginOptions.jit || pluginOptions.includeTestMetadata,
93100
},
94101
maxWorkers,
95102
cacheStore?.createCache('jstransformer'),
@@ -718,6 +725,7 @@ function createCompilerOptionsTransformer(
718725
externalRuntimeStyles: pluginOptions.externalRuntimeStyles,
719726
_enableHmr: !!pluginOptions.templateUpdates,
720727
supportTestBed: !!pluginOptions.includeTestMetadata,
728+
supportJitMode: !!pluginOptions.includeTestMetadata,
721729
};
722730
};
723731
}

0 commit comments

Comments
 (0)