From 83b75af9f74af0742a6a78cf7531866b7ba434b6 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:33:41 -0400 Subject: [PATCH] fix(@angular/build): check inlineSourceMap option with isolated modules optimization The isolated modules transpilation option that was recently introduced is currently disabled when source maps are enabled. TypeScript has two mutually exclusive options that can be used to check for source map usage. Both of these options (`sourceMap` and `inlineSourceMap`) are now checked to determine if the direct transpilation optimization can be used. (cherry picked from commit aa88e682649d147eecf075780f7fbd6168a54854) --- .../build/src/tools/angular/compilation/aot-compilation.ts | 4 +++- .../build/src/tools/angular/compilation/parallel-worker.ts | 3 ++- .../build/src/tools/esbuild/angular/compiler-plugin.ts | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts b/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts index 10d1d477ef3f..59de92fb76b1 100644 --- a/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts +++ b/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts @@ -204,7 +204,9 @@ export class AotCompilation extends AngularCompilation { const compilerOptions = typeScriptProgram.getCompilerOptions(); const buildInfoFilename = compilerOptions.tsBuildInfoFile ?? '.tsbuildinfo'; const useTypeScriptTranspilation = - !compilerOptions.isolatedModules || !!compilerOptions.sourceMap; + !compilerOptions.isolatedModules || + !!compilerOptions.sourceMap || + !!compilerOptions.inlineSourceMap; const emittedFiles = new Map(); const writeFileCallback: ts.WriteFileCallback = (filename, contents, _a, _b, sourceFiles) => { diff --git a/packages/angular/build/src/tools/angular/compilation/parallel-worker.ts b/packages/angular/build/src/tools/angular/compilation/parallel-worker.ts index db6771cae005..21cdea54c940 100644 --- a/packages/angular/build/src/tools/angular/compilation/parallel-worker.ts +++ b/packages/angular/build/src/tools/angular/compilation/parallel-worker.ts @@ -94,11 +94,12 @@ export async function initialize(request: InitRequest) { return { referencedFiles, - // TODO: Expand? `allowJs`, `isolatedModules`, `sourceMap` are the only fields needed currently. + // TODO: Expand? `allowJs`, `isolatedModules`, `sourceMap`, `inlineSourceMap` are the only fields needed currently. compilerOptions: { allowJs: compilerOptions.allowJs, isolatedModules: compilerOptions.isolatedModules, sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, }, }; } diff --git a/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts b/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts index 24d3d7f0bd52..ec76cc2c7a8e 100644 --- a/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts +++ b/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts @@ -275,7 +275,8 @@ export function createCompilerPlugin( // Typescript printing support for sourcemaps is not yet integrated. useTypeScriptTranspilation = !initializationResult.compilerOptions.isolatedModules || - !!initializationResult.compilerOptions.sourceMap; + !!initializationResult.compilerOptions.sourceMap || + !!initializationResult.compilerOptions.inlineSourceMap; referencedFiles = initializationResult.referencedFiles; } catch (error) { (result.errors ??= []).push({ @@ -562,6 +563,7 @@ function createCompilerOptionsTransformer( noEmitOnError: false, inlineSources: !!pluginOptions.sourcemap, inlineSourceMap: !!pluginOptions.sourcemap, + sourceMap: undefined, mapRoot: undefined, sourceRoot: undefined, preserveSymlinks,