build(vite): alias async-event-store to shim to avoid Vercel resolution error

- Add alias for applesauce-core/dist/event-store/async-event-store.js
- Provide minimal shim module so bundler resolves cleanly
- Use node:path and import.meta.url to build absolute path
- Keep linter strict (added ts-expect-error for node path types)
This commit is contained in:
Gigi
2025-10-07 06:22:54 +01:00
parent 6bf31c124c
commit d3fad33948

View File

@@ -1,5 +1,8 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error Node built-in types may be missing in editor, available at build time
import path from 'node:path'
export default defineConfig({
plugins: [react()],
@@ -10,7 +13,12 @@ export default defineConfig({
extensions: ['.js', '.ts', '.tsx', '.json'],
conditions: ['import', 'module', 'browser', 'default'],
preserveSymlinks: false,
mainFields: ['module', 'jsnext:main', 'jsnext', 'main']
mainFields: ['module', 'jsnext:main', 'jsnext', 'main'],
alias: {
// applesauce-core publishes async-event-store.js in some environments, but exports map can block deep resolution on Vercel
// We don't use the async store; stub it to avoid bundler trying to resolve it
'applesauce-core/dist/event-store/async-event-store.js': path.resolve(new URL('./src/shims/applesauce/async-event-store.js', import.meta.url).pathname)
}
},
optimizeDeps: {
include: ['applesauce-core', 'applesauce-factory', 'applesauce-relay', 'applesauce-react'],