x)- [ ] bug report -> please search issues before submitting
- [X] feature request
x)- [ ] new
- [X] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
v10.11.0
6.4.1
Angular CLI: 6.1.1
Node: 10.11.0
OS: linux x64
Angular: 6.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular-devkit/architect 0.7.1
@angular-devkit/build-angular 0.7.1
@angular-devkit/build-ng-packagr 0.7.1
@angular-devkit/build-optimizer 0.7.1
@angular-devkit/build-webpack 0.7.1
@angular-devkit/core 0.7.1
@angular-devkit/schematics 0.7.1
@angular/cli 6.1.1
@ngtools/json-schema 1.1.0
@ngtools/webpack 6.1.1
@schematics/angular 0.7.1
@schematics/update 0.7.1
ng-packagr 3.0.6
rxjs 6.2.2
typescript 2.9.2
webpack 4.9.2
If I build an Angular library that has a dependency and that dependency requires a polyfill, I need to inform the consumer of my library to add the polyfill to their application polyfill.ts. The CLI does not provide the ability to define a polyfill within a library and have it be bundled into the application.
The desired behavior is to enable libraries to include the polyfill and abstract that knowledge from the library consumer.
In angular.json, a polyfills field exists for the @angular-devkit/build-angular:browser builder. Is it possible to add a polyfills field for the @angular-devkit/build-ng-packagr:build builder?
I asked if this feature was available on StackOverflow. Based on the up votes on the question it appears that I am not the only one with this use case.
IMHO, a library should never bundle a polyfill. It鈥檚 up to the consumers of the library based on their targeted browsers to include a polyfill or not.
If I want to target only ever green browsers I certainly don鈥檛 want that a library that I am using has an embedded polyfill.
As an application develop, I don鈥檛 want to end up having duplicate polyfills for the same thing, because it was already shipped in library that I am using.
@alan-agius4 that is a very good point!
I will close this issue since @alan-agius4's response is pretty convincing to me :smile:
@alan-agius4 I think this could be worth reopening. What if we want to compile a library as a web component to be reused in any framework? Then we should be able to add the following:
import "@webcomponents/custom-elements/src/native-shim";
import "@webcomponents/custom-elements/custom-elements.min";
Unless there is a guideline I'm not aware of?
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._
Most helpful comment
IMHO, a library should never bundle a polyfill. It鈥檚 up to the consumers of the library based on their targeted browsers to include a polyfill or not.
If I want to target only ever green browsers I certainly don鈥檛 want that a library that I am using has an embedded polyfill.
As an application develop, I don鈥檛 want to end up having duplicate polyfills for the same thing, because it was already shipped in library that I am using.