Skip to content

fix: Strip the service worker source map before deploy - #16

Merged
do0ori merged 1 commit into
mainfrom
fix/strip-service-worker-sourcemap
Sep 19, 2026
Merged

do0ori merged 1 commit into
mainfrom
fix/strip-service-worker-sourcemap

Conversation

@do0ori

@do0ori do0ori commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Problem

After #15 landed, gh-pages carried service-worker.js.map (204 KB) — the one source map the cleanup missed.

vite-plugin-pwa builds the service worker in a pass of its own that runs after every plugin's closeBundle, which is where the Sentry plugin's filesToDeleteAfterUpload runs. So the app bundle's maps were removed and the service worker's was written afterwards, unnoticed.

A plugin placed after VitePWA in the array does not fix this; its closeBundle still runs before that pass. Verified locally — service-worker.js.map survived.

Fix

Move the cleanup to a post-build step in the build script, which runs once the entire build is finished.

$ npm run build   # with source maps forced on
Stripped source maps: service-worker.js.map, assets/index-D0eXf5WD.js.map, assets/workbox-window.prod.es5-BBnX5xw4.js.map
maps left: 0

readdirSync(..., { recursive: true }) rather than fs.globSync, which needs Node 22 — CI runs Node 20.

Verification

  • Source maps forced on: all three stripped, dist clean.
  • Normal local build (no token, so none generated): No source maps to strip., exit 0.
  • npm test — 32/32 passing.

gh-pages keeps the stale service-worker.js.map in its history; the next deploy stops publishing it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MUBfrDZLkPRPZQJxJWzeU4

vite-plugin-pwa builds the service worker in a pass of its own, after
every plugin hook the Sentry plugin's cleanup runs in, so
service-worker.js.map survived and was published to GitHub Pages.

Move the cleanup to a post-build step, which runs once the whole build
including that pass is done.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MUBfrDZLkPRPZQJxJWzeU4
@do0ori
do0ori merged commit abe59d4 into main Sep 19, 2026
1 check passed
@do0ori
do0ori deleted the fix/strip-service-worker-sourcemap branch September 19, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant