fix(docs-infra): fix angular.io on IE 11#41162
Conversation
|
You can preview 99eab12 at https://pr41162-99eab12.ngbuilds.io/. |
The custom elements spec is not compatible with ES5 style classes. This means ES2015 code compiled to ES5 will not work with a native implementation of Custom Elements. To support browsers that natively support Custom Elements but not ES2015 modules, we load `@webcomponents/custom-elements/src/native-shim.js`, which minimally augments the native implementation to be compatible with ES5 code. (See [here][1] for more details.) Previously, the shim was included in `polyfills.ts`, which meant it was loaded in all browsers (even those supporting ES2015 modules and thus not needing the shim). This commit moves the shim from `polyfills.ts` to a `nomodule` script tag in `index.html`. This will ensure that it is only loaded in browsers that do not support ES2015 modules and thus do not needed the shim. NOTE: This commit also reduces size of the polyfills bundle by ~400B (52609B --> 52215B). [1]: https://www.npmjs.com/package/@webcomponents/custom-elements#es5-vs-es2015
Previously, the angular.io app was broken on IE 11. In particular, pages that included Custom Elements would fail to load, because the `Reflect.construct()` method (which the Custom Elements ES5 shim relies on) was not available. This commit fixes this by loading the polyfill for `Reflect.construct()` on browsers that do not support ES2015 (including IE 11).
|
You can preview 7d487d3 at https://pr41162-7d487d3.ngbuilds.io/. |
jessicajaniuk
left a comment
There was a problem hiding this comment.
LGTM
reviewed-for: size-tracking
|
@jessicajaniuk, wait what? No 🍪? 😭 😭 😭 |
petebacondarwin
left a comment
There was a problem hiding this comment.
I haven't bothered to test on IE. I trust that you did @gkalpak.
Reviewed-for: size-tracking
jessicajaniuk
left a comment
There was a problem hiding this comment.
🍪 I managed to find one!
Previously, the angular.io app was broken on IE 11. In particular, pages that included Custom Elements would fail to load, because the `Reflect.construct()` method (which the Custom Elements ES5 shim relies on) was not available. This commit fixes this by loading the polyfill for `Reflect.construct()` on browsers that do not support ES2015 (including IE 11). PR Close #41162
|
@gkalpak FYI this PR was merged to master only, since it had merge conflicts withe the patch branch (11.2.x). Could you please create a new patch-only version of this PR? Thank you. |
…angular#41162) The custom elements spec is not compatible with ES5 style classes. This means ES2015 code compiled to ES5 will not work with a native implementation of Custom Elements. To support browsers that natively support Custom Elements but not ES2015 modules, we load `@webcomponents/custom-elements/src/native-shim.js`, which minimally augments the native implementation to be compatible with ES5 code. (See [here][1] for more details.) Previously, the shim was included in `polyfills.ts`, which meant it was loaded in all browsers (even those supporting ES2015 modules and thus not needing the shim). This commit moves the shim from `polyfills.ts` to a `nomodule` script tag in `index.html`. This will ensure that it is only loaded in browsers that do not support ES2015 modules and thus do not needed the shim. NOTE: This commit also reduces size of the polyfills bundle by ~400B (52609B --> 52215B). [1]: https://www.npmjs.com/package/@webcomponents/custom-elements#es5-vs-es2015 PR Close angular#41162
Previously, the angular.io app was broken on IE 11. In particular, pages that included Custom Elements would fail to load, because the `Reflect.construct()` method (which the Custom Elements ES5 shim relies on) was not available. This commit fixes this by loading the polyfill for `Reflect.construct()` on browsers that do not support ES2015 (including IE 11). PR Close angular#41162
…nts but not ES2015 Before angular#41162, angular.io was broken on IE 11 due to missing a polyfill for an API (`Reflect.construct()`) needed by the Custom Elements ES5 shim. angular#41162 tried to fix this by loading the necessary polyfill (`es.reflect.construct.js`) on browsers that do not support ES2015 modules (including IE 11). It turns out that the fix in angular#41162 was itself broken, because the `es.reflect.consruct.js` script (included directly in the page via a `<script>` tag) was in CommonJS format (which cannot run in the browser as is). By chance, this still allowed browsers that supported neither Custom Elements nor ES2015 modules (such as IE 11) to work correctly as a side-effect of loading the `@webcomponents/custom-elements` polyfill after the Custom Elements ES5 shim (`native-shim.js`). However, on the few browsers that natively support Custom Elements but not ES2015 modules, angular.io would still be broken. This commit correctly fixes angular.io on all browsers by properly bundling the polyfills and transpiling to ES5. Implementation-wise, we use [esbuild][1] for bundling the polyfills (and converting from CommonJS to a browser-compatible, IIFE-based format) and [swc][2] for downleveling the code to ES5 (since `esbuild` only supports ES2015+). [1]: https://esbuild.github.io/ [2]: https://swc.rs/
…#41162) (#41184) The custom elements spec is not compatible with ES5 style classes. This means ES2015 code compiled to ES5 will not work with a native implementation of Custom Elements. To support browsers that natively support Custom Elements but not ES2015 modules, we load `@webcomponents/custom-elements/src/native-shim.js`, which minimally augments the native implementation to be compatible with ES5 code. (See [here][1] for more details.) Previously, the shim was included in `polyfills.ts`, which meant it was loaded in all browsers (even those supporting ES2015 modules and thus not needing the shim). This commit moves the shim from `polyfills.ts` to a `nomodule` script tag in `index.html`. This will ensure that it is only loaded in browsers that do not support ES2015 modules and thus do not needed the shim. NOTE: This commit also reduces size of the polyfills bundle by ~400B (52609B --> 52215B). [1]: https://www.npmjs.com/package/@webcomponents/custom-elements#es5-vs-es2015 PR Close #41162 PR Close #41184
Previously, the angular.io app was broken on IE 11. In particular, pages that included Custom Elements would fail to load, because the `Reflect.construct()` method (which the Custom Elements ES5 shim relies on) was not available. This commit fixes this by loading the polyfill for `Reflect.construct()` on browsers that do not support ES2015 (including IE 11). PR Close #41162 PR Close #41184
…nts but not ES2015 (#41183) Before #41162, angular.io was broken on IE 11 due to missing a polyfill for an API (`Reflect.construct()`) needed by the Custom Elements ES5 shim. #41162 tried to fix this by loading the necessary polyfill (`es.reflect.construct.js`) on browsers that do not support ES2015 modules (including IE 11). It turns out that the fix in #41162 was itself broken, because the `es.reflect.consruct.js` script (included directly in the page via a `<script>` tag) was in CommonJS format (which cannot run in the browser as is). By chance, this still allowed browsers that supported neither Custom Elements nor ES2015 modules (such as IE 11) to work correctly as a side-effect of loading the `@webcomponents/custom-elements` polyfill after the Custom Elements ES5 shim (`native-shim.js`). However, on the few browsers that natively support Custom Elements but not ES2015 modules, angular.io would still be broken. This commit correctly fixes angular.io on all browsers by properly bundling the polyfills and transpiling to ES5. Implementation-wise, we use [esbuild][1] for bundling the polyfills (and converting from CommonJS to a browser-compatible, IIFE-based format) and [swc][2] for downleveling the code to ES5 (since `esbuild` only supports ES2015+). [1]: https://esbuild.github.io/ [2]: https://swc.rs/ PR Close #41183
…nts but not ES2015 (#41183) Before #41162, angular.io was broken on IE 11 due to missing a polyfill for an API (`Reflect.construct()`) needed by the Custom Elements ES5 shim. #41162 tried to fix this by loading the necessary polyfill (`es.reflect.construct.js`) on browsers that do not support ES2015 modules (including IE 11). It turns out that the fix in #41162 was itself broken, because the `es.reflect.consruct.js` script (included directly in the page via a `<script>` tag) was in CommonJS format (which cannot run in the browser as is). By chance, this still allowed browsers that supported neither Custom Elements nor ES2015 modules (such as IE 11) to work correctly as a side-effect of loading the `@webcomponents/custom-elements` polyfill after the Custom Elements ES5 shim (`native-shim.js`). However, on the few browsers that natively support Custom Elements but not ES2015 modules, angular.io would still be broken. This commit correctly fixes angular.io on all browsers by properly bundling the polyfills and transpiling to ES5. Implementation-wise, we use [esbuild][1] for bundling the polyfills (and converting from CommonJS to a browser-compatible, IIFE-based format) and [swc][2] for downleveling the code to ES5 (since `esbuild` only supports ES2015+). [1]: https://esbuild.github.io/ [2]: https://swc.rs/ PR Close #41183
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fix(docs-infra): avoid unnecessarily loading Custom Elements ES5 shim:
The custom elements spec is not compatible with ES5 style classes. This means ES2015 code compiled to ES5 will not work with a native implementation of Custom Elements. To support browsers that natively support Custom Elements but not ES2015 modules, we load
@webcomponents/custom-elements/src/native-shim.js, which minimally augments the native implementation to be compatible with ES5 code.(See here for more details.)
Previously, the shim was included in
polyfills.ts, which meant it was loaded in all browsers (even those supporting ES2015 modules and thus not needing the shim).This commit moves the shim from
polyfills.tsto anomodulescript tag inindex.html. This will ensure that it is only loaded in browsers that do not support ES2015 modules and thus do not needed the shim.NOTE:
This commit also reduces size of the polyfills bundle by ~400B (52609B --> 52215B).
fix(docs-infra): fix angular.io on IE 11:
Previously, the angular.io app was broken on IE 11. In particular, pages that included Custom Elements would fail to load, because the
Reflect.construct()method (which the Custom Elements ES5 shim relies on) was not available.This commit fixes this by loading the polyfill for
Reflect.construct()on browsers that do not support ES2015 (including IE 11).