shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.71k stars 312 forks source link

Service worker gets changed every build (output not reproducible) #501

Open elliot-nelson opened 5 months ago

elliot-nelson commented 5 months ago

Summary

A client app team working on a Nextjs app recently added the next-pwa toolchain, and what we are noticing is that even if all inputs (i.e. dependencies and source files) have not changed, the output file is not reproducible -- it keeps changing every build, which is breaking our build caching.

Versions

How To Reproduce

We added the following config block to the next.config.js file:

const withPWA = require('next-pwa')({
  dest: 'public',
  sw: '_next_service-worker.js',
  swSrc: 'service-worker.js',
  register: true,
  skipWaiting: true,
  maximumFileSizeToCacheInBytes: 3000000,
  disable: process.env.NODE_ENV === 'development',
  buildExcludes: ['app-build-manifest.json']
});
  1. Run next build
  2. Run git add public/_next_service-worker.js
  3. Run next build again (no other files in repo have been modified)

EXPECTED: git status contains no diffs, output file is identical to previous one ACTUAL: git status contains diffs, a very big compressed line has changed in the service worker output