flowbite-svelte ships TypeScript optional-param syntax (x?: string, event?: MouseEvent,
date?: Date) in its dist .svelte files. Vite's esbuild dep pre-bundler processes these
files (via dist/*/index.js re-exports) and fails with "Unexpected '?'" parse errors
whenever the lockfile changes and the dep cache is rebuilt.
- Add scripts/postinstall.mjs: patches 4 specific TypeScript signatures in
CommandPalette.svelte, ScrollSpy.svelte, and Datepicker.svelte after every npm install.
Patches are idempotent and targeted — only the ?-in-param-position syntax is removed;
optional-chaining (?.) in function bodies is untouched.
- Add "postinstall" script to package.json to run it automatically.
- Upgrade flowbite-svelte 1.31.0 → 1.33.1 (both have the same issue; 1.33.1 is current).
- npm update now works without breaking the dev server.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>