-
-
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: SSR deep imports externalization (fixes #8420) #8421
Conversation
Tested SvelteKit and it is building after: We'll need to add later a .css dep in ssr test case in our CI |
// check ext before externalizing - only externalize | ||
// extension-less imports and explicit .js imports | ||
if (resolvedExt && !resolved.id.match(/(.js|.mjs|.cjs)$/)) { | ||
return |
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.
Is this meant to be return resolved
?
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.
No, it should return undefined. The only way this code is reached is when called to test if it should be externalized here. I should have added a comment there
true // try to externalize, will return undefined if not possible |
Once this returns undefined, the second tryNodeResolve in the resolve plugin will already have
externalize
false so it wont reach the branch. This is quite confusing though. It was done as part of a refactoring that tried to not change too much of the current structure. Now that we know the new SSR externals logic is working, we should do another refactoring to clean up and avoid the need to calling tryNodeResolve twice (the ssr check is cached, so it is only duplicated the first time but still)
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.
Oh wow that is very confusing, haha 😆
Description
Fixes the error reported by @benmccann here #8420
But after this fix, SvelteKit is still not building as there is an issue with .css imports
We can still merge this one while we work on the other issue.
What is the purpose of this pull request?