Skip to content

Commit 3623fe9

Browse files
committed
fix(@angular-devkit/build-angular): update ESM loader to work with Node.js 18.19.0
In Node.js 18.19 ESM loaders works the same way as Node.js 20.9+ Closes #26648 (cherry picked from commit 7a50df5)
1 parent ef11781 commit 3623fe9

File tree

1 file changed

+6
-5
lines changed
  • packages/angular_devkit/build_angular/src/utils/server-rendering/esm-in-memory-loader

1 file changed

+6
-5
lines changed

packages/angular_devkit/build_angular/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99
import { join } from 'node:path';
1010
import { pathToFileURL } from 'node:url';
1111
import { workerData } from 'node:worker_threads';
12+
import { satisfies } from 'semver';
1213

13-
let IS_NODE_18: boolean | undefined;
14-
function isNode18(): boolean {
15-
return (IS_NODE_18 ??= process.versions.node.startsWith('18.'));
14+
let SUPPORTS_IMPORT_FLAG: boolean | undefined;
15+
function supportsImportFlag(): boolean {
16+
return (SUPPORTS_IMPORT_FLAG ??= satisfies(process.versions.node, '>= 18.19'));
1617
}
1718

1819
/** Call the initialize hook when running on Node.js 18 */
1920
export function callInitializeIfNeeded(
2021
initialize: (typeof import('./loader-hooks'))['initialize'],
2122
): void {
22-
if (isNode18()) {
23+
if (!supportsImportFlag()) {
2324
initialize(workerData);
2425
}
2526
}
2627

2728
export function getESMLoaderArgs(): string[] {
28-
if (isNode18()) {
29+
if (!supportsImportFlag()) {
2930
return [
3031
'--no-warnings', // Suppress `ExperimentalWarning: Custom ESM Loaders is an experimental feature...`.
3132
'--loader',

0 commit comments

Comments
 (0)