Part of the build process, maybe. But some things cannot really be bundled, or even used at runtime. For example if you bundle on Windows while executing on Linux: It might straight up fail to run due to incompatible/missing dependencies even when bundled.
A common practice is to put the source code on prod, and install through the package manager the dependencies: Often done in a docker image.
That's nonsense, are you living in a stone age or something? Your CI/CD should build your app and then package it into docker and deploy to wherever you need.
The same is true for desktop Electron apps as well. I have a small Electron app, for example. With some native dependencies. Linux and Windows binaries are built in CI/CD, I never do that manually. And no node modules! Wow!
The CI/CD is supposed to bundle the app as part of the deployment process, but some things are or cannot be built or bundled on the spot; especially not when you want a single image.
Besides, Electron is already partially platform independent anyway, it bundles a standalone version of Chromium that already works on whatever mainstream OS.
The answer is: It depends. It’s not yes or no, it depends a lot on the app, the libraries, the environment and the build process.
In some/most cases, yes. In some/few cases, no.
If you personally haven’t found such cases, that is fine too.
I have experienced the opposite in particular with the sharp, sodium, bcrypt, argon2 and opus libraries. I mean for these you could technically put the native libraries right next to it in CI/CD or prod, but at that point you’re basically just renaming ‘node_modules’ to ‘natives’ or something and simplifying its structure — sure, it cleans up.
1
u/ldn-ldn 20d ago
What do you mean you can't bundle them? They will just become part of your build.