Skip to content
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

Failed to resolve workspace dependency present in 'optimizeDeps.include' #10047

Closed
7 tasks done
tajo opened this issue Sep 9, 2022 · 6 comments
Closed
7 tasks done

Failed to resolve workspace dependency present in 'optimizeDeps.include' #10047

tajo opened this issue Sep 9, 2022 · 6 comments

Comments

@tajo
Copy link
Contributor

tajo commented Sep 9, 2022

Describe the bug

It seems that optimizeDeps.include is able to resolve only dependencies that are defined in the root workspace and its package.json. In other words, you can optimize deps only from a single workspace.

After opening the repro, you will see this warning:

Failed to resolve dependency: jquery, present in 'optimizeDeps.include'

while react gets optimized just fine because it's in the root workspace.

Expectation

optimizeDeps.include should work for all dependencies across multiple workspaces. If these deps can be later resolved and served by Vite anyway I don't see a reason why they couldn't be prebundled as well.

Reproduction

https://stackblitz.com/edit/node-whfueq?file=app%2Fpackage.json

System Info

Stackblitz

Used Package Manager

pnpm

Logs

No response

Validations

@VRuzhentsov
Copy link

Here I found a solution from this guy

in several words - use Vite inside the workspace, not in the root

https://github.com/adiun/vite-monorepo

@tajo
Copy link
Contributor Author

tajo commented Mar 9, 2023

The example doesn't use optimizeDeps (it was removed)?

in several words - use Vite inside the workspace, not in the root
That's the case in my example as well.

@phiberber
Copy link

phiberber commented May 18, 2023

I've the same issue, With the following schema:

Package A:

  • The one running Vite
  • Has and uses B as dependency

Package B:

  • Has as dependency a CJS package called C

When adding C to A's Vite optimizeDeps, Vite says it can't resolve the dependency. The more I see how Vite treats Workspaces, the less I want to use it.

@bluwy
Copy link
Member

bluwy commented Jun 7, 2023

@phiberber Have you tried optimizeDeps.include: ['B > C'] as documented here?

@tajo The warning seems to be correct as you're starting the Vite server with the base set to pkg-a. Vite would then resolve dependencies from the root, which react exists in pkg-a, but not jquery.

@edisonLzy
Copy link

I've the same issue, With the following schema:

Package A:

  • The one running Vite
  • Has and uses B as dependency

Package B:

  • Has as dependency a CJS package called C

When adding C to A's Vite optimizeDeps, Vite says it can't resolve the dependency. The more I see how Vite treats Workspaces, the less I want to use it.

i got this issue too!

@bluwy
Copy link
Member

bluwy commented Sep 17, 2023

Going to close this following my comment above.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants