Skip to content
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

Differential loading: Edge not considered ES2015 browser #14580

Closed
acalvo opened this issue May 30, 2019 · 3 comments · Fixed by #14716
Closed

Differential loading: Edge not considered ES2015 browser #14580

acalvo opened this issue May 30, 2019 · 3 comments · Fixed by #14716

Comments

@acalvo
Copy link
Contributor

acalvo commented May 30, 2019

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Kind of, due to the introduction of differential loading.

Description

Edge 15-18 are considered non-ES2015 browsers when compiling the app. If you target only Edge 18 in browserslist, I'd expect to only generate the ES2015 code (similar to what happens when only targeting the latest Firefox/Chrome release); but ES5 code is also generated. This is specially worrying because, due to a Edge bug, when running the app, the ES5 bundle is downloaded (but not executed), and the ES2015 bundle is downloaded twice (reference philipwalton/webpack-esnext-boilerplate#1 (comment) ).

The result is that, while in Angular 7 I already compiled for ES2015 giving Edge users a optimized bundle, in Angular8 they are going to download more than 3 times the previous size to end up running the same ES2015 bundle.

🔬 Minimal Reproduction

Edit browserslist file with only this content:

Edge 18

And run ng build --prod

🔥 Exception or Error

Both ES5 and ES2015 are generated.

🌍 Your Environment

Angular CLI: 8.0.0
Node: 12.2.0
OS: darwin x64
Angular: 8.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0
@angular-devkit/build-angular     0.800.0
@angular-devkit/build-optimizer   0.800.0
@angular-devkit/build-webpack     0.800.0
@angular-devkit/core              8.0.0
@angular-devkit/schematics        8.0.0
@angular/flex-layout              8.0.0-beta.26
@angular/pwa                      0.800.0
@ngtools/webpack                  8.0.0
@schematics/angular               8.0.0
@schematics/update                0.800.0
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented May 30, 2019

Hi, I just had a quick look at this, and it seems to be caused by an upstream package.

import * as caniuse from 'caniuse-api';
caniuse.isSupported('es6-module', 'Edge 18')  -> false 

I will try to determine in which upstream direct or transitive dependency the problem is to report the problem in the appropriate tracker.

@alan-agius4 alan-agius4 added state: blocked needs: investigation Requires some digging to determine if action is needed labels May 30, 2019
@acalvo
Copy link
Contributor Author

acalvo commented May 30, 2019

Thanks a lot for looking into this! :)

Yes, I got there because once detected in Angular I was curious how Angular was deciding if it was either a ES5 or ES2015 browser, and saw the caniuse.isSupported bit. I reported it in there: Nyalab/caniuse-api#82 . Truth is I didn't dig any further; didn't occur to me that the problem might come from another dependency of it...

@alan-agius4 alan-agius4 removed the needs: investigation Requires some digging to determine if action is needed label Jun 1, 2019
kyliau pushed a commit that referenced this issue Jun 11, 2019
…S6 modules are being marked as not supported

`caniuse-api` only returns `true` for a feature when it's fully supported. This might causes redundant ES5 builds if users opt to support only browsers which do support ES6 modules but either require polyfills such as Safari 10.1 or when both bundles will be downloaded such as `Edge 18`

See: https://github.com/Nyalab/caniuse-api/blob/1b74c10257e36877709da4f6630513db10203a78/src/index.js#L49 and Nyalab/caniuse-api#82

Fixes #14580
kyliau pushed a commit that referenced this issue Jun 11, 2019
…s6 modules are being marked as not supported

caniuse-api only returns true for a feature when it's fully supported. This might causes redundant ES5 builds if users opt to support only browsers which do support ES6 modules but either require polyfills such as Safari 10.1 or when both bundles will be downloaded such as Edge 18

See: https://github.com/Nyalab/caniuse-api/blob/1b74c10257e36877709da4f6630513db10203a78/src/index.js#L49 and Nyalab/caniuse-api#82

Fixes #14580
@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants