fix(build): postinstall script patches flowbite-svelte TypeScript optional params

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>
This commit is contained in:
Scott Idem
2026-06-22 18:33:53 -04:00
parent 99c4934045
commit 9c30d4618a
3 changed files with 436 additions and 315 deletions

View File

@@ -21,7 +21,8 @@
"build:docker:dev": "docker compose -f ../aether_container_env/docker-compose.yml build ae_app && docker compose -f ../aether_container_env/docker-compose.yml up -d ae_app",
"compose:down": "docker compose -f ../aether_container_env/docker-compose.yml --profile database down",
"deploy:remote:test": "ssh linode.oneskyit.com 'bash /srv/env/test_aether/deploy.sh test'",
"deploy:remote:prod": "ssh linode.oneskyit.com 'bash /srv/env/prod_aether/deploy.sh prod'"
"deploy:remote:prod": "ssh linode.oneskyit.com 'bash /srv/env/prod_aether/deploy.sh prod'",
"postinstall": "node scripts/postinstall.mjs"
},
"devDependencies": {
"@eslint/js": "9.39.4",
@@ -108,7 +109,7 @@
"@tailwindcss/vite": "^4.3.0",
"dayjs": "^1.11.10",
"dexie": "^4.0.0",
"flowbite-svelte": "1.31.0",
"flowbite-svelte": "1.33.1",
"html5-qrcode": "^2.3.8",
"marked": "17.0.6",
"openai": "^6.10.0",