I'm quite new in this overwhelmingly huge world of js-stack-tools and recently I've been following some tutorials about bundlers, which seem to include almost always the frontend facet.
But in a simple app with only server-side participation (like a single service app in a microservices architecture) is it necessary to bundle the app? what are the pros/cons of doing it?
If pros > cons would be a good practice to use Jest's snapshots to check the bundle.js file?
My apologizes if the question turns to be a bit ambiguous but I'm struggling trying to fit all these new concepts in my head.
I would recommend that you bundle code, because of tree shaking.
The Node.js import/require statement will import the entire module (if the library author exports all things in one file), including any features you don't use. This holds true whether the module is an CommonJS module or ESM.
The downside of importing entire modules is their memory usage. Smaller, less dependent modules take up less memory; larger, more dependent modules take up more memory. In one case I encountered, a pure (no side effects) module import took up 20MB of memory, which would have been reduced to KB if the code had been bundled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With