/** * Lane J — lets node run the repo's extension-less TS imports directly. * * The house test style (see paint/coverage-math.test.ts) imports './thing' with * no extension, which is what tsc's "bundler" resolution and vite both want but * which node's ESM resolver rejects outright. This registers a resolve hook that * retries a bare relative specifier as `.ts`, so: * * node --experimental-strip-types --import ./src/editor/node-ts-resolve.mjs \ * src/editor/manifest-io.test.ts * * Plain .mjs on purpose: tsconfig only compiles .ts, and nothing imports this * file, so it never reaches tsc or the vite bundle. */ import { registerHooks } from 'node:module' registerHooks({ resolve(specifier, context, next) { try { return next(specifier, context) } catch (err) { if (specifier.startsWith('.') && !/\.[a-z]+$/i.test(specifier)) { try { return next(specifier + '.ts', context) } catch { // '../machine' style directory imports resolve to their index.ts return next(specifier + '/index.ts', context) } } throw err } }, })