1import { defineConfig } from 'vite';
2import { realpathSync } from 'node:fs';
3import { resolve } from 'node:path';
5// numbl is a local `file:` dependency, so node_modules/numbl is a symlink to
6// the sibling checkout. Its package `exports` map only publishes the runtime
7// entry points, not the compiler internals we need (parser + JIT lowering), so
8// we reach them through a path alias. (package.json's `imports` field cannot
9// express this — Node rejects node_modules targets — and plain Node could not
10// resolve numbl's internal `.js`->`.ts` imports anyway, which is why the GPU
11// tests run in the browser harness rather than under `node`.)
12// Realpath'd through the symlink: dev serves modules under their real ids, so
13// aliasing the node_modules path would give the same file two identities (one
14// per spelling) and run its side effects twice — the interpreter's builtin
15// registry throws on the second.
16const numblSrc = realpathSync(resolve(import.meta.dirname, 'node_modules/numbl/src'));
18export default defineConfig({
19 base: './',
20 resolve: {
21 alias: { 'numbl-src': numblSrc },
22 },
23 server: {
24 // the alias resolves outside the project root (through the symlink)
25 fs: { allow: [import.meta.dirname, numblSrc] },
26 },
27 build: {
28 target: 'es2022',
29 },
30});