Skip to content

Commit

Permalink
Revert "perf(@angular/cli): enable Node.js compile code cache when av…
Browse files Browse the repository at this point in the history
…ailable"

This reverts commit ecc107d.
  • Loading branch information
alan-agius4 committed Sep 13, 2024
1 parent ac71ce1 commit de17cbc
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 34 deletions.
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, getCompileCacheDir } from 'node:module';
import { createRequire } from 'node:module';
import { MessageChannel } from 'node:worker_threads';
import Piscina from 'piscina';
import type { SourceFile } from 'typescript';
Expand Down Expand Up @@ -41,11 +41,6 @@ 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,7 +8,6 @@

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 @@ -63,11 +62,6 @@ 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: 0 additions & 6 deletions packages/angular/build/src/tools/sass/sass-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

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 @@ -103,11 +102,6 @@ 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: 0 additions & 7 deletions packages/angular/build/src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,3 @@
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: 1 addition & 9 deletions packages/angular/cli/bin/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,4 @@
* range.
*/

// 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');
import('../lib/init.js');

3 comments on commit de17cbc

@robertIsaac
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's reverted?

@alan-agius4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's reverted?

See: #28410

@robertIsaac
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.