Skip to content

viatcheslav-zadorozhniy/module-bundlers

Repository files navigation

Module Bundlers

Table of contents

Description

What is their purpose?

  • browsers (or node.js) understand JavaScript, not JSX or TypeScript
  • browsers understand CSS, not SASS (SCSS) or LESS
  • to deliver optimized code for users - bundled, minified
  • etc.

When they are used?

How does their usually work?

Typical config has the following properties:

  • entry point (single or multiple)
  • output details
    • output file(s) name
    • output directory
    • etc.
  • bundling details
    • use minification
    • add source maps
    • etc.
  • set of plugins
    • perform manipulations not supported out of the box
    • use lifecycle hooks to inject their logic

Bundlers

ESBuild

Parcel

  • Zero configuration build tool.
  • Documentation
  • Run yarn build:parcel to bundle the demo app (uncomment script in the index.html before).

Rollup

Webpack

Demo

Details

An example app is close to the real-world infrastructure:

  • written in TypeScript;
  • imports 3rd party libraries;
  • has unused imports (to test tree shaking);
  • has lazy loading modules;
  • uses CSS preprocessor (SASS);
  • uses partially-supported CSS rules, which require vendor prefixes (autoprefixer);

Installation

yarn install --frozen-lockfile