mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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 |
||
|---|---|---|
| .. | ||
| animations | ||
| bazel | ||
| benchpress | ||
| common | ||
| compiler | ||
| compiler-cli | ||
| core | ||
| docs | ||
| elements | ||
| examples | ||
| forms | ||
| language-service | ||
| localize | ||
| misc/angular-in-memory-web-api | ||
| platform-browser | ||
| platform-browser-dynamic | ||
| platform-server | ||
| private/testing | ||
| router | ||
| service-worker | ||
| upgrade | ||
| zone.js | ||
| BUILD.bazel | ||
| circular-deps-test.conf.js | ||
| empty.ts | ||
| goog.d.ts | ||
| license-banner.txt | ||
| README.md | ||
| system.d.ts | ||
| tsconfig-build-no-strict.json | ||
| tsconfig-build.json | ||
| tsconfig-test.json | ||
| tsconfig.json | ||
| types.d.ts | ||
Angular
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT