Skip to content

Commit efef054

Browse files
author
Angular Builds
committed
2c9904e fix(@angular-devkit/build-angular): handle basename collisions
1 parent e0faa1c commit efef054

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
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-8f6ee1a",
3+
"version": "19.1.0-next.0+sha-2c9904e",
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#8f6ee1a",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#8f6ee1a",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#8f6ee1a",
13-
"@angular/build": "github:angular/angular-build-builds#8f6ee1a",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#2c9904e",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#2c9904e",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#2c9904e",
13+
"@angular/build": "github:angular/angular-build-builds#2c9904e",
1414
"@babel/core": "7.26.0",
1515
"@babel/generator": "7.26.2",
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#8f6ee1a",
24+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#2c9904e",
2525
"@vitejs/plugin-basic-ssl": "1.1.0",
2626
"ansi-colors": "4.1.3",
2727
"autoprefixer": "10.4.20",
@@ -70,7 +70,7 @@
7070
"@angular/localize": "^19.0.0-next.0",
7171
"@angular/platform-server": "^19.0.0-next.0",
7272
"@angular/service-worker": "^19.0.0-next.0",
73-
"@angular/ssr": "github:angular/angular-ssr-builds#8f6ee1a",
73+
"@angular/ssr": "github:angular/angular-ssr-builds#2c9904e",
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#8f6ee1a",
94+
"@angular/ssr": "github:angular/angular-ssr-builds#2c9904e",
9595
"@web/test-runner": {
9696
"optional": true
9797
},

src/builders/karma/application_builder.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,21 @@ function normalizePolyfills(polyfills) {
196196
async function collectEntrypoints(options, context, projectSourceRoot) {
197197
// Glob for files to test.
198198
const testFiles = await (0, find_tests_1.findTests)(options.include ?? [], options.exclude ?? [], context.workspaceRoot, projectSourceRoot);
199-
return new Set(testFiles);
199+
const seen = new Set();
200+
return new Map(Array.from(testFiles, (testFile) => {
201+
const relativePath = path
202+
.relative(testFile.startsWith(projectSourceRoot) ? projectSourceRoot : context.workspaceRoot, testFile)
203+
.replace(/^[./]+/, '_')
204+
.replace(/\//g, '-');
205+
let uniqueName = `spec-${path.basename(relativePath, path.extname(relativePath))}`;
206+
let suffix = 2;
207+
while (seen.has(uniqueName)) {
208+
uniqueName = `${relativePath}-${suffix}`;
209+
++suffix;
210+
}
211+
seen.add(uniqueName);
212+
return [uniqueName, testFile];
213+
}));
200214
}
201215
async function initializeApplication(options, context, karmaOptions, transforms = {}) {
202216
if (transforms.webpackConfiguration) {
@@ -209,13 +223,12 @@ async function initializeApplication(options, context, karmaOptions, transforms
209223
collectEntrypoints(options, context, projectSourceRoot),
210224
fs.rm(outputPath, { recursive: true, force: true }),
211225
]);
212-
let mainName = 'init_test_bed';
226+
const mainName = 'test_main';
213227
if (options.main) {
214-
entryPoints.add(options.main);
215-
mainName = path.basename(options.main, path.extname(options.main));
228+
entryPoints.set(mainName, options.main);
216229
}
217230
else {
218-
entryPoints.add('@angular-devkit/build-angular/src/builders/karma/init_test_bed.js');
231+
entryPoints.set(mainName, '@angular-devkit/build-angular/src/builders/karma/init_test_bed.js');
219232
}
220233
const instrumentForCoverage = options.codeCoverage
221234
? createInstrumentationFilter(projectSourceRoot, getInstrumentationExcludedPaths(context.workspaceRoot, options.codeCoverageExclude ?? []))
@@ -257,7 +270,9 @@ async function initializeApplication(options, context, karmaOptions, transforms
257270
// Serve global setup script.
258271
{ pattern: `${outputPath}/${mainName}.js`, type: 'module', watched: false },
259272
// Serve all source maps.
260-
{ pattern: `${outputPath}/*.map`, included: false, watched: false });
273+
{ pattern: `${outputPath}/*.map`, included: false, watched: false },
274+
// These are the test entrypoints.
275+
{ pattern: `${outputPath}/spec-*.js`, type: 'module', watched: false });
261276
if (hasChunkOrWorkerFiles(buildOutput.files)) {
262277
karmaOptions.files.push(
263278
// Allow loading of chunk-* files but don't include them all on load.
@@ -268,9 +283,6 @@ async function initializeApplication(options, context, karmaOptions, transforms
268283
watched: false,
269284
});
270285
}
271-
karmaOptions.files.push(
272-
// Serve remaining JS on page load, these are the test entrypoints.
273-
{ pattern: `${outputPath}/*.js`, type: 'module', watched: false });
274286
if (options.styles?.length) {
275287
// Serve CSS outputs on page load, these are the global styles.
276288
karmaOptions.files.push({ pattern: `${outputPath}/*.css`, type: 'css', watched: false });

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-8f6ee1a';
13+
const VERSION = '19.1.0-next.0+sha-2c9904e';
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-
Wed Nov 06 2024 12:44:09 GMT+0000 (Coordinated Universal Time)
1+
Wed Nov 06 2024 15:24:13 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)