mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-28 02:58:04 +08:00
feat(@angular-devkit/build-angular): add aot option to karma
This commit is contained in:
parent
8faaf51d61
commit
523d539c66
@ -206,6 +206,7 @@ export type FileReplacement = {
|
|||||||
|
|
||||||
// @public
|
// @public
|
||||||
export type KarmaBuilderOptions = {
|
export type KarmaBuilderOptions = {
|
||||||
|
aot?: boolean;
|
||||||
assets?: AssetPattern_2[];
|
assets?: AssetPattern_2[];
|
||||||
browsers?: Browsers;
|
browsers?: Browsers;
|
||||||
builderMode?: BuilderMode;
|
builderMode?: BuilderMode;
|
||||||
|
@ -396,7 +396,7 @@ async function initializeApplication(
|
|||||||
entryPoints,
|
entryPoints,
|
||||||
tsConfig: options.tsConfig,
|
tsConfig: options.tsConfig,
|
||||||
outputPath,
|
outputPath,
|
||||||
aot: false,
|
aot: options.aot,
|
||||||
index: false,
|
index: false,
|
||||||
outputHashing: OutputHashing.None,
|
outputHashing: OutputHashing.None,
|
||||||
optimization: false,
|
optimization: false,
|
||||||
|
@ -276,6 +276,11 @@
|
|||||||
"webWorkerTsConfig": {
|
"webWorkerTsConfig": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "TypeScript configuration for Web Worker modules."
|
"description": "TypeScript configuration for Web Worker modules."
|
||||||
|
},
|
||||||
|
"aot": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Run tests using Ahead of Time compilation.",
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": 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