You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vite introduced ModuleRunner recently, which is specifically useful for using vite with the option --configLoader runner so it can load .ts config files. I am, for example, using this approach to define a shared vite config from a package in a monorepo.
Now, with vitest's monorepo / project setup, it would be very helpful to load .ts config files from a sub-package using this approach, mainly because by default projects within a vitest workspace do not inherit all configurations but must be extended by a shared config (as per your documentation).
I like this design decision a lot, but having a shared config file in a monorepo is best done by defining it in a package that can be consumed by other packages.
Suggested solution
Allow vitest to load .ts files the same way vite can with the --configLoader runner flag. Or allow importing .ts files into vitest config files another way. An ideal config would look something like this:
import{defineProject,mergeConfig}from'vitest/config';importvitestConfigReactfrom'@my-monorepo/vitest-config/react-base';// Note: This uses vitest's `defineProject`, not `defineConfig`, as workspace projects don't have all config optionsexportdefaultmergeConfig(vitestConfigReact,defineProject({// ... my per-project-config}));
Alternative
I am not at all fixed on supporting this ModuleRunner thing as I have no clue what the implications to Vitest would be. So any way to support .ts file imports would be great.
I figured you might want to know which errors one would currently get.
When running vitest with a vitest.config.ts file at the monorepo root and a sub-package for the vitest config, an error would look like this:
> vitest
failed to load config from /monorepo/packages/package-a/vitest.config.ts
failed to load config from /monorepo/packages/package-b/vite.config.ts
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
AggregateError: Failed to initialize projects. There were errors during workspace setup. See below for more details.
errors]: [
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /monorepo/packages/vite-config/react.ts
Clear and concise description of the problem
Vite introduced ModuleRunner recently, which is specifically useful for using vite with the option
--configLoader runner
so it can load.ts
config files. I am, for example, using this approach to define a shared vite config from a package in a monorepo.Now, with vitest's monorepo / project setup, it would be very helpful to load .ts config files from a sub-package using this approach, mainly because by default projects within a vitest workspace do not inherit all configurations but must be extended by a shared config (as per your documentation).
I like this design decision a lot, but having a shared config file in a monorepo is best done by defining it in a package that can be consumed by other packages.
Suggested solution
Allow vitest to load
.ts
files the same way vite can with the--configLoader runner
flag. Or allow importing .ts files into vitest config files another way. An ideal config would look something like this:Alternative
I am not at all fixed on supporting this
ModuleRunner
thing as I have no clue what the implications to Vitest would be. So any way to support .ts file imports would be great.Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: