Skip to content

Commit 8f038de

Browse files
committed
refactor(@angular-devkit/build-angular): remove implicit localize polyfill
In the v19 application builder, the localize polyfill should not be added implicitly. See: d6a3403
1 parent bd52d11 commit 8f038de

14 files changed

+34
-43
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
ResultKind,
1313
buildApplicationInternal,
1414
emitFilesToDisk,
15-
purgeStaleBuildCache,
1615
} from '@angular/build/private';
1716
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
1817
import { randomUUID } from 'crypto';
@@ -22,7 +21,6 @@ import * as path from 'path';
2221
import { Observable, catchError, defaultIfEmpty, from, of, switchMap } from 'rxjs';
2322
import { Configuration } from 'webpack';
2423
import { ExecutionTransformer } from '../../transforms';
25-
import { readTsconfig } from '../../utils/read-tsconfig';
2624
import { OutputHashing } from '../browser-esbuild/schema';
2725
import { findTests } from './find-tests';
2826
import { Schema as KarmaBuilderOptions } from './schema';
@@ -110,18 +108,6 @@ async function collectEntrypoints(
110108
entryPoints.add('zone.js/testing');
111109
}
112110

113-
const tsConfigPath = path.resolve(context.workspaceRoot, options.tsConfig);
114-
const tsConfig = await readTsconfig(tsConfigPath);
115-
116-
const localizePackageInitEntryPoint = '@angular/localize/init';
117-
const hasLocalizeType = tsConfig.options.types?.some(
118-
(t) => t === '@angular/localize' || t === localizePackageInitEntryPoint,
119-
);
120-
121-
if (hasLocalizeType) {
122-
polyfills.push(localizePackageInitEntryPoint);
123-
}
124-
125111
return [entryPoints, polyfills];
126112
}
127113

packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/code-coverage_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isAppli
2929
});
3030
}
3131

32-
beforeEach(() => {
33-
setupTarget(harness);
32+
beforeEach(async () => {
33+
await setupTarget(harness);
3434
});
3535

3636
it('should generate coverage report when file was previously processed by Babel', async () => {

packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/errors_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup
1111

1212
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
1313
describe('Behavior: "Errors"', () => {
14-
beforeEach(() => {
15-
setupTarget(harness);
14+
beforeEach(async () => {
15+
await setupTarget(harness);
1616
});
1717

1818
it('should fail when there is a TypeScript error', async () => {

packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/module-cjs_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup
1111

1212
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
1313
describe('Behavior: "module commonjs"', () => {
14-
beforeEach(() => {
15-
setupTarget(harness);
14+
beforeEach(async () => {
15+
await setupTarget(harness);
1616
});
1717

1818
it('should work when module is commonjs', async () => {

packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/rebuilds_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isAppli
1818
});
1919
}
2020

21-
beforeEach(() => {
22-
setupTarget(harness);
21+
beforeEach(async () => {
22+
await setupTarget(harness);
2323
});
2424

2525
it('recovers from compilation failures in watch mode', async () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup
1111

1212
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
1313
describe('Option: "assets"', () => {
14-
beforeEach(() => {
15-
setupTarget(harness);
14+
beforeEach(async () => {
15+
await setupTarget(harness);
1616
});
1717

1818
it('includes assets', async () => {

packages/angular_devkit/build_angular/src/builders/karma/tests/options/builder-mode_spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ const ESBUILD_LOG_TEXT = 'Application bundle generation complete.';
1414

1515
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isApplicationTarget) => {
1616
describe('option: "builderMode"', () => {
17-
beforeEach(() => {
18-
setupTarget(harness);
17+
beforeEach(async () => {
18+
await setupTarget(harness);
1919
});
2020

2121
it('"application" always uses esbuild', async () => {
2222
harness.useTarget('test', {
2323
...BASE_OPTIONS,
24+
// Must explicitly provide localize polyfill:
25+
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'],
2426
builderMode: BuilderMode.Application,
2527
});
2628

packages/angular_devkit/build_angular/src/builders/karma/tests/options/code-coverage-exclude_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isAppli
2626
});
2727
}
2828

29-
beforeEach(() => {
30-
setupTarget(harness);
29+
beforeEach(async () => {
30+
await setupTarget(harness);
3131
});
3232

3333
it('should exclude file from coverage when set', async () => {

packages/angular_devkit/build_angular/src/builders/karma/tests/options/code-coverage_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isAppli
2727
});
2828
}
2929

30-
beforeEach(() => {
31-
setupTarget(harness);
30+
beforeEach(async () => {
31+
await setupTarget(harness);
3232
});
3333

3434
it('should generate coverage report when option is set to true', async () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup
1111

1212
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
1313
describe('Option: "exclude"', () => {
14-
beforeEach(() => {
15-
setupTarget(harness);
14+
beforeEach(async () => {
15+
await setupTarget(harness);
1616
});
1717

1818
beforeEach(async () => {

0 commit comments

Comments
 (0)