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

Proposal for external polyfills being included in shim #183

Closed
matt-gadd opened this issue Nov 23, 2018 · 1 comment
Closed

Proposal for external polyfills being included in shim #183

matt-gadd opened this issue Nov 23, 2018 · 1 comment
Labels
enhancement New feature or request next Issue/Pull Request for the next major version

Comments

@matt-gadd
Copy link
Contributor

matt-gadd commented Nov 23, 2018

Enhancement
At the moment, any third party polyfills or ponyfills used by or recommended to be used with dojo have to be included separately, this causes a few pain points:

  • inconsistency with how users are used to using other ponyfills from shim
  • relies on them knowing the correct packages to install from npm (or us documenting it effectively)
  • relies on the end user knowing how to include/use the polyfill or ponyfill
  • relies on the package being installed to have correct/compatible types, or an equivalent @types package
  • does not allow us to elide the polyfills/ponyfills based on whether they are implemented in the specific browser

To solve this the proposal is to include a number of external polyfills/ponyfills in dojo/framework and re-export them to the end user as if they were any other kind of dojo shim. For example for IntersectionObserver may look like:

module: @dojo/framework/shim/IntersectionObserver
import global from '@dojo/framework/shim/global';
import 'intersection-observer';

export default global.IntersectionObserver as IntersectionObserver;

The end user would then leverage @dojo/framework/shim/IntersectionObserver and use it as a ponyfill (regardless of whether it is a ponyfill or not).

From this, we can then also expand our current build capabilities to correctly include the polyfills based on whether a) they are used/imported, and b) if they are actually needed by the users browser based on a runtime check.

@agubler
Copy link
Member

agubler commented Jan 9, 2019

This has been completed, external polyfills are encapsulated in shim, exposed as ponyfills and conditionally loaded when using the dojo build tooling.

@agubler agubler closed this as completed Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request next Issue/Pull Request for the next major version
Projects
None yet
Development

No branches or pull requests

2 participants