-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: vite dev and yarn pnp + vite by unreverting and adding lodash files to optimizeDeps.include #21535
Conversation
I think the core issue here is that vite does not consider absolute paths to be dependencies. So it does not convert them from commonjs to esm. I worry that the yarn pnp changes here of turning many things into absolute paths will break other dependencies as well. Ideally I would like to remove most or all of the I'll try to look into it more soon, but wanted to say that I'm concerned about this change. |
@IanVS well, absolute paths are needed to have pnp support fully.. What should we do here? As-is.. we have a regression where the react-vite framework does not support pnp. This PR fixes that. |
Is this because of the architectural design of Storybook, whereby we pass strings around from one package to another to be imported? @arcanis have you encountered other similar projects that have added yarn pnp support (particularly complex projects like ours)? What ways have they approached it? Is it expected that we should have to resolve node_module imports into absolute paths? If so, do you know what those projects have done to support vite, which will not treat absolute paths as dependencies? Any guidance you can give would be much appreciated here. @ndelangen I'm having a hard time seeing how the changes here would impact the imports of lodash functions, do you have any idea why those changed? |
Yes that's the reason @IanVS |
I am also not sure how the lodash issues popped up after this change. |
@IanVS though it does seem correct that these paths should end with the extention, since this is what we have in the .mjs dist output.. |
I agree, but what confuses me is why Vite isn't handling it automatically like every other dep. I'll go ahead and approve so we can move forward, but when I have some time I want to figure out what's really going on, and maybe we can talk about ways that we can try to avoid absolute imports in the future. |
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.
I'm confused why wrapForPnP
needs to be defined locally in each file, but I guess it has something to do with the monkeypatching that pnp.cjs is doing to require
.
I do like that this gives us a clear string to grep for if we ever find another way to handle these.
The the wrapForPnP must be in each file, because it calls |
Closes #21523 (comment) #21548
Related: #21528, #20443, #21527
What I did
I added the wrapForPnP code back and added the extra optimizeDeps.include entries
How to test
yarn start
should work