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 currently supports monorepo-based setups for application code.
Now, in a monorepo, I want to implement a vite-plugin package in TypeScript that I plan to make use of in other monorepo packages without additional build step.
Right now Vite crashed when trying to load vite.config.ts that imports my plugin.
That happens because all bare imports are externalized during config bundling here:
Vite could check if a package being imported in the config is a local package before externalizing it.
Alternative
UPD: Build step can be avoided on the local vite-plugin package by using an intermediary index.js module that wires up esbuild-register or tsm and then re-exports the actual entry point written in TS.
Additional context
The text was updated successfully, but these errors were encountered:
This sounds like it would open a can of worms, especially if the linked dependency contains transitive dependencies too. Node can't resolve those normally as we would have bundled the linked dependency, unless we bundle everything in the linked dependency, including it's transitive dependencies. Though now, there are two issues: (1) The Vite config would have to bundle a lot every time, (2) Transitive dependencies could be duplicated, causing weird runtime errors. With the reasons, I think it's simpler to have a build step for the linked dependency instead.
And build step can be avoided on the local vite-plugin package by using an intermediary index.js module that wires up esbuild-register or tsm and then re-exports the actual entry point in TS.
Actually I just noticed that we have a duplicate #5370 too proposing the same thing, so perhaps it's something doable within Vite, but let's keep that issue open up as it has more discussion about the feature.
Clear and concise description of the problem
Vite currently supports monorepo-based setups for application code.
Now, in a monorepo, I want to implement a vite-plugin package in TypeScript that I plan to make use of in other monorepo packages without additional build step.
Right now Vite crashed when trying to load
vite.config.ts
that imports my plugin.That happens because all bare imports are externalized during config bundling here:
vite/packages/vite/src/node/config.ts
Lines 776 to 780 in 70536b4
Suggested solution
Vite could check if a package being imported in the config is a local package before externalizing it.
Alternative
UPD: Build step can be avoided on the local vite-plugin package by using an intermediary
index.js
module that wires upesbuild-register
ortsm
and then re-exports the actual entry point written in TS.Additional context
The text was updated successfully, but these errors were encountered: