1import { defineConfig } from 'vite';
2import { resolve } from 'node:path';
4// numbl is a local `file:` dependency, so node_modules/numbl is a symlink to
5// the sibling checkout. Its package `exports` map only publishes the runtime
6// entry points, not the compiler internals we need (parser + JIT lowering), so
7// we reach them through a path alias — the same arrangement turing-surface
8// uses, and documented there in src/mgpu/numbl.d.ts.
9const numblSrc = resolve(import.meta.dirname, 'node_modules/numbl/src');
11export default defineConfig({
12 base: './',
13 resolve: {
14 alias: { 'numbl-src': numblSrc },
15 // Without this, the dev server canonicalizes the symlink for SOME import
16 // chains (`/@fs/<realpath>?v=...`) but not others (raw absolute paths),
17 // which (a) trips the fs allow list and (b) loads numbl's builtin
18 // registry twice — so the type-rule patches in src/mgpu/patches.ts land
19 // on one instance while the lowerer consults the other. Keeping the
20 // symlinked path everywhere gives every module one canonical URL.
21 preserveSymlinks: true,
22 },
23 server: {
24 // the alias resolves through the symlink; allow both spellings
25 fs: { allow: [import.meta.dirname] },
26 },
27 build: {
28 target: 'es2022',
29 rollupOptions: {
30 input: {
31 main: resolve(import.meta.dirname, 'index.html'),
32 test: resolve(import.meta.dirname, 'test.html'),
33 },
34 },
35 },
36});