import { defineConfig } from 'vite'; import { resolve } from 'node:path'; // numbl is a local `file:` dependency, so node_modules/numbl is a symlink to // the sibling checkout. Its package `exports` map only publishes the runtime // entry points, not the compiler internals we need (parser + JIT lowering), so // we reach them through a path alias — the same arrangement turing-surface // uses, and documented there in src/mgpu/numbl.d.ts. const numblSrc = resolve(import.meta.dirname, 'node_modules/numbl/src'); export default defineConfig({ base: './', resolve: { alias: { 'numbl-src': numblSrc }, // Without this, the dev server canonicalizes the symlink for SOME import // chains (`/@fs/?v=...`) but not others (raw absolute paths), // which (a) trips the fs allow list and (b) loads numbl's builtin // registry twice — so the type-rule patches in src/mgpu/patches.ts land // on one instance while the lowerer consults the other. Keeping the // symlinked path everywhere gives every module one canonical URL. preserveSymlinks: true, }, server: { // the alias resolves through the symlink; allow both spellings fs: { allow: [import.meta.dirname] }, }, build: { target: 'es2022', rollupOptions: { input: { main: resolve(import.meta.dirname, 'index.html'), test: resolve(import.meta.dirname, 'test.html'), }, }, }, });