Skip to content

N-Ziermann/Bundler

Repository files navigation

Bundler

npm Example

This is a personal project I built to better understand how bundlers work.

It uses babel to transpile code to CommonJS and bundles that code into a singular JavaScript file.

These are some of the features it supports:

  • reading node_modules (even in pnpm workspaces)
  • transpiling esmodules & typescript using babel
  • loading assets like pngs and css files using a loader-pattern
  • reading a local config file (bundler.json)
  • using a public folder that gets merged into the output
  • multithreading for transpilation (using workers)

In combination all of these features offer enough functionality to bundle a fully working react site.

Note that this bundler is not meant to be especially fast. It is specifically written to not use any libraries that abstract away behaviours commonly connected to bundling, like:

  • file reading
  • file combination
  • getting dependencies of a file
  • multithreading

If you would like to try it out anyway then you can use this command to try it out.

npx @ziermann/bundler

A working bundler.json config for react projects can be found in the examples directory.

And the bundled result of that example can be found here