Skip to content

Automatically add Svelte component libraries to ssr.noExternal #904

Closed
@Rich-Harris

Description

@Rich-Harris

Is your feature request related to a problem? Please describe.
Vite will exclude many node_modules packages from the SSR bundle it generates, using a set of heuristics. While they're subject to change, those heuristics typically exclude Svelte component libraries from the bundle, and so we need to explicitly add them to ssr.noExternal, as in #806 or the kit.svelte.dev config.

Describe the solution you'd like
A convention exists for declaring a package to be a component library — pkg.svelte. It's not used universally (e.g. Svelte GL and site-kit don't use it, which I was slightly surprised about. not sure what i was thinking) but with #518 we can make it more of a standard.

We could forcibly add packages with a pkg.svelte to ssr.noExternal, in addition to any values the user may have specified. This would reduce the number of bugs along the lines of #806.

Relatedly, I can't remember the reason we added the current ssr.noExternal block to the template...

vite: {
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
}
...but its presence feels like a design failure, and I think we should remove it and try and solve whatever issues arise a different way (by having adapters create their own single file bundles if appropriate, etc).

Describe alternatives you've considered
Solve it with documentation. We could also force devDependencies to always be bundled rather than dependencies, and expect people to understand the difference.

How important is this feature to you?
Not solving this one way or another is going to cause people to get mad at us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions