🍕 fix(zip): strip source maps + verify manifest at root#5
Merged
Conversation
The Chrome Web Store rejects uploads where `manifest.json` isn't at the zip root with "No manifest found in package." The most common cause is right-clicking `dist/` in Finder/Explorer → Compress, which produces a zip with a `dist/` wrapper. Even when our script is used, source maps and macOS `__MACOSX/` resource forks would silently triple the upload size and occasionally trip Web Store validation. This hardens `scripts/zip-extension.mjs`: - **Strips `*.map`, `.DS_Store`, and `__MACOSX/`** by default. Pass `INCLUDE_SOURCEMAPS=1 npm run zip` to opt back in for sideload-debug builds. Cuts the zip from ~333 KB → ~101 KB (3.3× smaller). - **Verifies after zipping** that `manifest.json` is at the root by shelling out to `unzip -p` (with a PowerShell fallback). Refuses to hand off a zip that would be rejected by the store. - **Asserts `dist/manifest.json` exists** before zipping (catches a half-broken build). - **Prints explicit upload instructions** so there's no ambiguity about which file to upload and where. README's "Releasing" section now warns against Finder/Explorer compression and documents the `INCLUDE_SOURCEMAPS=1` escape hatch. Tested locally: $ npm run zip → clay-slip-v2.0.2.zip (101.0 KB) → manifest.json verified at root Negative test (zipped with a `dist/` wrapper) correctly trips the verification guard with exit code 2. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Fixes the Chrome Web Store upload error "No manifest found in package. Please make sure to put manifest.json at the root directory of the zip package." — and shrinks the upload from 333 KB → 101 KB (3.3× smaller) while we're at it.
Why we hit the error
Two ways to land in this state:
dist/in Finder / Explorer → Compress produces a zip with adist/wrapper, so the store seesdist/manifest.jsonand notmanifest.json. Rejected.npm run zip, the previous script shipped:*.map, ~70% of the bundle weight)__MACOSX/,.DS_Store) when zipped on a macOS dev boxSource maps don't break the upload but they leak source and bloat the package; macOS metadata occasionally trips Web Store validation.
What this PR changes
scripts/zip-extension.mjs:*.map,.DS_Store,__MACOSX/by default. PassINCLUDE_SOURCEMAPS=1 npm run zipto opt back in (handy for debugging a sideloaded build).dist/manifest.jsonis missing.unzip -p outzip manifest.json(with a PowerShellSystem.IO.Compressionfallback for Windows) to assertmanifest.jsonexists at the root. If not, exits with code 2 and a descriptive error.README.md:INCLUDE_SOURCEMAPS=1env var.Verification
npm run zip*.mapINCLUDE_SOURCEMAPS=1 npm run zipdist/wrapper (Finder repro)manifest.jsonaccidentally missing fromdist/npm run validateManifest at root, no source maps, no macOS junk, 23 clean files. Ready for the store.
Test plan
npm run zipproduces a 101 KB zip withmanifest.jsonat root and no*.mapfilesINCLUDE_SOURCEMAPS=1 npm run zipproduces a 333 KB zip with maps includedzip -r bad.zip dist) is rejected by the verification guardnpm run validatepasses (84 tests, lint, format, typecheck)Made with Cursor