Bundler
A JavaScript Bundler I built from scratch, 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
So don't expect to use it in any of your future projects, as that is not its intended usecase.
If you do want to try it out anyway, then you can run it using
npx @ziermann/bundler
A working config file can be found inside the examples directory of the projects git repository.