-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Make ssr.noExternal
shallow
#8991
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
Comments
It is the other way around. IIUC, in v2 sub-dependencies of some-library will end up being external
This is correct, if a sub-dependency is a direct dependency of your project it will be external, but if not they will be noExternal as node will not be able to resolve to them depending on your setup. What you are proposing here is to keep v2's logic. But as we were discussing in #8983, this is broken if we also don't rewrite imports to resolved node_modules paths that may also break in prod, no? |
Since Potential solution: resolve the import statements in
It means that the user shouldn't modify |
I just tried and it does seem to be as I described. (The VikePress dependency
Yes exactly, see my previous reply. |
I think this isn't difficult to implement now that we do lazy SSR externals/noExternal resolving, maybe it could be optional? |
Or maybe we could use a similar scheme to what @bluwy implemented with optimizeDeps.include: [ 'dep > nested' ] And have ssr.external: [ 'vikepress > tweemoji' ] And even ssr.external: [ 'vikepress > *' ] The global boolean may cause surprises as every other user dep will work as shallow no external too. |
Sounds good. Also maybe: (Btw. the naming |
Yes, maybe it should be |
👍 Also So:
About the portability issue: since we make shallow/deep configurable, it's not a blocker anymore so we're good. |
Re portability, my concern are for setups that publish This could be fixed though if Perhaps this can be implemented as a Vite plugin for now to test it out. |
I wonder if this has a real world use case; I don't know why one would do this. Also when using lock files, which is an increasingly ubiquitous practice, this may actually still work.
Yes I agree and that's why the idea is to support both shallow externalization and deep externalization. Those who need to build before installation can use deep externalization. |
It's the reason why we split |
I see, that makes sense.
Vite only needs to resolve So I still think a lock file works (as long as the package manager produces a |
Description
Current behavior in v2: when an SSR dependency
some-library
isnoExternal
, then Vite will as wellnoExternal
allsome-library
's dependencies.Current behavior in v3 (beta): slightly better because it only
noExternal
dependencies ofsome-libraries
that cannot be resolved. (Correct me if I'm wrong.)Suggested solution
Externalize all
some-library
's dependencies. I.e. only makesome-library
noExternal
.Priority
Low. (Because AFAICT this doesn't cause the same problems than
noExternalize
too many SSR user dependencies.)Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: