nollup icon indicating copy to clipboard operation
nollup copied to clipboard

Usage with Workbox

Open piotr-cz opened this issue 4 years ago • 2 comments

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,

piotr-cz avatar Jul 14 '20 09:07 piotr-cz

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?

PepsRyuu avatar Jul 14 '20 21:07 PepsRyuu

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.

piotr-cz avatar Jul 17 '20 08:07 piotr-cz