The project is a basic, naive implementation of a real-world JavaScript bundler. The purpose of this repo is to understand and learn the underlying mechanisms, structure and processes.
The AST is generated by SWC (speedy-web-compiler) to scope the learning to only bundling.
All the JavaScript files with a single entry point are bundled into one file which can be executed in a Node runtime.
- Dependency resolution
- AST
- Bundle to one
It uses the Rollup style to bundle i.e build the dependency graph, and walk back by starting from the last vertex, resolving the dependencies by replacing with the imported code.
npm i
npm run start
As I mentioned, it's a toy project and it comes with things it does not support as of now:
- Dependency resolution might not be perfect.
module.exports
does not work alongwith inline default exports.- Bundled code is not cleaned up as it just does a manual merge.
- Circular dependencies do not work.
- Same named variables/functions are not renamed like Rollup.
- More stuff which maybe I haven't come across yet!
npm test