Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Determine strategy to provide Babel-polyfill for older browsers #42

Closed
pierluigi opened this issue Oct 26, 2016 · 4 comments
Closed

Determine strategy to provide Babel-polyfill for older browsers #42

pierluigi opened this issue Oct 26, 2016 · 4 comments

Comments

@pierluigi
Copy link
Member

Older browsers require the babel-polyfill https://babeljs.io/docs/usage/polyfill/ – do you think it's this package's responsibility to solve this issue?

@dlmr
Copy link
Member

dlmr commented Oct 27, 2016

This is definitely something that should be managed by Roc and this package is a good place.

We just need to do this correctly when adding this, a reason for us not adding it as of yet. What I mean with that we would optimally load polyfills on demand in clients that require them to avoid increasing the size in modern browsers.

There are several strategies on how to solve this some of which are mentioned in this article https://philipwalton.com/articles/loading-polyfills-only-when-needed. We could probably using the knowledge that Roc have about the application only add the needed checks needed to polyfill what is needed by the specific application.

On this topic we should also look into what we transpile using Babel and target the correct browsers, we can do this using https://github.com/babel/babel-preset-env potentially.

@wadim
Copy link
Contributor

wadim commented Nov 17, 2016

Before we figure out a generic polyfill strategy for roc, what is the best way to include babel-polyfill in individual projects for now?

@dlmr
Copy link
Member

dlmr commented Nov 17, 2016

The current suggested way is the following.

roc.config.js

module.exports = {
  /* … */
  settings: {
    /* … */
    build: {
      /* … */
      resources: ['src/polyfill.js'],
    },
  },
};

src/polyfill.js

if (__WEB__) {
  require('babel-polyfill');
}

@dlmr
Copy link
Member

dlmr commented Jan 2, 2018

This issue has been moved into the mono repository rocjs/extensions#21.

@dlmr dlmr closed this as completed Jan 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants