Skip to content

Commit 2bae1a9

Browse files
cexbrayatalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): support aot option for karma browser builder
1 parent adf4ea5 commit 2bae1a9

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

packages/angular_devkit/build_angular/src/builders/karma/browser_builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async function initializeBrowser(
131131
budgets: undefined,
132132
optimization: false,
133133
buildOptimizer: false,
134-
aot: false,
134+
aot: options.aot,
135135
vendorChunk: true,
136136
namedChunks: true,
137137
extractLicenses: false,

packages/angular_devkit/build_angular/src/builders/karma/tests/options/aot_spec.ts

+34-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import { BuilderMode } from '../../schema';
1212

1313
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
1414
describe('Option: "aot"', () => {
15-
it('enables aot', async () => {
15+
it('enables aot with application builder', async () => {
1616
await setupTarget(harness);
1717

1818
await harness.writeFiles({
1919
'src/aot.spec.ts': `
2020
import { Component } from '@angular/core';
21-
21+
2222
describe('Hello', () => {
2323
it('should *not* contain jit instructions', () => {
2424
@Component({
@@ -43,5 +43,37 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
4343
const { result } = await harness.executeOnce();
4444
expect(result?.success).toBeTrue();
4545
});
46+
47+
it('enables aot with browser builder', async () => {
48+
await setupTarget(harness);
49+
50+
await harness.writeFiles({
51+
'src/aot.spec.ts': `
52+
import { Component } from '@angular/core';
53+
54+
describe('Hello', () => {
55+
it('should *not* contain jit instructions', () => {
56+
@Component({
57+
template: 'Hello',
58+
})
59+
class Hello {}
60+
61+
expect((Hello as any).ɵcmp.template.toString()).not.toContain('jit');
62+
});
63+
});
64+
`,
65+
});
66+
67+
harness.useTarget('test', {
68+
...BASE_OPTIONS,
69+
aot: true,
70+
/** Cf. {@link ../builder-mode_spec.ts} */
71+
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'],
72+
builderMode: BuilderMode.Browser,
73+
});
74+
75+
const { result } = await harness.executeOnce();
76+
expect(result?.success).toBeTrue();
77+
});
4678
});
4779
});

0 commit comments

Comments
 (0)