Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): avoid native realpath in applicat…
Browse files Browse the repository at this point in the history
…ion 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.

(cherry picked from commit 0363da2)
  • Loading branch information
clydin authored and alan-agius4 committed Nov 23, 2023
1 parent 0f9f2fa commit 0634a4e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
PluginBuild,
} from 'esbuild';
import assert from 'node:assert';
import { realpath } from 'node:fs/promises';
import { realpathSync } from 'node:fs';
import * as path from 'node:path';
import { maxWorkers } from '../../../utils/environment-options';
import { JavaScriptTransformer } from '../javascript-transformer';
Expand Down Expand Up @@ -61,8 +61,11 @@ export function createCompilerPlugin(
if (!preserveSymlinks) {
// Use the real path of the tsconfig if not preserving symlinks.
// This ensures the TS source file paths are based on the real path of the configuration.
// NOTE: promises.realpath should not be used here since it uses realpath.native which
// can cause case conversion and other undesirable behavior on Windows systems.
// ref: https://github.com/nodejs/node/issues/7726
try {
tsconfigPath = await realpath(tsconfigPath);
tsconfigPath = realpathSync(tsconfigPath);
} catch {}
}

Expand Down

0 comments on commit 0634a4e

Please sign in to comment.