-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Angular 8 Service Worker Support for Conditionally Download ES5 or Es2015 bundles #31256
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
Comments
For angular.io, we do the following in ngsw-config.json: "assetGroups": [
{
"name": "app-shell",
"installMode": "prefetch",
"updateMode": "prefetch",
"resources": {
"files": [
...
"/*.js",
"!/*-es5*.js"
],
...
}
}, {
"name": "assets-lazy",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
...
"/*-es5*.js",
]
}
}
], I.e. we eagerly load the es2015 bundles and we only load and cache the es5 bundles when requested (i.e. on browsers that need them). This is indeed not ideal, but we take advantage of the fact that most browsers that support ServiceWorkers also support the es2015 bundles. Leaving this open as a feature request (to have a mechanism to fetch the right bundles), but it is low priority atm. |
As this seems to be a reasonable approach, and the one most people would take, I'd argue that the
The few browser versions that support Service Workers but not The Angular Service Worker has also no support to load a different (es5) |
The tooling team was going through some old PRs and came across #17905. In the current state of affairs, differential loading is deprecated and disabled by default, while it's main motivation (IE11) is also deprecated and losing support in v13. Changing the schematic now introduces migration challenges to update existing apps and then likely will need to be migrated again once differential loading is removed. @gkalpak's workaround is pretty easy for individual projects to change if this issue is important enough to them, but updating the schematics now is probably more effort than it is worth for a feature like differential loading in its current state, so I'm closing this issue. |
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. |
This feature request is for
@angular/pwa
Description
With Angular 8 we now have support for Differential Loading, and Angular compiler produces two bundles one for ES5 and other for ES2015 and browser can choose between modern or legacy JavaScript based on its own capabilities.
This works fine, unless we are using Angular Service worker, but when we have a progressive web app, Angular Service Worker prefetchs, all JavaScript bundles i.e. ES5 and ES2015 bundles.
So, there should be an option in service worker to download the bundles on the basis of browser capabilities and it should download either ES5 or Es2015 bundles not both.
Describe the solution you'd like
May be some option could be provided in
ngsw-config.json
file e.g. a property forassetGroups
through which we could specify when assets in this group should be downloaded (legacy/modern browser).The text was updated successfully, but these errors were encountered: