Skip to content

Commit e7a6a77

Browse files
author
Angular Builds
committed
9d7613d fix(@angular-devkit/build-angular): zone.js/testing + karma + esbuild
1 parent c52f3b5 commit e7a6a77

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "19.0.0-next.8+sha-87a90af",
3+
"version": "19.0.0-next.8+sha-9d7613d",
44
"description": "Angular Webpack Build Facade",
55
"main": "src/index.js",
66
"typings": "src/index.d.ts",
77
"builders": "builders.json",
88
"dependencies": {
99
"@ampproject/remapping": "2.3.0",
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#87a90af",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#87a90af",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#87a90af",
13-
"@angular/build": "github:angular/angular-build-builds#87a90af",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#9d7613d",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#9d7613d",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#9d7613d",
13+
"@angular/build": "github:angular/angular-build-builds#9d7613d",
1414
"@babel/core": "7.25.2",
1515
"@babel/generator": "7.25.6",
1616
"@babel/helper-annotate-as-pure": "7.24.7",
@@ -21,7 +21,7 @@
2121
"@babel/preset-env": "7.25.4",
2222
"@babel/runtime": "7.25.6",
2323
"@discoveryjs/json-ext": "0.6.1",
24-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#87a90af",
24+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#9d7613d",
2525
"@vitejs/plugin-basic-ssl": "1.1.0",
2626
"ansi-colors": "4.1.3",
2727
"autoprefixer": "10.4.20",
@@ -77,7 +77,7 @@
7777
"@angular/localize": "^19.0.0-next.0",
7878
"@angular/platform-server": "^19.0.0-next.0",
7979
"@angular/service-worker": "^19.0.0-next.0",
80-
"@angular/ssr": "github:angular/angular-ssr-builds#87a90af",
80+
"@angular/ssr": "github:angular/angular-ssr-builds#9d7613d",
8181
"@web/test-runner": "^0.19.0",
8282
"browser-sync": "^3.0.2",
8383
"jest": "^29.5.0",
@@ -98,7 +98,7 @@
9898
"@angular/service-worker": {
9999
"optional": true
100100
},
101-
"@angular/ssr": "github:angular/angular-ssr-builds#87a90af",
101+
"@angular/ssr": "github:angular/angular-ssr-builds#9d7613d",
102102
"@web/test-runner": {
103103
"optional": true
104104
},

src/builders/karma/application_builder.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,28 @@ async function getProjectSourceRoot(context) {
7979
const sourceRoot = (projectMetadata.sourceRoot ?? projectMetadata.root ?? '');
8080
return path.join(context.workspaceRoot, sourceRoot);
8181
}
82+
function normalizePolyfills(polyfills) {
83+
if (typeof polyfills === 'string') {
84+
return [polyfills];
85+
}
86+
return polyfills ?? [];
87+
}
8288
async function collectEntrypoints(options, context, projectSourceRoot) {
8389
// Glob for files to test.
8490
const testFiles = await (0, find_tests_1.findTests)(options.include ?? [], options.exclude ?? [], context.workspaceRoot, projectSourceRoot);
8591
const entryPoints = new Set([
8692
...testFiles,
8793
'@angular-devkit/build-angular/src/builders/karma/init_test_bed.js',
8894
]);
89-
// Extract `zone.js/testing` to a separate entry point because it needs to be loaded after Jasmine.
90-
const [polyfills, hasZoneTesting] = extractZoneTesting(options.polyfills);
91-
if (hasZoneTesting) {
92-
entryPoints.add('zone.js/testing');
93-
}
94-
return [entryPoints, polyfills];
95+
return entryPoints;
9596
}
9697
async function initializeApplication(options, context, karmaOptions, transforms = {}) {
9798
if (transforms.webpackConfiguration) {
9899
context.logger.warn(`This build is using the application builder but transforms.webpackConfiguration was provided. The transform will be ignored.`);
99100
}
100101
const testDir = path.join(context.workspaceRoot, 'dist/test-out', (0, crypto_1.randomUUID)());
101102
const projectSourceRoot = await getProjectSourceRoot(context);
102-
const [karma, [entryPoints, polyfills]] = await Promise.all([
103+
const [karma, entryPoints] = await Promise.all([
103104
Promise.resolve().then(() => __importStar(require('karma'))),
104105
collectEntrypoints(options, context, projectSourceRoot),
105106
fs.rm(testDir, { recursive: true, force: true }),
@@ -124,7 +125,7 @@ async function initializeApplication(options, context, karmaOptions, transforms
124125
},
125126
instrumentForCoverage,
126127
styles: options.styles,
127-
polyfills,
128+
polyfills: normalizePolyfills(options.polyfills),
128129
webWorkerTsConfig: options.webWorkerTsConfig,
129130
}, context));
130131
if (buildOutput.kind === private_1.ResultKind.Failure) {
@@ -140,11 +141,8 @@ async function initializeApplication(options, context, karmaOptions, transforms
140141
// Serve polyfills first.
141142
{ pattern: `${testDir}/polyfills.js`, type: 'module' },
142143
// Allow loading of chunk-* files but don't include them all on load.
143-
{ pattern: `${testDir}/chunk-*.js`, type: 'module', included: false },
144-
// Allow loading of worker-* files but don't include them all on load.
145-
{ pattern: `${testDir}/worker-*.js`, type: 'module', included: false },
146-
// `zone.js/testing`, served but not included on page load.
147-
{ pattern: `${testDir}/testing.js`, type: 'module', included: false },
144+
{ pattern: `${testDir}/{chunk,worker}-*.js`, type: 'module', included: false });
145+
karmaOptions.files.push(
148146
// Serve remaining JS on page load, these are the test entrypoints.
149147
{ pattern: `${testDir}/*.js`, type: 'module' });
150148
if (options.styles?.length) {
@@ -199,15 +197,6 @@ async function writeTestFiles(files, testDir) {
199197
}
200198
});
201199
}
202-
function extractZoneTesting(polyfills) {
203-
if (typeof polyfills === 'string') {
204-
polyfills = [polyfills];
205-
}
206-
polyfills ??= [];
207-
const polyfillsWithoutZoneTesting = polyfills.filter((polyfill) => polyfill !== 'zone.js/testing');
208-
const hasZoneTesting = polyfills.length !== polyfillsWithoutZoneTesting.length;
209-
return [polyfillsWithoutZoneTesting, hasZoneTesting];
210-
}
211200
/** Returns the first item yielded by the given generator and cancels the execution. */
212201
async function first(generator) {
213202
for await (const value of generator) {

src/utils/normalize-cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.normalizeCacheOptions = normalizeCacheOptions;
1111
const node_path_1 = require("node:path");
1212
/** Version placeholder is replaced during the build process with actual package version */
13-
const VERSION = '19.0.0-next.8+sha-87a90af';
13+
const VERSION = '19.0.0-next.8+sha-9d7613d';
1414
function hasCacheMetadata(value) {
1515
return (!!value &&
1616
typeof value === 'object' &&

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fri Sep 27 2024 19:50:03 GMT+0000 (Coordinated Universal Time)
1+
Fri Sep 27 2024 22:33:42 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)