logoalt Hacker News

curtisblainetoday at 12:09 PM5 repliesview on HN

I'm always curious of the use case when someone proposes Node code bundling. What's the advantage? Obfuscation in SEA?


Replies

afavourtoday at 12:22 PM

In my experience the bundling isn’t really the important aspect (though it also doesn’t harm anything), it’s more just having an ecosystem of plugins for code transpiling, static asset inclusion (e.g. text files) etc and a configuration format folks are already used to.

ivanjermakovtoday at 12:14 PM

Running typescript without compilation is still tricky with plain Node. `vite dev` has amazing DX not available for Node programs. I'm wondering if Vite+ tackles this problem.

show 1 reply
inbx0today at 1:54 PM

For me, the main benefit is deployment bundle/artifact size reduction. Mostly from dropping unneeded files from node_modules. Many packages include both esm and cjs builds, sources, docs, TS types, etc. stuff that you don’t need in prod. This matters for lambdas, for example, because deployed code size has limits there.

mnutttoday at 1:29 PM

In cases where startup time matters and you have a slow disk, bundling can drastically reduce the number of filesystem calls you have to make for large dependency graphs.

UnfitFootprinttoday at 1:33 PM

I’ve found if you want interop ts esm and js cjs you need to compile your code - and then `tsc` doesn’t bundle your dependencies for you and outputs incomplete code.