Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
"@types/picomatch": "^4.0.0",
"@types/progress": "^2.0.3",
"@types/semver": "^7.3.12",
"@types/watchpack": "^2.4.4",
"@types/yargs": "^17.0.20",
"@types/yargs-parser": "^21.0.0",
"@typescript-eslint/eslint-plugin": "8.65.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ ts_project(
":node_modules/@babel/helper-split-export-declaration",
":node_modules/@inquirer/confirm",
":node_modules/@oxc-project/types",
":node_modules/@parcel/watcher",
":node_modules/@vitejs/plugin-basic-ssl",
":node_modules/beasties",
":node_modules/browserslist",
":node_modules/chokidar",
":node_modules/https-proxy-agent",
":node_modules/istanbul-lib-instrument",
":node_modules/jsonc-parser",
Expand All @@ -110,7 +112,6 @@ ts_project(
":node_modules/tinyglobby",
":node_modules/vite",
":node_modules/vitest",
":node_modules/watchpack",
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
"//:node_modules/@angular/compiler-cli",
Expand All @@ -125,7 +126,6 @@ ts_project(
"//:node_modules/@types/node",
"//:node_modules/@types/picomatch",
"//:node_modules/@types/semver",
"//:node_modules/@types/watchpack",
"//:node_modules/esbuild",
"//:node_modules/esbuild-wasm",
"//:node_modules/karma",
Expand Down
3 changes: 2 additions & 1 deletion packages/angular/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"source-map-support": "0.5.21",
"tinyglobby": "0.2.17",
"vite": "8.1.5",
"watchpack": "2.5.2"
"@parcel/watcher": "2.5.1",
"chokidar": "4.0.3"
},
"optionalDependencies": {
"lmdb": "3.5.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ export async function* runEsBuildBuildAction(

// Setup a watcher
const { createWatcher } = await import('../../tools/esbuild/watcher');
watcher = createWatcher({
watcher = await createWatcher({
polling: typeof poll === 'number',
interval: poll,
followSymlinks: preserveSymlinks,
ignored,
cwd: workspaceRoot,
});

// Setup abort support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export async function executeBuild(
bundlingResult = BundlerContext.mergeResults([bundlingResult, ...typescriptResults]);
} else {
const target = transformSupportedBrowsersToTargets(browsers);
codeBundleCache = new SourceFileCache(cacheOptions.enabled ? cacheOptions.path : undefined);
codeBundleCache = new SourceFileCache(
cacheOptions.enabled ? cacheOptions.path : undefined,
options.workspaceRoot,
);
componentStyleBundler = createComponentStyleBundler(options, target);
if (options.templateUpdates) {
templateUpdates = new Map<string, string>();
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/src/builders/application/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export async function normalizeOptions(
options.preserveSymlinks ?? process.execArgv.includes('--preserve-symlinks');

// Setup base paths based on workspace root and project information
const workspaceRoot = canonicalizePath(context.workspaceRoot, preserveSymlinks);
const workspaceRoot = canonicalizePath(context.workspaceRoot);
const projectMetadata = await context.getProjectMetadata(projectName);
const { projectRoot, projectSourceRoot } = getProjectRootPaths(workspaceRoot, projectMetadata);

Expand Down
10 changes: 8 additions & 2 deletions packages/angular/build/src/builders/karma/application_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,14 @@ export function execute(

// Close the stream once the Karma server returns.
karmaServer = new karma.Server(karmaConfig as Config, (exitCode) => {
controller.enqueue({ success: exitCode === 0 });
controller.close();
if (controller.desiredSize !== null) {
try {
controller.enqueue({ success: exitCode === 0 });
controller.close();
} catch {
// Stream controller may already be closed or cancelled
}
}
});

await karmaServer.start();
Expand Down
10 changes: 6 additions & 4 deletions packages/angular/build/src/builders/karma/progress-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ export function injectKarmaReporter(
}

onRunComplete = function (_browsers: unknown, results: RunCompleteInfo): void {
if (results.exitCode === 0) {
controller.enqueue({ success: true });
} else {
controller.enqueue({ success: false });
if (controller.desiredSize !== null) {
try {
controller.enqueue({ success: results.exitCode === 0 });
} catch {
// Stream controller may already be closed or cancelled
}
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/src/builders/unit-test/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function normalizeOptions(
: process.execArgv.includes('--preserve-symlinks');

// Setup base paths based on workspace root and project information
const workspaceRoot = canonicalizePath(context.workspaceRoot, preserveSymlinks);
const workspaceRoot = canonicalizePath(context.workspaceRoot);

const projectMetadata = await context.getProjectMetadata(projectName);
const { projectRoot, projectSourceRoot } = getProjectRootPaths(workspaceRoot, projectMetadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { realpathSync } from 'node:fs';
import { platform } from 'node:os';
import * as path from 'node:path';
import type ts from 'typescript';
Expand All @@ -18,11 +19,25 @@ export class SourceFileCache extends Map<string, ts.SourceFile> {
readonly modifiedFiles = new Set<string>();
readonly typeScriptFileCache = new Map<string, string | Uint8Array>();
readonly loadResultCache = new MemoryLoadResultCache();
private readonly rootDir?: string;
private readonly realRootDir?: string;

referencedFiles?: readonly string[];

constructor(readonly persistentCachePath?: string) {
constructor(
readonly persistentCachePath?: string,
workspaceRoot?: string,
) {
super();
const root = workspaceRoot ?? process.cwd();
try {
const normRoot = path.normalize(root);
const real = path.normalize(realpathSync(normRoot));
if (real !== normRoot) {
this.rootDir = normRoot;
this.realRootDir = real;
}
} catch {}
}

invalidate(files: Iterable<string>): boolean {
Expand All @@ -45,6 +60,16 @@ export class SourceFileCache extends Map<string, ts.SourceFile> {

invalid = this.delete(file) || invalid;
this.modifiedFiles.add(file);

// Invalidate the realpath variant if TypeScript stored the SourceFile under its realpath
// (e.g. dynamically imported modules where TS module resolution resolved symlinked root directories).
if (this.rootDir && this.realRootDir) {
if (file.startsWith(this.rootDir)) {
const realFile = this.realRootDir + file.slice(this.rootDir.length);
invalid = this.delete(realFile) || invalid;
this.modifiedFiles.add(realFile);
}
}
}

return invalid;
Expand Down
Loading
Loading