Provide ability to bundle dev dependencies for Node adapter
See original GitHub issueDescribe the problem
Currently, the Node adapter will not bundle any external server side dependencies. This means that you need to make all of the dependencies you might need at runtime be prod dependencies. This differs from its (recent) previous behavior, and from Sapper’s behavior, and from (I would argue) expected behavior.
Until now, it’s been standard operating procedure to bundle as many of the server-side dependencies as possible, to reduce the deployed app size, parse time, and startup time. If there’s some good reason to stop doing this, it should certainly at least be documented.
This issue may also well apply to other adapters (other than the static one), but I haven’t tried to validate that.
Describe the proposed solution
I’m not entirely sure. It would be nice to be able to provide sensible default Vite configuration so that we have Vite do it, rather than do this in a separate esbuild step afterwards (either automatically or manually).
I don’t know whether some different behavior from Vite would make this easier on our end, or whether this is something that Vite ought to change.
Below, I describe what I’m currently doing in userland to deal with this, but I’m not positive that this would have an equivalent in-framework analogue. (Do we have convenient access to the user’s project’s package.json
?)
Alternatives considered
Currently, I have a vite.ssr.noExternal
setting of process.env.NODE_ENV === "development" ? undefined : Object.keys(pkg.devDependencies)
(where pkg
is the parsed JSON from package.json
) to force Vite to bundle all of my dev dependencies.
The check for development vs prod mode is there because I was having an issue using Object.keys(pkg.devDependencies)
in dev mode that I haven’t fully tracked down or tried to reproduce in a minimal repo, but which seem to stem from having a CJS-only dependency that Vite doesn’t try to convert to ESM during dev mode.
Importance
would make my life easier
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:21 (9 by maintainers)
This should be good to go now in
1.0.0-next.88
of the Node adapter. When you update, you should remove any workarounds you added for this issue, including myssr
Vite config and including adding SvelteKit’s runtime dependencies as direct prod dependencies of your app.I think the process of build need to add adapter node dependencies in production. It’ very confusing if every time this dependencies was changed, we would need to start the app in production to discover that some packages is not there.