-
When I build my sveltekit project with adapter-node, I realize that the contents of the node_modules folder is not bundled into the build directory. So when I upload my production website onto a server, I have to install all my node_modules there as well. I analyzed the code of the node adapter and discovered this is on purpose. On line 66 of the main index.js file, we see:
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
It's because there's no need to. In a normal node environment, it's expected for prod dependencies to be installed, and the final build should leverage that instead of bundling them. The reason why other adapters like netlify or cloudflare does is mainly that they are in a worker environment and it's expected for everything to be bundled and be as small as possible. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer. What do you mean by 'the final build should leverage that'? Are there any benefits in not bundling the node_modules folder in the final build? In other words, if I decide to bundle the node_modules folder (because I have space restriction on the server I use), do I have any drawbacks? |
Beta Was this translation helpful? Give feedback.
-
One reason to bundle is because in Docker land an image of 1.5G is considered enormous. |
Beta Was this translation helpful? Give feedback.
-
Doesn't that mean that we lose the benefits of tree shaking in the production dependencies? |
Beta Was this translation helpful? Give feedback.
-
Would really love for this feature to get some attention especially for Docker users, at least to provide some workarounds, here is a deployment example of our deployment having SurrealDB and an Actix Web server in Rust both are lightweight (less than If anyone can suggest a way to work around this, would be much appreciated. |
Beta Was this translation helpful? Give feedback.
It's because there's no need to. In a normal node environment, it's expected for prod dependencies to be installed, and the final build should leverage that instead of bundling them. The reason why other adapters like netlify or cloudflare does is mainly that they are in a worker environment and it's expected for everything to be bundled and be as small as possible.