From 8052de07e2fe711515225a39e877219907214a0a Mon Sep 17 00:00:00 2001 From: Judy Bogart Date: Tue, 25 Jun 2019 11:42:26 -0700 Subject: [PATCH] docs: update polyfill support doc (#31262) PR Close #31262 --- aio/content/guide/browser-support.md | 146 +++++++-------------------- 1 file changed, 37 insertions(+), 109 deletions(-) diff --git a/aio/content/guide/browser-support.md b/aio/content/guide/browser-support.md index 116ee4dcfe..a9f355ae4a 100644 --- a/aio/content/guide/browser-support.md +++ b/aio/content/guide/browser-support.md @@ -53,7 +53,7 @@ Angular supports most recent browsers. This includes the following specific vers IE - 11
10
9 + 11, 10, 9 @@ -89,7 +89,7 @@ Angular supports most recent browsers. This includes the following specific vers - Nougat (7.0)
Marshmallow (6.0)
Lollipop (5.0, 5.1)
KitKat (4.4) + Nougat (7.0), Marshmallow (6.0), Lollipop (5.0, 5.1), KitKat (4.4) @@ -127,25 +127,27 @@ In Angular CLI version 8 and higher, applications are built using *differential This strategy allows you to continue to build your web application to support multiple browsers, but only load the necessary code that the browser needs. For more information about how this works, see [Differential Loading](guide/deployment#differential-loading) in the [Deployment guide](guide/deployment). -## Enabling polyfills +## Enabling polyfills with CLI projects -[Angular CLI](cli) users enable polyfills through the `src/polyfills.ts` file that -the CLI created with your project. +The [Angular CLI](cli) provides support for polyfills. +If you are not using the CLI to create your projects, see [Polyfill instructions for non-CLI users](#non-cli). +When you create a project with the `ng new` command, a `src/polyfills.ts` configuration file is created as part of your project folder. This file incorporates the mandatory and many of the optional polyfills as JavaScript `import` statements. -The npm packages for the _mandatory_ polyfills (such as `zone.js`) were installed automatically for you when you created your project and their corresponding `import` statements are ready to go. You probably won't touch these. +* The npm packages for the [_mandatory_ polyfills](#polyfill-libs) (such as `zone.js`) are installed automatically for you when you create your project with `ng new`, and their corresponding `import` statements are already enabled in the `src/polyfills.ts` configuration file. -But if you need an optional polyfill, you'll have to install its npm package. -For example, [if you need the web animations polyfill](http://caniuse.com/#feat=web-animation), you could install it with `npm`, using the following command (or the `yarn` equivalent): +* If you need an _optional_ polyfill, you must install its npm package, then uncomment or create the corresponding import statement in the `src/polyfills.ts` configuration file. + +For example, if you need the optional [web animations polyfill](http://caniuse.com/#feat=web-animation), you could install it with `npm`, using the following command (or the `yarn` equivalent): - # note that the web-animations-js polyfill is only here as an example - # it isn't a strict requirement of Angular anymore (more below) + # install the optional web animations polyfill npm install --save web-animations-js -Then open the `polyfills.ts` file and un-comment the corresponding `import` statement as in the following example: +You can then add the import statement in the `src/polyfills.ts` file. +For many polyfills, you can simply un-comment the corresponding `import` statement in the file, as in the following example. /** @@ -155,23 +157,14 @@ Then open the `polyfills.ts` file and un-comment the corresponding `import` stat import 'web-animations-js'; // Run `npm install --save web-animations-js`. -If you can't find the polyfill you want in `polyfills.ts`, -add it yourself, following the same pattern: +If the polyfill you want is not already in `polyfills.ts` file, add the `import` statement by hand. -1. install the npm package -1. `import` the file in `polyfills.ts` - -
- -Non-CLI users should follow the instructions [below](#non-cli). -
{@a polyfill-libs} ### Mandatory polyfills These are the polyfills required to run an Angular application on each supported browser: - @@ -189,26 +182,13 @@ These are the polyfills required to run an Angular application on each supported - - - - - - - - @@ -222,7 +202,7 @@ These are the polyfills required to run an Angular application on each supported @@ -235,12 +215,6 @@ These are the polyfills required to run an Angular application on each supported Some features of Angular may require additional polyfills. -For example, the animations library relies on the standard web animation API, which is only available in Chrome and Firefox today. -(note that the dependency of web-animations-js in Angular is only necessary if `AnimationBuilder` is used.) - -Here are the features which may require additional polyfills: - -
- Chrome, Firefox, Edge, Safari 9+ + Chrome, Firefox, Edge,
+ Safari, Android, IE10+
- [ES7/reflect](guide/browser-support#core-es7-reflect) (JIT only) - -
- Safari 7 & 8, IE10 & 11, Android 4.1+ - - - [ES6](guide/browser-support#core-es6) + [ES2015](guide/browser-support#core-es6) - [ES6
classList](guide/browser-support#classlist) + ES2015
[classList](guide/browser-support#classlist)
@@ -263,31 +237,8 @@ Here are the features which may require additional polyfills: - - - - - - - - - - @@ -298,8 +249,9 @@ Here are the features which may require additional polyfills: @@ -308,15 +260,10 @@ Here are the features which may require additional polyfills: @@ -337,9 +284,7 @@ Here are the features which may require additional polyfills:
- [JIT compilation](guide/aot-compiler). - - Required to reflect for metadata. - - - [ES7/reflect](guide/browser-support#core-es7-reflect) - - - All current browsers. Enabled by default. - Can remove if you always use AOT and only use Angular decorators. -
- - [Animations](guide/animations) -
Only if `Animation Builder` is used within the application--standard - animation support in Angular doesn't require any polyfills (as of NG6). + [AnimationBuilder](api/animations/AnimationBuilder). + (Standard animation support does not require polyfills.)
-

If AnimationBuilder is used then the polyfill will enable scrubbing - support for IE/Edge and Safari (Chrome and Firefox support this natively).

+

If AnimationBuilder is used, enables scrubbing + support for IE/Edge and Safari. + (Chrome and Firefox support this natively).

- If you use the following deprecated i18n pipes: - - + If you use the following deprecated i18n pipes: [date](api/common/DeprecatedDatePipe), - [currency](api/common/DeprecatedCurrencyPipe), - [decimal](api/common/DeprecatedDecimalPipe), - [percent](api/common/DeprecatedPercentPipe) - [NgClass](api/common/NgClass) - - on SVG elements + [NgClass](api/common/NgClass) on SVG elements @@ -358,9 +303,7 @@ Here are the features which may require additional polyfills: - [Http](guide/http) - - when sending and receiving binary data + [Http](guide/http) when sending and receiving binary data @@ -383,9 +326,8 @@ Here are the features which may require additional polyfills: - [Router](guide/router) - - when using [hash-based routing](guide/router#appendix-locationstrategy-and-browser-url-styles) + [Router](guide/router) when using + [hash-based routing](guide/router#appendix-locationstrategy-and-browser-url-styles) @@ -404,8 +346,9 @@ Here are the features which may require additional polyfills: -### Suggested polyfills ## -Below are the polyfills which are used to test the framework itself. They are a good starting point for an application. +### Suggested polyfills + +The following polyfills are used to test the framework itself. They are a good starting point for an application. @@ -426,24 +369,6 @@ Below are the polyfills which are used to test the framework itself. They are a - - - - - - - - - - @@ -595,11 +520,14 @@ Below are the polyfills which are used to test the framework itself. They are a computed with the closure compiler. {@a non-cli} + ## Polyfills for non-CLI users -If you are not using the CLI, you should add your polyfill scripts directly to the host web page (`index.html`), perhaps like this. +If you are not using the CLI, add your polyfill scripts directly to the host web page (`index.html`). - +For example: + + <!-- pre-zone polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/web-animations-js/web-animations.min.js"></script>
- - ES7/reflect - - - MIT - - 0.5KB -
@@ -466,7 +391,7 @@ Below are the polyfills which are used to test the framework itself. They are a - ES6 + ES2015