-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Vite: Fix react-vite and projects with absolute path preview entries on Windows #21545
Vite: Fix react-vite and projects with absolute path preview entries on Windows #21545
Conversation
import { normalizePath } from 'vite'; | ||
import slash from 'slash'; | ||
|
||
function normalizePath(id: string) { |
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.
This is copied largely from the normalizePath
from vite
, which was used previously in builder-vite.
? { | ||
// TODO: Evaluate if searching for node_modules in a yarn pnp environment is correct | ||
bare: previewFile.includes('node_modules') | ||
? stripAbsNodeModulesPath(previewFile) |
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.
It's unfortunate that this is necessary, but it is caused by #21197 (comment) in all projects but also could happen if the user specifies addons in their main.js using absolute paths (for yarn pnp, for instance).
I would love to find a way to avoid so many absolute paths, but it seems like for now at least it's what we are stuck with.
Note that windows will likely still break if the user specifies absolute paths to non-node_modules files, but I don't think that should not be supported anyway (I can't think of a reason it would be needed, at least).
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.
In a pnp situation, the path won't include node_modules
.
7c38ee5
to
c939bbb
Compare
Co-authored-by: Ian VanSchooten <[email protected]>
c939bbb
to
267df02
Compare
I don't think this is a bug fix only for vite sandboxes, but rather any vite react project in Windows. I would love to get it fixed ASAP. @ndelangen do you have a suggestion for how to handle yarn pnp? If not, I'd like to move forward with this and fix pnp as a second step, since that is a much smaller set of users affected. (side note: I tried for quite a while to get the yarn pnp sandbox to work, so I could experiment, but was not successful) |
Closes N/A
What I did
Fix vite-react-sandbox development on Windows machines
How to test
yarn task --task sandbox --start-from auto --template react-vite/default-ts
on a Windows machine. Storybook should start up properly.Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]