Close #40215 `fesm2015/zone.js` is built to `esm` bundle with rollup, so the 'use strict'; statement is not generated in the bundle, even we put the 'use strict' in the src code, rollup removes the code in the final bundle. So if we load the `fesm2015/zone.js` as a module, such as `ng serve`, in the index.html ``` <script src="polyfills.js" type="module"></script> ``` Everything works fine, since polyfills.js is loaded as `module`, so it is always `strict`. But in `ng test`, webpack concat the `zone.js` and loaded into the karma html. For other app and test code, they are still `strict` since they are `module` because they have `export/import` statement, but `zone.js` is a bundle without `export`, it is a `side effect` bundle, so after loaded by webpack, it becomes non-strict. Which causes some issues, such as #40215, the root cause is the `this` context should be `undefined` but treated as `Window` in `non-strict` mode. ``` Object.prototype.toString.apply(undefined); // should be [object undefined], but it is [object Window] in non-strict mode. // zone.js patched version of toString Object.prototype.toString = function() { ... // in non-strict mode, this is Window return originalObjectPrototypeToString.call(this); } ``` So in this commit, `'use strict';` is always added to the `esm` bundles. PR Close #40456
Angular - One framework. Mobile & desktop.
Angular is a development platform for building mobile and desktop web applications
using Typescript/JavaScript and other languages.
Contributing Guidelines
·
Submit an Issue
·
Blog
Documentation
Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.
Advanced
Development Setup
Prerequisites
- Install Node.js which includes Node Package Manager
Setting Up a Project
Install the Angular CLI globally:
npm install -g @angular/cli
Create workspace:
ng new [PROJECT NAME]
Run the application:
cd [PROJECT NAME]
ng serve
Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.
Quickstart
Ecosystem
Changelog
Learn about the latest improvements.
Upgrading
Check out our upgrade guide to find out the best way to upgrade your project.
Contributing
Contributing Guidelines
Read through our contributing guidelines to learn about our submission process, coding rules and more.
Want to Help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.
Code of Conduct
Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.
Community
Join the conversation and help the community.
Love Angular? Give our repo a star ⭐ ⬆️.