-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CJS dependencies are not being pre-bundled #7241
Comments
I changed gboost-ui to have a peerDependency of aws-amplify hoping that would fix it since Vite wouldn't have to find nested CJS dependency since it's installed directly in project but that didn't work. |
Issue is resolved for npm installation by adding this
However, this still doesn't work for PNPM as I get: |
I'm stuck at trying to get this to work with PNPM. I got through the first couple errors but I cannot resolve:
|
Not happy with it, but I had to shamefully hoist. Repo shows working state: https://github.com/bestickley/vite-gboost-ui-error |
I'm still confused why it works when locally linking the package. If anyone has an answer, please comment! |
This looks like a similar issue as #3910. It seems that Of course, I could be wrong too as I'm not using React a lot. |
@bluwy, thank you so much for your insight. This explains everything. |
Describe the bug
I've got an example Vite app here that has an ESM library, gboost-ui, which has CJS dependencies and peerDependencies which are CJS. When I run
pnpm dev
I get an error in the browser:The requested module '/node_modules/.pnpm/[email protected]/node_modules/prop-types/index.js?v=f8148f89' does not provide an export named 'default'
. So I try addingprop-types
tooptimizeDeps.include
but then I get:The requested module '/@fs/Users/stickb/Code/scratch/tdmp-edge-mgmt-ui/node_modules/.pnpm/[email protected]/node_modules/zen-observable/index.js?v=2906f0d0' does not provide an export named 'default'
. so I addzen-observable
tooptimizeDeps.includes
. But thenUncaught SyntaxError: The requested module '/@fs/Users/stickb/Code/scratch/tdmp-edge-mgmt-ui/node_modules/.pnpm/[email protected]/node_modules/url/url.js?v=f14ea013' does not provide an export named 'format'
and so forth. I think this is happening for all CJS dependencies gboost-ui imports. Why isn't vite pre-bundling these dependencies?Strangely, if I clone gboost-ui and run
pnpm add ../../path/to/gboost-ui
it works.I saw the issue: #3024 where it says:
So I tried install with npm (since PNPM symlinks) but that didn't work either :/
Reproduction
https://github.com/bestickley/vite-gboost-ui-error
System Info
Used Package Manager
pnpm
Logs
Validations
The text was updated successfully, but these errors were encountered: