Skip to content

Commit 03180fe

Browse files
clydinalan-agius4
authored andcommittedMar 6, 2025
feat(@schematics/angular): use TypeScript module preserve option for new projects
Newly generated projects will now use the `preserve` value for the `module` option within the TypeScript configuration for the workspace (`tsconfig.json`). This value was added in TypeScript 5.4 and is intended to model the behavior of modern bundlers such as used in the default `application` builder. This option value also has the advantage of automatically enabling `esModuleInterop` and setting `moduleResolution` to `bundler` which are the currently generated values for new projects. This allows explicit use of these options to be removed from the generated file. The `resolveJsonModule` option is also enabled with `preserve` which removes the need for developers to manually add it if JSON files are imported. JSON file imports are fully support including unused property treeshaking with named imports in the `application` builder. Additional details on the option can be found here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-4.html#support-for-require-calls-in---moduleresolution-bundler-and---module-preserve
1 parent 29243fb commit 03180fe

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed
 

‎packages/schematics/angular/workspace/files/tsconfig.json.template

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
"noFallthroughCasesInSwitch": true,<% } %>
1212
"skipLibCheck": true,
1313
"isolatedModules": true,
14-
"esModuleInterop": true,
1514
"experimentalDecorators": true,
16-
"moduleResolution": "bundler",
1715
"importHelpers": true,
1816
"target": "ES2022",
19-
"module": "ES2022"
17+
"module": "preserve"
2018
},
2119
"angularCompilerOptions": {
2220
"enableI18nLegacyMessageIdFormat": false<% if (strict) { %>,

0 commit comments

Comments
 (0)
Please sign in to comment.