PepsRyuu / nollup

Rollup compatible development bundler for fast rebuilds and HMR.
MIT License
488 stars 28 forks source link

Usage with Workbox #106

Open piotr-cz opened 4 years ago

piotr-cz commented 4 years ago

In my project I'm using Workbox via rollup-plugin-workbox-inject to compile service worker.

My rollup configuration has two rollup input entries: one for app and other for service worker.

This doesn't work with nollup in Hot module replacement mode, because rollup-plugin-workbox-inject is creating precache revisions (checksums) basing on physical file contents in the output folder, while nollups' dev-server is serving files on the fly.

Actually I'm not sure if it's bad thing that these two technologies doesn't work together. If they would, browser would have to reinstall service worker on each hmr push.

I'm just curious how others cope with nollup and workbox,

PepsRyuu commented 4 years ago

Not familiar with Workbox. Do you have a reproducible example of trying to use the plugin with Nollup? Is there something in particular going wrong?

piotr-cz commented 4 years ago

When thinking about it. it probably doesn't make sense to register/ use Service Worker when using Hot Module Replacement.

For example create-react-app is doing so only on production environment:

The service worker is only enabled in the production environment, e.g. the output of npm run build. It's recommended that you do not enable an offline-first service worker in a development environment, as it can lead to frustration when previously cached assets are used and do not include the latest changes you've made locally.

Code reference: https://github.com/facebook/create-react-app/blob/v3.4.1/packages/cra-template/template/src/serviceWorker.js#L24 (register function is no-op on dev server)

But let's keep this issue open so others can add to discussion.