From a7f5b6f8b15ea092b31a57c2f7ac9e3e2d407849 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:03:35 -0400 Subject: [PATCH] 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 --- .../schematics/angular/workspace/files/tsconfig.json.template | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/schematics/angular/workspace/files/tsconfig.json.template b/packages/schematics/angular/workspace/files/tsconfig.json.template index 66f33fe73f08..45c41bcc800d 100644 --- a/packages/schematics/angular/workspace/files/tsconfig.json.template +++ b/packages/schematics/angular/workspace/files/tsconfig.json.template @@ -11,12 +11,10 @@ "noFallthroughCasesInSwitch": true,<% } %> "skipLibCheck": true, "isolatedModules": true, - "esModuleInterop": true, "experimentalDecorators": true, - "moduleResolution": "bundler", "importHelpers": true, "target": "ES2022", - "module": "ES2022" + "module": "preserve" }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false<% if (strict) { %>,