Skip to content

Commit a9b92e4

Browse files
committed
feat(@angular/build): preserve names in esbuild for improved debugging in dev mode
This commit introduces the `keepNames` option in esbuild configurations for both application code bundling and Vite utility functions. By setting `keepNames` to `true` (or conditionally based on optimization settings), function and variable names are preserved during the build process. This significantly improves the debugging experience in **development mode** by ensuring that original names are retained in compiled output, leading to more readable stack traces and easier identification of code sections during development.
1 parent 26127bd commit a9b92e4

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

packages/angular/build/src/tools/esbuild/application-code-bundle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ function getEsBuildCommonOptions(options: NormalizedApplicationBuildOptions): Bu
618618
metafile: true,
619619
legalComments: options.extractLicenses ? 'none' : 'eof',
620620
logLevel: options.verbose && !jsonLogs ? 'debug' : 'silent',
621+
keepNames: !(optimizationOptions.scripts && allowMangle),
621622
minifyIdentifiers: optimizationOptions.scripts && allowMangle,
622623
minifySyntax: optimizationOptions.scripts,
623624
minifyWhitespace: optimizationOptions.scripts,

packages/angular/build/src/tools/vite/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function getDepOptimizationConfig({
9898
esbuildOptions: {
9999
// Set esbuild supported targets.
100100
target,
101+
keepNames: true,
101102
supported: getFeatureSupport(target, zoneless),
102103
plugins,
103104
loader,

0 commit comments

Comments
 (0)