Skip to content

Conditional ES5 Browser Polyfill Loading #13403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 15, 2019
Merged

Conversation

clydin
Copy link
Member

@clydin clydin commented Jan 10, 2019

  • no need to manually import and manage individual ES2015 polyfills required by Angular
  • ES2015 polyfills are only loaded by browsers that require them
  • Controllable via a new es5BrowserSupport option; no behavior change if option is not enabled
  • es5BrowserSupport is enabled in newly generated projects
  • allows for custom polyfill solutions by not using the new option
  • works in conjunction with conditional JIT polyfills and will load ES2015 specific JIT polyfills as needed
  • Saves ~56KB on native ES2015 browsers

@clydin clydin force-pushed the polyfills branch 3 times, most recently from 53a32a0 to 9ab5eff Compare January 10, 2019 20:37
Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clydin clydin added the target: major This PR is targeted for the next major release label Jan 14, 2019
@tomgruszowski
Copy link

tomgruszowski commented Jan 31, 2019

Love this feature, are there any docs on how to enable this?

@Francois-Belanger
Copy link

How can we enable on current projects ?

@diicar
Copy link

diicar commented Feb 1, 2019

It's enabled by defauly, just need to Update cli to v7.3.x I believe.

@neilhem
Copy link
Contributor

neilhem commented Feb 7, 2019

Add es5BrowserSupport: true to angular.json options. Remove es6 polyfills from polyfills.ts.
There is no option to include specific polyfills to this file

@maxailloud
Copy link

How can I fix the Schema validation failed with the following errors: Data path "" should NOT have additional properties(es5BrowserSupport). error?
I just added the option to my build option.

@clydin
Copy link
Member Author

clydin commented Feb 7, 2019

@maxailloud The project most likely has an older version of @angular-devkit/build-angular (for this feature 0.13.0+ is needed).

Also, the team is more than happy to help when possible, but please avoid using a PR for these type of discussions as they are not generally monitored.

@maxailloud
Copy link

Oh my bad, thought it was an issue.
And btw don't know why but i still had the 0.12.4 version of it, even after executing ng update @angular/cli.

Thank you and sorry again.

@paulogr
Copy link

paulogr commented Feb 7, 2019

And on your previously created projects, don't forget to remove those es6 polyfills imports from polyfills.ts file for this feature be real effective!

import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be mistaken, but it's my understanding that polyfills are moved into an internal file. I often find that I also need to import some of the es7 modules (for example to support Object.entries) into polifyls. Having them in an internal file won't allow me adding additional polifylls only required for legacy browsers. It'd be my preference if there was a new file generated by CLI and included in the app: polifyls.legacy.ts or something like that.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.