Skip to content

Commit 1a3ef3b

Browse files
committed
fix(@angular/build): disable TypeScript removeComments option
Disables TypeScript's `removeComments` option to ensure important annotations like `/* @__PURE__ */` and `/* vite-ignore */` are preserved. TypeScript's comment removal can be too aggressive, potentially stripping out critical information needed by bundlers for dead code elimination. Non-essential comments will be handled by the bundler, so removing them in TypeScript isn't necessary and could lead to an increase in the final bundle size. Closes #29470
1 parent 1e088f5 commit 1a3ef3b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Diff for: packages/angular/build/src/tools/angular/compilation/angular-compilation.ts

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export abstract class AngularCompilation {
6363
enableResourceInlining: false,
6464
supportTestBed: false,
6565
supportJitMode: false,
66+
// Disable removing of comments as TS is quite aggressive with these and can
67+
// remove important annotations, such as /* @__PURE__ */ and comments like /* vite-ignore */.
68+
removeComments: false,
6669
}),
6770
);
6871
}

Diff for: packages/angular_devkit/build_angular/src/tools/webpack/plugins/typescript.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export function createIvyPlugin(
2323
sourceMap: buildOptions.sourceMap.scripts,
2424
declaration: false,
2525
declarationMap: false,
26+
// Disable removing of comments as TS is quite aggressive with these and can
27+
// remove important annotations, such as /* @__PURE__ */.
28+
removeComments: false,
2629
};
2730

2831
if (tsConfig.options.target === undefined || tsConfig.options.target < ScriptTarget.ES2022) {

0 commit comments

Comments
 (0)