-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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: respect resolve.conditions
during nodeResolve
#13487
Conversation
…uired for "react-server" components
Run & review this pull request in StackBlitz Codeflow. |
resolve.conditions
during nodeResolve
resolve.conditions
during nodeResolve
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.
We can try this during the 4.4 beta. @sapphi-red, I recall you stating this was good for you too. I'll run ecosystem-ci for reference, don't worry about the fails, we have several projects CIs to work out before the 4.4 release.
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Same failures in ecosystem-ci as in main |
I have one thing that I want to discuss before merging this PR. Is it fine to use IIUC https://discord.com/channels/804011606160703521/1097227364846534656/1098923455656759386 |
Maybe |
Thanks @sapphi-red. I forgot about the discussion about I added the PR to the team board so we get to it if don't manage to merge it before Thursday. It would be good to merge this in 4.4, we could add it as experimental if needed. |
For example, if you have
If the option is named |
Thanks for the write up @sapphi-red! I agree with you then we better call it b and c could be interesting if we end up adding other resolve options for |
But I think we want it to apply to both. Whatever usual resolution steps need to happen (even for bundled stuff) should be resolved with these conditions . I can choose to not externalize a dependency and that should also respect resolve.conditions. I am assuming some vite plug-in is doing that coz I think I saw a PR related to that |
IIRC if the file isn't externalized, I think we need two options here.
Because using Having |
Yeah I think I agree with sapphi here, we need to create In the future, maybe we can use |
Makes sense to me. Better to be explicit for all three cases im understanding: resolve.conditions: non-SSR Any guidance on where the other parts will be implemented. Should I update this PR to handle these? |
For example,
Yeah, maybe. If we use that, users will need to run Vite with
vite/packages/vite/src/node/plugins/resolve.ts Lines 1086 to 1120 in 711dd80
I think we can split implementing |
Just to be sure, this is actually the function I wanted my passed conditions to go to. Will that be |
Ah. If the function is called from |
Just found this issue after being stuck on trying to get Looking forward to seeing this fix merged! |
Use experimental node loaders when launching the RSC FE Server This is all done to try to make loading of 3rd party modules work. Specifically have been experimenting with the `server-only` package. In the end it turned out that it's not working because there's a bug/missing feature in Vite vitejs/vite#13487
By configuring `noExternal` for the server side build correctly we now support using npm modules with client side only React components, i.e. components with `'use client'` at the top of the file. Currently you have to patch vite for this to work. Still waiting for vitejs/vite#13487 to be merged.
This is needed until vitejs/vite#13487 is merged and released and RW uses that new version of Vite
I'll close this in favour of #14498 |
Description
Respect user's
resolve.conditions
while doing the internal node resolve. This is required by "react-server" components. They need the internal node resolve to also use the "react-server" condition. I am passing it in the vite config but its not being used by thenodeResolve
function. This adds it to the override conditions, so its used by the nodeResolve function.Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).