Skip to content

Commit cbc4f36

Browse files
author
Angular Builds
committed
9e2d3fb fix(@angular-devkit/build-angular): handle windows spec collisions
1 parent 2419f4e commit cbc4f36

File tree

6 files changed

+47
-25
lines changed

6 files changed

+47
-25
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.1.0-next.0+sha-1ca260e",
3+
"version": "19.1.0-next.0+sha-9e2d3fb",
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#1ca260e",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#1ca260e",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#1ca260e",
13-
"@angular/build": "github:angular/angular-build-builds#1ca260e",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#9e2d3fb",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#9e2d3fb",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#9e2d3fb",
13+
"@angular/build": "github:angular/angular-build-builds#9e2d3fb",
1414
"@babel/core": "7.26.0",
1515
"@babel/generator": "7.26.3",
1616
"@babel/helper-annotate-as-pure": "7.25.9",
@@ -21,7 +21,7 @@
2121
"@babel/preset-env": "7.26.0",
2222
"@babel/runtime": "7.26.0",
2323
"@discoveryjs/json-ext": "0.6.3",
24-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#1ca260e",
24+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#9e2d3fb",
2525
"@vitejs/plugin-basic-ssl": "1.2.0",
2626
"ansi-colors": "4.1.3",
2727
"autoprefixer": "10.4.20",
@@ -70,7 +70,7 @@
7070
"@angular/localize": "^19.0.0 || ^19.1.0-next.0",
7171
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
7272
"@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
73-
"@angular/ssr": "github:angular/angular-ssr-builds#1ca260e",
73+
"@angular/ssr": "github:angular/angular-ssr-builds#9e2d3fb",
7474
"@web/test-runner": "^0.19.0",
7575
"browser-sync": "^3.0.2",
7676
"jest": "^29.5.0",
@@ -91,7 +91,7 @@
9191
"@angular/service-worker": {
9292
"optional": true
9393
},
94-
"@angular/ssr": "github:angular/angular-ssr-builds#1ca260e",
94+
"@angular/ssr": "github:angular/angular-ssr-builds#9e2d3fb",
9595
"@web/test-runner": {
9696
"optional": true
9797
},

src/builders/karma/application_builder.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,7 @@ function normalizePolyfills(polyfills) {
206206
async function collectEntrypoints(options, context, projectSourceRoot) {
207207
// Glob for files to test.
208208
const testFiles = await (0, find_tests_1.findTests)(options.include ?? [], options.exclude ?? [], context.workspaceRoot, projectSourceRoot);
209-
const seen = new Set();
210-
return new Map(Array.from(testFiles, (testFile) => {
211-
const relativePath = path
212-
.relative(testFile.startsWith(projectSourceRoot) ? projectSourceRoot : context.workspaceRoot, testFile)
213-
.replace(/^[./]+/, '_')
214-
.replace(/\//g, '-');
215-
let uniqueName = `spec-${path.basename(relativePath, path.extname(relativePath))}`;
216-
let suffix = 2;
217-
while (seen.has(uniqueName)) {
218-
uniqueName = `${relativePath}-${suffix}`;
219-
++suffix;
220-
}
221-
seen.add(uniqueName);
222-
return [uniqueName, testFile];
223-
}));
209+
return (0, find_tests_1.getTestEntrypoints)(testFiles, { projectSourceRoot, workspaceRoot: context.workspaceRoot });
224210
}
225211
async function initializeApplication(options, context, karmaOptions, transforms = {}) {
226212
if (transforms.webpackConfiguration) {

src/builders/karma/find-tests.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88
export declare function findTests(include: string[], exclude: string[], workspaceRoot: string, projectSourceRoot: string): Promise<string[]>;
9+
interface TestEntrypointsOptions {
10+
projectSourceRoot: string;
11+
workspaceRoot: string;
12+
}
13+
/** Generate unique bundle names for a set of test files. */
14+
export declare function getTestEntrypoints(testFiles: string[], { projectSourceRoot, workspaceRoot }: TestEntrypointsOptions): Map<string, string>;
15+
export {};

src/builders/karma/find-tests.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var __importStar = (this && this.__importStar) || (function () {
4141
})();
4242
Object.defineProperty(exports, "__esModule", { value: true });
4343
exports.findTests = findTests;
44+
exports.getTestEntrypoints = getTestEntrypoints;
4445
const fast_glob_1 = __importStar(require("fast-glob"));
4546
const fs_1 = require("fs");
4647
const path_1 = require("path");
@@ -51,6 +52,26 @@ async function findTests(include, exclude, workspaceRoot, projectSourceRoot) {
5152
// Unique file names
5253
return [...new Set(files.flat())];
5354
}
55+
/** Generate unique bundle names for a set of test files. */
56+
function getTestEntrypoints(testFiles, { projectSourceRoot, workspaceRoot }) {
57+
const seen = new Set();
58+
return new Map(Array.from(testFiles, (testFile) => {
59+
const relativePath = removeRoots(testFile, [projectSourceRoot, workspaceRoot])
60+
// Strip leading dots and path separators.
61+
.replace(/^[./\\]+/, '')
62+
// Replace any path separators with dashes.
63+
.replace(/[/\\]/g, '-');
64+
const baseName = `spec-${(0, path_1.basename)(relativePath, (0, path_1.extname)(relativePath))}`;
65+
let uniqueName = baseName;
66+
let suffix = 2;
67+
while (seen.has(uniqueName)) {
68+
uniqueName = `${baseName}-${suffix}`.replace(/([^\w](?:spec|test))-([\d]+)$/, '-$2$1');
69+
++suffix;
70+
}
71+
seen.add(uniqueName);
72+
return [uniqueName, testFile];
73+
}));
74+
}
5475
const normalizePath = (path) => path.replace(/\\/g, '/');
5576
const removeLeadingSlash = (pattern) => {
5677
if (pattern.charAt(0) === '/') {
@@ -64,6 +85,14 @@ const removeRelativeRoot = (path, root) => {
6485
}
6586
return path;
6687
};
88+
function removeRoots(path, roots) {
89+
for (const root of roots) {
90+
if (path.startsWith(root)) {
91+
return path.substring(root.length);
92+
}
93+
}
94+
return (0, path_1.basename)(path);
95+
}
6796
async function findMatchingTests(pattern, ignore, workspaceRoot, projectSourceRoot) {
6897
// normalize pattern, glob lib only accepts forward slashes
6998
let normalizedPattern = normalizePath(pattern);

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.1.0-next.0+sha-1ca260e';
13+
const VERSION = '19.1.0-next.0+sha-9e2d3fb';
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-
Thu Dec 05 2024 15:26:56 GMT+0000 (Coordinated Universal Time)
1+
Thu Dec 05 2024 15:35:49 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)