da63b6122caf
fix Codex generation — bwip-js not bundled due to @vite-ignore on dynamic import (v3.6.55)
- time
- 2026-05-20 02:14 UTC · 5 months ago
- machine
- koh2
- parent
- 805ccac4d45e
↓ peach-browser-da63b612.tar.gzatlas at this save
files changed3 files
manifest.firefox.json+1 −1manifest.json+1 −1src/popup/codex/aztec.ts+16 −6manifest.firefox.json+1 −1
@@ -2,7 +2,7 @@22 "_comment_audio_capture": "Firefox does not honor the Chrome 'audioCapture' optional_permission — getUserMedia in WebExtensions is gated solely by the runtime permission prompt. Microphone access for chirp pairing works from the popup under the existing '<all_urls>' host permission; no manifest entry is required or accepted here.",33 "manifest_version": 3,44 "name": "Peach",5- "version": "3.6.54",5+ "version": "3.6.55",66 "description": "Zero-knowledge password manager",77 "browser_specific_settings": {88 "gecko": {manifest.json+1 −1
@@ -1,7 +1,7 @@11 {22 "manifest_version": 3,33 "name": "Peach",4- "version": "3.6.54",4+ "version": "3.6.55",55 "description": "Zero-knowledge password manager",66 "action": {77 "default_popup": "src/popup/index.html",src/popup/codex/aztec.ts+16 −6
@@ -73,12 +73,22 @@7373 }7474 const isBrowser = typeof OffscreenCanvas !== "undefined";7575 76- // Pick the entrypoint explicitly. Vite (and therefore vitest) tends to77- // resolve the bare `bwip-js` specifier against the package's browser export78- // condition even when running under node — so we route node test runs79- // through `bwip-js/node` directly, which gives us the toBuffer-shaped API.80- const spec = isBrowser ? "bwip-js" : "bwip-js" + "/node";81- const ns = (await import(/* @vite-ignore */ spec)) as Record<string, unknown>;76+ // Two separate import() calls so Rolldown code-splits the browser entry77+ // into a real chunk (making the URL resolvable at runtime in the extension),78+ // while keeping @vite-ignore on the test-only node path to prevent Rolldown79+ // from trying to bundle node:zlib into the browser build.80+ let ns: Record<string, unknown>;81+ if (isBrowser) {82+ // bwip-js exports types under the "browser" condition only — tsc can't83+ // resolve them with moduleResolution:"bundler". The runtime behavior is84+ // correct; the cast below enforces our own interface.85+ // @ts-expect-error — no top-level types entry in bwip-js package.json exports86+ ns = (await import("bwip-js")) as Record<string, unknown>;87+ } else {88+ // vitest / node only — bwip-js/node uses node:zlib which can't bundle for browser.89+ ns = (await import(/* @vite-ignore */ "bwip-js/node")) as Record<string, unknown>;90+ }91+8292 const defaultExport = ns["default"] as Record<string, unknown> | undefined;8393 // ESM dynamic import surface differs between the two builds: the browser8494 // bundle exports `toCanvas` as a named export, while the node bundle is