{ "id": "guide/migration-update-module-and-target-compiler-options", "title": "Update module and target compiler options migration", "contents": "\n\n\n
module
and target
compiler options migrationlinkThis migration adjusts the target
and module
settings within the TypeScript configuration files for the workspace.\nThe changes to each option vary based on the builder or command that uses the TypeScript configuration file.\nUnless otherwise noted, changes are only made if the existing value was not changed since the project was created.\nThis process helps ensure that intentional changes to the options are kept in place.
TypeScript Configuration File(s) | \nChanged Property | \nExisting Value | \nNew Value | \n\n |
---|---|---|---|---|
<workspace base>/tsconfig.json | \n\"module\" | \n\"esnext\" | \n\"es2020\" | \n\n |
Used in browser builder options (ng build for applications) | \n\"module\" | \n\"esnext\" | \n\"es2020\" | \n\n |
Used in ng-packgr builder options (ng build for libraries) | \n\"module\" | \n\"esnext\" | \n\"es2020\" | \n\n |
Used in karma builder options (ng test for applications) | \n\"module\" | \n\"esnext\" | \n\"es2020\" | \n\n |
Used in server builder options (universal) | \n\"module\" | \n\"commonjs\" | \nremoved | \n\n |
Used in server builder options (universal) | \n\"target\" | \nany | \n\"es2016\" | \n\n |
Used in protractor builder options (ng e2e for applications) | \n\"target\" | \n\"es5\" | \n\"es2018\" | \n\n |
This migration provides improvements to the long-term supportability of projects by updating the projects to use recommended best practice compilation options.
\nFor the functionality that executes on Node.js, such as Universal and Protractor, the new settings provide performance and troubleshooting benefits as well.\nThe minimum Node.js version for the Angular CLI (v10.13) supports features in ES2018 and earlier.\nBy targeting later ES versions, the compiler transforms less code and can use newer features directly.\nSince zone.js does not support native async
and await
, the universal builds still target ES2016.
\"es2020\"
instead of \"esnext\"
?linkIn TypeScript 3.9, the behavior of the TypeScript compiler controlled by module
is the same with both \"esnext\"
and \"es2020\"
values.\nThis behavior can change in the future, because the \"esnext\"
option could evolve in a backwards incompatible ways, resulting in build-time or run-time errors during a TypeScript update.\nAs a result, code can become unstable. Using the \"es2020\"
option mitigates this risk.