Skip to content

Commit 0363da2

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): avoid native realpath in application builder
When the `preserveSymlinks` option is false (the default), the tsconfig path was passed through realpath to ensure that the TypeScript source files were resolved correctly. However, the promise version of the Node.js API was previously used. This version used `realpath.native` internally but the native version has numerous behavior problems on Windows systems. This includes potential case conversion which can result in differing cases for files within the build system and in turn failed path comparison checks. The synchronous version is now used which has a JavaScript implementation that does not suffer from these problems.
1 parent dde1372 commit 0363da2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/angular/compiler-plugin.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
PluginBuild,
1717
} from 'esbuild';
1818
import assert from 'node:assert';
19-
import { realpath } from 'node:fs/promises';
19+
import { realpathSync } from 'node:fs';
2020
import * as path from 'node:path';
2121
import { maxWorkers } from '../../../utils/environment-options';
2222
import { JavaScriptTransformer } from '../javascript-transformer';
@@ -61,8 +61,11 @@ export function createCompilerPlugin(
6161
if (!preserveSymlinks) {
6262
// Use the real path of the tsconfig if not preserving symlinks.
6363
// This ensures the TS source file paths are based on the real path of the configuration.
64+
// NOTE: promises.realpath should not be used here since it uses realpath.native which
65+
// can cause case conversion and other undesirable behavior on Windows systems.
66+
// ref: https://github.com/nodejs/node/issues/7726
6467
try {
65-
tsconfigPath = await realpath(tsconfigPath);
68+
tsconfigPath = realpathSync(tsconfigPath);
6669
} catch {}
6770
}
6871

0 commit comments

Comments
 (0)