-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: update SSR externals only when SSR is enabled (fix #6478) #6492
Merged
patak-dev
merged 2 commits into
vitejs:main
from
vursen:fix/dont-resove-ssr-externals-when-disabled
Jan 26, 2022
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
ssr
param inrerun
is what indicates if the server is running in ssr mode. @bluwy could you confirm this, I see that you approved this oneThere 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.
Actually, I'm not sure if they are entirely interchangeable and will work exactly the same way. As far as I get this,
tryNodeResolve
is the only invoker ofregisterMissing
. An important detail abouttryNodeResolve
is that this function is not always called withssr === true
even when SSR is enabled. See howssrModuleLoader
callstryNodeResolve
as an example:vite/packages/vite/src/node/ssr/ssrModuleLoader.ts
Line 222 in e6495f0
I don't know 100% how it is intended to work since there are no tests so I just tried to be as close to the original implementation as possible.
Maybe it will be indeed sufficient to call
resolveSSRExternal
only depending on thessr
param. I would just like to get an additional confirmation before updating this place.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.
@aleclarson could you help us checking this one?
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.
My bad. I think you're right @patak-dev, that slipped off my mind. @vursen regarding your concern, that seems like it should be a
true
instead, I'm not sure why it's false since it's used by hookNodeResolve. But yes, we do lack tests for this case, and @aleclarson may know more about it.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.
The
ssr
argument is actually undefined in the call above, not false. The false value is for thetargetWeb
argument. :)I think we can use
ssr
instead ofserver.config.ssr
(as suggested by @patak-dev), since thetryNodeResolve
call will be removed in #6591.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.
OK, updated this line. Please, take a look.