-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe 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