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
Monorepo project dedupes dependencies even when not specified #9948
Comments
Most likely related to an issue that didn't have reproduction #8440 |
This seems related to the package manager more than Vite? |
I don’t think so. I already reproduced it with 2 different package managers (pnpm and yarn 3), the first two I tried. This issue might also be related to #3254 |
I added rollup as a counterexample. It handles two different package versions just fine. Can someone confirm this is a bug? I can try to work on that |
This might be fixed by #11410, which I'm working on rebasing it. |
Just wanted to pop in and confirm I'm seeing the same issue. Seems like bluwy is working on it though :) Here is a summary of my pnpm workspace's packages dependencies. If I need to make a reproduction repo I can
When running Expectation: In Actual: Whatever version of Note: This only happens in dev mode. When I run |
Hi, I'm currently running into this issue! Is there a workaround or solution in the meantime that hasn't been mentioned here? I'm not sure what the status of the fix is, but the linked MR has been closed and no new ones are linked so I can't easily follow up elsewhere |
Sorry, I haven't finished it up since I last worked on that. The whole code path to deduplicate the packages turned out to be harder than expected if we want to preserve the performance. At the moment, I think this can be workaround (following gdosherjc's comment) with something like: optimizeDeps: {
include: [
'subPackageA > somePackage'
'subPackageB > somePackage'
]
} So it keeps two reference. I have not tested this though. |
I think I'm also running into this same issue. In my case, I'm trying to migrate to @tanstack/react-query@5 from v4. I couldn't get the workarounds working at all, though it may be me not quite understanding how the ">" character is being interpreted here. I've made a monorepo package called "@shared/query" which reexports the api from react-query. I've tried the following but nothing changed: optimizeDeps: {
exclude: ["@shared/query > @tanstack/react-query"]
} Maybe I'm doing something wrong... 🤷 The workaround that did work was to rename the dependency itself, which you can do with {
"new-tanstack-react-query": "npm:@tanstack/react-query@5.13.4",
} Then you just need to update references to |
Describe the bug
I am using a monorepo package and an app consuming it. They both use different versions of a dependency
Vite uses the version specified in app, even when importing it from the internal package
I expect Vite to use version of a package that is specified in internal package's package.json for the package and the version in app's package.json for app code (not the package code)
For me personally it happens with yarn 3, but I reproduced it on stackblitz using pnpm
To represent the issue I used:
nanoid@2.0.0 for package that is using default export
nanoid@3.0.0 for app that is using named export
Reproduction
https://stackblitz.com/edit/github-zdg7ym-1hbqbp?file=package%2Findex.jsx
System Info
Used Package Manager
yarn
Logs
Click to expand!
Error in browser ```shell Uncaught SyntaxError: import not found: default ```Validations
The text was updated successfully, but these errors were encountered: