ember-cli-babel icon indicating copy to clipboard operation
ember-cli-babel copied to clipboard

Create a target specific polyfill.

Open rwjblue opened this issue 8 years ago • 14 comments
trafficstars

Instead of importing the full babel-polyfill we create a polyfill that supports the specific targets the app has declared.

This dramatically reduces the cost of setting includePolyfill: true when your targets are newer. For example, with last 1 chrome versions as the list of targets, you save 4kb after min+gz (roughly 50% of the total polyfill size).

TODO:

  • [ ] Fix CI
  • [ ] Ensure we add regeneratorRuntime when needed by the given targets.

rwjblue avatar May 04 '17 02:05 rwjblue

CI is currently failing due to a new assertion added to ember-cli-htmlbars-inline-precompile (which checks if the host project has a new enough version of ember-cli-babel).

rwjblue avatar May 04 '17 02:05 rwjblue

@stefanpenner - Would love general thoughts on this before I go too far down the rabbit hole...

rwjblue avatar May 04 '17 02:05 rwjblue

Would love to see this! 👍

@rwjblue not sure about your numbers, shouldn't the savings be substantially more? I see the whole polyfill at ~30kB (min+gz)

simonihmig avatar Jul 18 '17 09:07 simonihmig

@simonihmig - Been a while since I've looked at it, haven't had much time to try to push this over the hump. Would love help if you are interested..

rwjblue avatar Jul 19 '17 16:07 rwjblue

@rwjblue If @simonihmig doesn't have time I'd be interested in looking into this. I just spent several days working around something that this would have been perfect for ;-)

eshtadc avatar Jul 26 '17 20:07 eshtadc

@eshtadc feel free to do so! Would love to help, but time is very limited atm, with day job and other OSS. Btw, noticed today that this PR was subject of a discussion on #dev-ember-cli, so maybe others are interested to give a helping hand? cc @cibernox @t-sauer

simonihmig avatar Jul 26 '17 21:07 simonihmig

@rwjblue I have a rebased version of this PR at https://github.com/andyhot/ember-cli-babel/commits/target-based-polyfill (also fixes a minor issue with the targets-parser)

Do you see this going forwards?

andyhot avatar Oct 20 '17 13:10 andyhot

@andyhot - Absolutely interested in pushing forward on this, just haven't had much time lately. If you'd like, feel free to open up a new PR (or PR against my branch here) and we can try to continue to move things forward...

rwjblue avatar Nov 05 '17 01:11 rwjblue

Great. Well, I already have a PR for this against ember-cli-babel#6.8.2. Should I try to rebase against master (7.0.0-alphas) or is that good enough?

andyhot avatar Nov 05 '17 01:11 andyhot

Well, I already have a PR for this against ember-cli-babel#6.8.2.

Hmm, I'm confused by this. I don't see any PR's here or against my fork. Can you link me to the PR you had already created?

rwjblue avatar Nov 05 '17 02:11 rwjblue

Meant to say have the code ready - but hadn't done a PR since your master branch is really old. Anyway, I opened https://github.com/rwjblue/ember-cli-babel/pull/1 that updates your master to 6.8.2 and then adds the commits included here + a fix needed for targets-parser

andyhot avatar Nov 05 '17 03:11 andyhot

I also went ahead and opened a PR here (against master) which is easier to examine since it only contains 2 commits - https://github.com/babel/ember-cli-babel/pull/187. Feel free to remove the other one

andyhot avatar Nov 05 '17 03:11 andyhot

What's the status of this?

knownasilya avatar May 10 '18 21:05 knownasilya

For anyone following along here, https://github.com/pzuraq/ember-cli-babel-polyfills may be of interest

acorncom avatar Feb 09 '19 00:02 acorncom

Going to close this as polyfill support was removed in v8.

bertdeblock avatar Jan 28 '23 09:01 bertdeblock