JavaScript Module Bundlers
All you really need to make an interactive website is HTML, CSS, and JavaScript. But nowadays, JavaScript can be done with TypeScript or have so many add-ons that it hardly resembles JavaScript anymore. Truly well-designed websites have sections of code placed in smaller files called modules. Modules are very handy for only working on one part of the code you want to alter, but certain parts of the code can be placed in not-so-common hierarchies. Sometimes when a package is added or a module is referenced in another file the website or app can crash because it can’t find the module. Introducing module bundlers, a way for websites and apps to keep track of all the pieces of code and bundle the code into one large code file to load swiftly with minimal errors. One of the most recent examples of where a bundler could come in handy was our light and dark themes code. I had moved the code outside of the script tag at the bottom of the HTML page so I can use it on multiple pages and not clutter each page that needed it. I linked the new JavaScript file at the top of the page, but it didn’t work because I had placed it before some of the other functions were called. I used “defer” to make it work but a module bundler would see the dependencies and place them in the right part of the code when creating the larger compiled file.
There are many bundlers out there and trying to find the right one for your project can be difficult. Openbase.com is a great place to look at different bundlers and compare them. You can look at how popular they are in downloads, which can help you see if they are still being used and updated. You can see user ratings and top feedback. Things you might be interested in knowing are the ease of setup or how fast is the bundling.
Get Ace D Baugh’s stories in your inbox
Join Medium for free to get updates from this writer.
Module bundlers are great for making pages work with less thought as to where files are placed and imported and exported, but the more pages and modules are created, the bigger the file gets. It also takes a lot longer to compile or bundle. There are some bundlers around that try to mitigate the bundling duration as projects scale up. Overall, JavaScript Module Bundlers have more benefits than downsides as you scale up.
References
10 best javascript bundler libraries in 2022. Openbase. (n.d.). Retrieved August 23, 2022, from https://openbase.com/categories/js/best-javascript-bundler-libraries
Fireship. (2020). Module Bundlers Explained… Webpack, Rollup, Parcel, and Snowpack. YouTube. Retrieved August 23, 2022, from https://www.youtube.com/watch?v=5IG4UmULyoA.




