Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import type { CompilerOptions } from '@angular/compiler-cli';
import type { PartialMessage } from 'esbuild';
import { createRequire } from 'node:module';
import { createRequire, getCompileCacheDir } from 'node:module';
import { MessageChannel } from 'node:worker_threads';
import Piscina from 'piscina';
import type { SourceFile } from 'typescript';
Expand Down Expand Up @@ -41,6 +41,11 @@ export class ParallelCompilation extends AngularCompilation {
useAtomics: !process.versions.webcontainer,
filename: localRequire.resolve('./parallel-worker'),
recordTiming: false,
env: {
...process.env,
// Enable compile code caching if enabled for the main process (only exists on Node.js v22.8+)
'NODE_COMPILE_CACHE': getCompileCacheDir?.(),
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { createHash } from 'node:crypto';
import { readFile } from 'node:fs/promises';
import { getCompileCacheDir } from 'node:module';
import Piscina from 'piscina';
import { Cache } from './cache';

Expand Down Expand Up @@ -62,6 +63,11 @@ export class JavaScriptTransformer {
// Shutdown idle threads after 1 second of inactivity
idleTimeout: 1000,
recordTiming: false,
env: {
...process.env,
// Enable compile code caching if enabled for the main process (only exists on Node.js v22.8+)
'NODE_COMPILE_CACHE': getCompileCacheDir?.(),
},
});

return this.#workerPool;
Expand Down
6 changes: 6 additions & 0 deletions packages/angular/build/src/tools/sass/sass-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import assert from 'node:assert';
import { getCompileCacheDir } from 'node:module';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { MessageChannel } from 'node:worker_threads';
import { Piscina } from 'piscina';
Expand Down Expand Up @@ -101,6 +102,11 @@ export class SassWorkerImplementation {
// Shutdown idle threads after 1 second of inactivity
idleTimeout: 1000,
recordTiming: false,
env: {
...process.env,
// Enable compile code caching if enabled for the main process (only exists on Node.js v22.8+)
'NODE_COMPILE_CACHE': getCompileCacheDir?.(),
},
});

return this.#workerPool;
Expand Down
7 changes: 7 additions & 0 deletions packages/angular/build/src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@
declare module 'esbuild' {
export * from 'esbuild-wasm';
}

/**
* Augment the Node.js module builtin types to support the v22.8+ compile cache functions
*/
declare module 'node:module' {
function getCompileCacheDir(): string | undefined;
}
10 changes: 9 additions & 1 deletion packages/angular/cli/bin/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@
* range.
*/

import('../lib/init.js');
// Enable on-disk code caching if available (Node.js 22.8+)
try {
const { enableCompileCache } = require('node:module');

enableCompileCache?.();
} catch {}

// Initialize the Angular CLI
void import('../lib/init.js');