fix: Strip the service worker source map before deploy - #16
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After #15 landed,
gh-pagescarriedservice-worker.js.map(204 KB) — the one source map the cleanup missed.vite-plugin-pwabuilds the service worker in a pass of its own that runs after every plugin'scloseBundle, which is where the Sentry plugin'sfilesToDeleteAfterUploadruns. So the app bundle's maps were removed and the service worker's was written afterwards, unnoticed.A plugin placed after
VitePWAin the array does not fix this; itscloseBundlestill runs before that pass. Verified locally —service-worker.js.mapsurvived.Fix
Move the cleanup to a post-build step in the
buildscript, which runs once the entire build is finished.readdirSync(..., { recursive: true })rather thanfs.globSync, which needs Node 22 — CI runs Node 20.Verification
distclean.No source maps to strip., exit 0.npm test— 32/32 passing.gh-pageskeeps the staleservice-worker.js.mapin its history; the next deploy stops publishing it.🤖 Generated with Claude Code
https://claude.ai/code/session_01MUBfrDZLkPRPZQJxJWzeU4