mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 11:44:05 +08:00
fix(@angular-devkit/build-angular): use preserveSymlinks option for tsconfigs in esbuild builder
When using the esbuild-based browser application builder, the tsconfig path will now be properly converted to the realpath when the `preserveSymlinks` option is disabled (the default). This ensures that TypeScript source files will be properly matched with the bundler's resolved paths when symlinks are used and the `preserveSymlinks` option is not enabled. This is needed to properly support the use of bazel with rules_js.
This commit is contained in:
parent
5645fc85ec
commit
480eb3eeff
@ -16,6 +16,7 @@ import type {
|
|||||||
PluginBuild,
|
PluginBuild,
|
||||||
} from 'esbuild';
|
} from 'esbuild';
|
||||||
import * as assert from 'node:assert';
|
import * as assert from 'node:assert';
|
||||||
|
import { realpath } from 'node:fs/promises';
|
||||||
import { platform } from 'node:os';
|
import { platform } from 'node:os';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import { pathToFileURL } from 'node:url';
|
import { pathToFileURL } from 'node:url';
|
||||||
@ -167,6 +168,16 @@ export function createCompilerPlugin(
|
|||||||
async setup(build: PluginBuild): Promise<void> {
|
async setup(build: PluginBuild): Promise<void> {
|
||||||
let setupWarnings: PartialMessage[] | undefined = [];
|
let setupWarnings: PartialMessage[] | undefined = [];
|
||||||
|
|
||||||
|
const preserveSymlinks = build.initialOptions.preserveSymlinks;
|
||||||
|
let tsconfigPath = pluginOptions.tsconfig;
|
||||||
|
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.
|
||||||
|
try {
|
||||||
|
tsconfigPath = await realpath(tsconfigPath);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize a worker pool for JavaScript transformations
|
// Initialize a worker pool for JavaScript transformations
|
||||||
const javascriptTransformer = new JavaScriptTransformer(pluginOptions, maxWorkers);
|
const javascriptTransformer = new JavaScriptTransformer(pluginOptions, maxWorkers);
|
||||||
|
|
||||||
@ -251,7 +262,7 @@ export function createCompilerPlugin(
|
|||||||
const {
|
const {
|
||||||
affectedFiles,
|
affectedFiles,
|
||||||
compilerOptions: { allowJs },
|
compilerOptions: { allowJs },
|
||||||
} = await compilation.initialize(pluginOptions.tsconfig, hostOptions, (compilerOptions) => {
|
} = await compilation.initialize(tsconfigPath, hostOptions, (compilerOptions) => {
|
||||||
if (
|
if (
|
||||||
compilerOptions.target === undefined ||
|
compilerOptions.target === undefined ||
|
||||||
compilerOptions.target < ts.ScriptTarget.ES2022
|
compilerOptions.target < ts.ScriptTarget.ES2022
|
||||||
@ -285,6 +296,7 @@ export function createCompilerPlugin(
|
|||||||
inlineSourceMap: pluginOptions.sourcemap,
|
inlineSourceMap: pluginOptions.sourcemap,
|
||||||
mapRoot: undefined,
|
mapRoot: undefined,
|
||||||
sourceRoot: undefined,
|
sourceRoot: undefined,
|
||||||
|
preserveSymlinks,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
shouldTsIgnoreJs = !allowJs;
|
shouldTsIgnoreJs = !allowJs;
|
||||||
|
@ -395,6 +395,7 @@ function createCodeBundleOptions(
|
|||||||
externalDependencies,
|
externalDependencies,
|
||||||
target,
|
target,
|
||||||
inlineStyleLanguage,
|
inlineStyleLanguage,
|
||||||
|
preserveSymlinks,
|
||||||
browsers,
|
browsers,
|
||||||
tailwindConfiguration,
|
tailwindConfiguration,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user