Closed IlyaSemenov closed 1 year ago
Wow, took me a long time to figure out what was triggering this but I finally tracked it down to vite-tsconfig-paths
. Have you figured out a work around?
Best solution would be to wrap each tsconfck
parse call with its own try-catch so the process doesn't crash. PR welcome
Thanks for the quick reply!
I seem to have gotten things working with the following:
tsConfigPaths({ projects: ['./', '../../packages/db'] })
Will report back if I discover any issues that bubble up with that approach.
Hello, I have a related issue! 😄
I'm in a monorepo containing "disconnected" packages with their own yarn.lock
, and I don't want to install their dependency when in dev. But when using Vitest + vite-tsconfig-paths to run my tests, vite-tsconfig-paths is attempting to load all the tsconfig.json
of the monorepo, which fails because I extend configurations from @tsconfig/node-lts-strictest-esm
which isn't installed:
TSConfckParseError: failed to resolve "extends":"@tsconfig/node-lts-strictest-esm/tsconfig.json" in /Users/jgoux/Documents/code/snaplet/packages/cli/tsconfig.json
at resolveExtends (/Users/jgoux/Documents/code/snaplet/node_modules/tsconfck/dist/index.cjs:539:9)
at parseExtends (/Users/jgoux/Documents/code/snaplet/node_modules/tsconfck/dist/index.cjs:493:28)
... 5 lines matching cause stack trace ...
at async _createServer (file:///Users/jgoux/Documents/code/snaplet/node_modules/vite/dist/node/chunks/dep-a36bfc56.js:63161:20)
at async createVitest (file:///Users/jgoux/Documents/code/snaplet/node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:14365:18)
at async startVitest (file:///Users/jgoux/Documents/code/snaplet/node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:20757:15) {
code: 'EXTENDS_RESOLVE',
cause: Error: Cannot find module '@tsconfig/node-lts-strictest-esm/tsconfig.json/tsconfig.json'
Require stack:
- /Users/jgoux/Documents/code/snaplet/packages/cli/tsconfig.json
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at Function.resolve (node:internal/modules/cjs/helpers:116:19)
at resolveExtends (/Users/jgoux/Documents/code/snaplet/node_modules/tsconfck/dist/index.cjs:534:53)
at parseExtends (/Users/jgoux/Documents/code/snaplet/node_modules/tsconfck/dist/index.cjs:493:28)
at Object.parse (/Users/jgoux/Documents/code/snaplet/node_modules/tsconfck/dist/index.cjs:431:24)
at async Promise.all (index 4)
at async configResolved (/Users/jgoux/Documents/code/snaplet/node_modules/vite-tsconfig-paths/dist/index.js:124:9)
at async Promise.all (index 0)
at async resolveConfig (file:///Users/jgoux/Documents/code/snaplet/node_modules/vite/dist/node/chunks/dep-a36bfc56.js:64138:5)
at async _createServer (file:///Users/jgoux/Documents/code/snaplet/node_modules/vite/dist/node/chunks/dep-a36bfc56.js:63161:20) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/jgoux/Documents/code/snaplet/packages/cli/tsconfig.json'
]
},
tsconfigFile: '/Users/jgoux/Documents/code/snaplet/packages/cli/tsconfig.json'
}
vite-tsconfig-paths crashes in a monorepo where one package uses vite-tsconfig-paths, and the other package has invalid tsconfig.json (even if the two packages are unrelated and don't refer to each other in any way).
This kind of setup occurs when a monorepo is used to build a particular micro service, and one of the (unused) sibling packages uses build-time generated tsconfig.json (in my case, that is a Nuxt.js app).
Reproduction
https://stackblitz.com/edit/node-wpwtp3
Run:
Expected result
The test runs normally.
Actual result
Even though
api
package doesn't refer toweb
package in any away,web/tsconfig.json
is being loaded, parsed, and vite crashes: