-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
fix(optimizer): use correct default install state path for yarn PnP #19119
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. It's also showing up as install-state.gz
for me.
Maybe it's also possible for us to use a different file to detect? From https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored, we could also use
Ideally I think we should support all versions if it's not too hard to do so. Otherwise I think it's also fine for Vite to not support very old package managers. We don't really test against or track compatibility with different package managers. |
Hi @bluwy ,
I have applied your suggestion to check for .pnp.cjs/.pnp.js file so we don't need to deal with custom installStatePath
It's not hard to add for .pnp.js for yarn v2 this time (https://yarnpkg.com/advanced/changelog#breaking-changes), but the order of files gets checked matters. .pnp.js should be checked after but not before checking the existence of .pnp.cjs https://yarnpkg.com/advanced/changelog#major-changes as the old file is not removed when updating yarn. Otherwise vite will never re-run the pre-bundle step if the unused file gets left on the disk after upgrading yarn from 2 directly to 4. However I think probably in next major version release of vite we can specify supported package managers versions through |
I guess the failing test is flaky, need to rerun. |
Switched back to calling yarn to get installStatePath, and if yarn is not installed will use default installStatePath location |
Is there a reason to switch back to that. I don't think we can afford calling
I don't think we should worry about this. Shouldn't the user remove the If all else doesn't work, I think we can fallback to |
@bluwy Reverted back to using .pnp.js/.pnp.cjs file. |
Fix #19118 for the yarn's default config. Main reason is if it can't find the file, it will use empty string to generate the hash, causing the result to be the same every time.
For yarn's custom config https://yarnpkg.com/configuration/yarnrc#installStatePath we probably need a different PR.
Also are we still going to support yarn 2.4 for optimize deps? Do we have a compatibility chart for vite version vs different package manger's version?
https://github.com/yarnpkg/berry/blob/93a56643ba3c813a87920dcf75c644eaf3b38e6f/CHANGELOG.md?plain=1#L392