|
8 | 8 |
|
9 | 9 | import { BuilderContext } from '@angular-devkit/architect'; |
10 | 10 | import type { Plugin } from 'esbuild'; |
| 11 | +import { realpathSync } from 'node:fs'; |
11 | 12 | import { access, constants } from 'node:fs/promises'; |
12 | 13 | import { createRequire } from 'node:module'; |
13 | 14 | import path from 'node:path'; |
@@ -83,7 +84,17 @@ export async function normalizeOptions( |
83 | 84 | options: ApplicationBuilderInternalOptions, |
84 | 85 | plugins?: Plugin[], |
85 | 86 | ) { |
86 | | - const workspaceRoot = context.workspaceRoot; |
| 87 | + // If not explicitly set, default to the Node.js process argument |
| 88 | + const preserveSymlinks = |
| 89 | + options.preserveSymlinks ?? process.execArgv.includes('--preserve-symlinks'); |
| 90 | + |
| 91 | + // Setup base paths based on workspace root and project information |
| 92 | + const workspaceRoot = preserveSymlinks |
| 93 | + ? context.workspaceRoot |
| 94 | + : // NOTE: promises.realpath should not be used here since it uses realpath.native which |
| 95 | + // can cause case conversion and other undesirable behavior on Windows systems. |
| 96 | + // ref: https://github.com/nodejs/node/issues/7726 |
| 97 | + realpathSync(context.workspaceRoot); |
87 | 98 | const projectMetadata = await context.getProjectMetadata(projectName); |
88 | 99 | const projectRoot = normalizeDirectoryPath( |
89 | 100 | path.join(workspaceRoot, (projectMetadata.root as string | undefined) ?? ''), |
@@ -244,7 +255,6 @@ export async function normalizeOptions( |
244 | 255 | serviceWorker, |
245 | 256 | poll, |
246 | 257 | polyfills, |
247 | | - preserveSymlinks, |
248 | 258 | statsJson, |
249 | 259 | stylePreprocessorOptions, |
250 | 260 | subresourceIntegrity, |
@@ -275,8 +285,7 @@ export async function normalizeOptions( |
275 | 285 | poll, |
276 | 286 | progress, |
277 | 287 | externalPackages, |
278 | | - // If not explicitly set, default to the Node.js process argument |
279 | | - preserveSymlinks: preserveSymlinks ?? process.execArgv.includes('--preserve-symlinks'), |
| 288 | + preserveSymlinks, |
280 | 289 | stylePreprocessorOptions, |
281 | 290 | subresourceIntegrity, |
282 | 291 | serverEntryPoint, |
|
0 commit comments