-
-
Notifications
You must be signed in to change notification settings - Fork 6.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: respect explicitily external/noExternal config #8983
Conversation
✅ Deploy Preview for vite-docs-main canceled.
|
I think we should make |
So |
On a high-level I think we should only Now @bluwy has a point that if VikePress is One way we can solve this is to resolve the CC @benmccann SvelteKit also have the situation that some SSR dependencies need to be |
Why don't make 'vite-plugin-ssr' a peer dependency? Seems like something users should install in their projects. VikePress code doesn't live in |
Ah, yes, sorry it lives in For the |
Why |
I'm not really sure about rewriting imports for externalized deps since it makes the output code not portable, and agree with patak that we could discuss this separately since this feature doesn't exist in Vite 2 too. |
Another note, in v2, |
I just checked and v2 actually does
👍 Seems like a reasonable default.
From my side, yes. (VikePress is a low-key project anyways.) But I think we should check with the SvelteKit folks. (Svelte libraries can contain
👍 #8991. |
@brillout running brillout/vite-3-legacy-build-bug against this PR properly externalizes
Is my understanding correct that after this PR is merged and you update vikepress, CI should be green for vite-plugin-ssr? Let's merge this PR as we should respect users explicit external/noExternal configs independently of any other changes we will propose later. About this, we may still have a bug lurking, but we'll need a different issue and reproduction if this is still a problem:
|
Yes. I'll update the vite-plugin-ssr CI bug reports as soon as there is a new beta release. |
Description
Fixes #8974 when
vite-plugin-ssr
is explicitely configured asssr.external
@brillout following the previous logic, it looks like defining a dependency as
noExternal
wasn't affecting its internal dependencies. Is this what is expected?Imagine if
vite-plugin-ssr
is ESM, when you markvikepress
asnoExternal
, do you expectvite-plugin-ssr
to also benoExternal
?This is how
optimizeDeps.exclude
works, the whole dep tree is excluded according to @bluwy. That is why we need aoptimizeDeps.include: 'entry > sub'
if we want to escape that.We could make
noExternal
work likeoptimizeDeps.exclude
, but I think at least for v3, just making everything external by default is ok. This means that you shouldn't need to explicitly configurevite-plugin-ssr
as external, asnoExternal
only affects a single node imported file and not the imported modules from it. Let me know if this sounds ok to you too.The current code, once this PR is merged should already work like this. But there is another bug at play that prevents
vite-plugin-ssr
to be detected as external. Looks like thistryNodeResolve
call:vite/packages/vite/src/node/ssr/ssrExternal.ts
Line 153 in 5c6cf5a
is failing. @bluwy saw that it is working if
vite-plugin-ssr
is also installed as an entry.I'm working on a refactoring, I think we should directly check do the external/noExternal logic inside
tryNodeResolve
. Pushing this PR to keep the conversation going in the mean time.What is the purpose of this pull request?