mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-27 18:29:47 +08:00
feat(@angular-devkit/build-angular): add aot option to karma
This commit is contained in:
parent
8faaf51d61
commit
523d539c66
goldens/public-api/angular_devkit/build_angular
packages/angular_devkit/build_angular/src/builders/karma
@ -206,6 +206,7 @@ export type FileReplacement = {
|
||||
|
||||
// @public
|
||||
export type KarmaBuilderOptions = {
|
||||
aot?: boolean;
|
||||
assets?: AssetPattern_2[];
|
||||
browsers?: Browsers;
|
||||
builderMode?: BuilderMode;
|
||||
|
@ -396,7 +396,7 @@ async function initializeApplication(
|
||||
entryPoints,
|
||||
tsConfig: options.tsConfig,
|
||||
outputPath,
|
||||
aot: false,
|
||||
aot: options.aot,
|
||||
index: false,
|
||||
outputHashing: OutputHashing.None,
|
||||
optimization: false,
|
||||
|
@ -276,6 +276,11 @@
|
||||
"webWorkerTsConfig": {
|
||||
"type": "string",
|
||||
"description": "TypeScript configuration for Web Worker modules."
|
||||
},
|
||||
"aot": {
|
||||
"type": "boolean",
|
||||
"description": "Run tests using Ahead of Time compilation.",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import { execute } from '../../index';
|
||||
import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup';
|
||||
import { BuilderMode } from '../../schema';
|
||||
|
||||
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
|
||||
describe('Option: "aot"', () => {
|
||||
it('enables aot', async () => {
|
||||
await setupTarget(harness);
|
||||
|
||||
await harness.writeFiles({
|
||||
'src/aot.spec.ts': `
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
describe('Hello', () => {
|
||||
it('should *not* contain jit instructions', () => {
|
||||
@Component({
|
||||
template: 'Hello',
|
||||
})
|
||||
class Hello {}
|
||||
|
||||
expect((Hello as any).ɵcmp.template.toString()).not.toContain('jit');
|
||||
});
|
||||
});
|
||||
`,
|
||||
});
|
||||
|
||||
harness.useTarget('test', {
|
||||
...BASE_OPTIONS,
|
||||
aot: true,
|
||||
/** Cf. {@link ../builder-mode_spec.ts} */
|
||||
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'],
|
||||
builderMode: BuilderMode.Application,
|
||||
});
|
||||
|
||||
const { result } = await harness.executeOnce();
|
||||
expect(result?.success).toBeTrue();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user