concept-collection / dulcimer
dulcimer / vite.config.ts
28 lines · 1.1 KBBlameHistoryRaw
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 — the same arrangement
9// acoustic-scattering-2d and math-webgpu-sandbox use.
10// Realpath'd through the symlink: dev serves modules under their real ids, so
11// aliasing the node_modules path would give the same file two identities (one
12// per spelling) and run its side effects twice — the interpreter's builtin
13// registry throws on the second.
14const numblSrc = realpathSync(resolve(import.meta.dirname, 'node_modules/numbl/src'));
16export default defineConfig({
17 base: './',
18 resolve: {
19 alias: { 'numbl-src': numblSrc },
20 },
21 server: {
22 // the alias resolves outside the project root (through the symlink)
23 fs: { allow: [import.meta.dirname, numblSrc] },
24 },
25 build: {
26 target: 'es2022',
27 },
28});