Commit 1e9cdcf
committed
What was actually happening: prepublish.sh (cp -r dist/src/* .) copies compiled TypeScript — including *.test.js files — into the root-level preprocessor/, parser/, and ast/
directories. Vitest found and ran these compiled test files alongside the TypeScript ones. The compiled preprocessor/preprocessor.test.js imported GlslSyntaxError from ../error.js
(root-level compiled), but buildPreprocessorParser dynamically imported preprocessor/index.js which was resolved by Vite's TypeScript-aware resolver to src/preprocessor/index.ts →
src/error.ts. Two different class instances → instanceof failed.
Two fixes applied:
1. vite.config.ts: Added include: ['src/**/*.test.ts'] so Vitest only runs the canonical TypeScript test files in src/, ignoring compiled JS copies elsewhere.
2. prepublish.sh: Added cleanup to delete *.test.js and *.test.d.ts from published directories — test files don't belong in the npm package and cause this discovery problem.1 parent c92f0f3 commit 1e9cdcf
2 files changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
0 commit comments