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
We maintain a internal React library/package that we would like to distribute unbundled, shipping the original .tsx/.jsx source. My goal is for consuming apps to import this package from node_modules and let Vite handle the full compile/transpile process as if it were local code in the app’s src/.
Currently, Vite typically excludes node_modules from the same transformation pipeline used for local source. This leads to issues such as:
Difficult-to-diagnose errors, such as Uncaught ReferenceError: Cannot access 'MyComponent' before initialization (which might hint at circular dependency issues, even though the code appears to be initialize variables properly).
Having to manually configure optimizeDeps.include and/or @vitejs/plugin-reactinclude patterns to process node_modules/my-unbundled-lib/**/*.{ts,tsx,jsx}, which can be cumbersome.
Potential peer dependency or React version mismatch issues when raw code in node_modules expects transforms that Vite doesn’t apply by default.
I’d love a simpler or more “official” way to mark a package in node_modules as “local/uncompiled source” so that Vite automatically transpiles it exactly like code in src/. This might be some config flag or a documented pattern in vite.config.js.
Use Case / Motivation
We don’t want to deal with bundling our library code at all. This is an internal company library, and we prefer to ship raw .tsx/.jsx so each project can handle its own build pipeline, tree-shaking, and advanced transforms.
By shipping raw code, we avoid extra bundling steps and keep everything consistent with our app’s build environment.
However, the default Vite behavior—where node_modules is excluded from local-like transformations—causes multiple issues that aren’t straightforward to debug.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We maintain a internal React library/package that we would like to distribute unbundled, shipping the original
.tsx/.jsx
source. My goal is for consuming apps to import this package fromnode_modules
and let Vite handle the full compile/transpile process as if it were local code in the app’ssrc/
.Currently, Vite typically excludes
node_modules
from the same transformation pipeline used for local source. This leads to issues such as:Uncaught ReferenceError: Cannot access 'MyComponent' before initialization
(which might hint at circular dependency issues, even though the code appears to be initialize variables properly).optimizeDeps.include
and/or@vitejs/plugin-react
include
patterns to processnode_modules/my-unbundled-lib/**/*.{ts,tsx,jsx}
, which can be cumbersome.node_modules
expects transforms that Vite doesn’t apply by default.I’d love a simpler or more “official” way to mark a package in
node_modules
as “local/uncompiled source” so that Vite automatically transpiles it exactly like code insrc/
. This might be some config flag or a documented pattern invite.config.js
.Use Case / Motivation
.tsx/.jsx
so each project can handle its own build pipeline, tree-shaking, and advanced transforms.node_modules
is excluded from local-like transformations—causes multiple issues that aren’t straightforward to debug.An example user story:
npm install my-unbundled-library
Beta Was this translation helpful? Give feedback.
All reactions