Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using webpack on the node backend

I'm trying to figure out if webpack should be used at all on the backend of a node app (written in typescript), primarily because node has a built in module loader. I use tsc to convert the .ts files to .js and the module loader in node loads the files when running. What is the advantage on using webpack?

thanks

like image 499
tmp dev Avatar asked Aug 06 '26 03:08

tmp dev


1 Answers

Here are a few advantages of using a bundler like Webpack on the backend:

  • It allows you to bundle your app code into a single minified file that only contains the relevant code.

    This is especially useful when you want to minimize the size of the package or want to create a standalone file that can be run without the node_modules directory.

  • It helps you cut down the app startup time by minimizing the bundle size and the time required for module lookup.

  • It makes it possible to have hot code loading on the server-side (can be done without webpack too)

  • It enables you to use other webpack plugins and loaders.

Considering all those advantages it has its own quirks and can make things more complicated than they should be. So obviously, only use it when it's absolutely necessary.

like image 166
fardjad Avatar answered Aug 08 '26 04:08

fardjad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!