Open History to see the last commit
1import { createRequire } from 'node:module'
2import { dirname, join } from 'node:path'
3import { defineConfig } from 'vite'
4import { tanstackStart } from '@tanstack/react-start/plugin/vite'
5import { nitro } from 'nitro/vite'
6import viteReact from '@vitejs/plugin-react'
7import tailwindcss from '@tailwindcss/vite'
8
9const require = createRequire(import.meta.url)
10const reactorWasmJs = join(
11 dirname(require.resolve('@reactor-team/js-sdk')),
12 'wasm/reactor_wasm.js',
13)
14
15export default defineConfig({
16 resolve: { tsconfigPaths: true },
17 optimizeDeps: {
18 // The SDK loads wasm with a relative `import('./wasm/reactor_wasm.js')`
19 // marked `@vite-ignore`. Pre-bundling moves the JS and that import 404s.
20 exclude: ['@reactor-team/js-sdk', '@sparkjsdev/spark'],
21 // Nested CJS deps of the excluded ESM package. Without this, the browser
22 // loads awaitqueue as raw CJS and `import { AwaitQueue }` fails.
23 include: ['awaitqueue', '@reactor-team/js-sdk > awaitqueue'],
24 },
25 assetsInclude: ['**/*.wasm'],
26 ssr: {
27 external: ['@reactor-team/js-sdk', '@sparkjsdev/spark', 'three'],
28 },
29 plugins: [
30 {
31 name: 'reactor-wasm',
32 resolveId(id) {
33 if (id === './wasm/reactor_wasm.js') return reactorWasmJs
34 return undefined
35 },
36 },
37 tailwindcss(),
38 tanstackStart(),
39 nitro(),
40 viteReact(),
41 ],
42 nitro: {},
43})