oliviertassinari / serviceworker-webpack-plugin

Simplifies creation of a service worker to serve your webpack bundles. :recycle:
https://oliviertassinari.github.io/serviceworker-webpack-plugin/
MIT License
458 stars 76 forks source link

Is there a way to add babel-polyfill using options ? #74

Closed momsse closed 6 years ago

momsse commented 6 years ago

Thanks guys for all the work done !

To use ES6 features like async/await i have to import babel-polyfill before using my ES6 code.

serviceWorker/index.js:

import 'babel-polyfill';
import './worker';

serviceWorker/worker.js:

async function myAsyncStuffHere() {}

Is there a way to provide babel-polyfill on the entry options or something like that as we can do on webpack ?

woutervanvliet commented 6 years ago

Are you sure you need that? All browsers supporting ServiceWorker also support async/await - save for some really (over a year) old versions of Chrome and Firefox

woutervanvliet commented 6 years ago

And otherwise you can just import them in your sw.js file.

momsse commented 6 years ago

Encountering same issue that this guy (https://stackoverflow.com/questions/33527653/babel-6-regeneratorruntime-is-not-defined) : regeneratorRuntime is not defined.

And unfortunately importing babel-polyfill on the same module don't fix the issue :/

Do you need a minimal reproduction case so you can look at it ? Or no plan to consider this issue ?

woutervanvliet commented 6 years ago

If you have a minimal repo I can take a look if we can classify this as a bug, a reasonable feature request, or something that you can fix with a few lines of code yourself.

Thinking about what I wrote myself before; maybe the real solution will be to be able to use a separate babel config for the ServiceWorker. After all, as it only works on modern browsers it won't need as much transpiling.

momsse commented 6 years ago

@woutervanvliet did the minimal repo here => momsse/serviceworker-webpack-plugin-issue-11 but cannot reproduce the issue. The problem is probably elsewhere.

Thanks again and sorry for making you waste time :/

woutervanvliet commented 6 years ago

@momsse No worries - thanks for closing the issue, and sorry for the delayed response