A tiny JavaScript bundler to learn how Webpack/Rollup work!
-
Create
example/index.js
:import { greet } from './utils.js'; console.log(greet('Developer'));
-
Run the bundler:
node bundler.js
Output:
dist/bundle.js
✨
-
Find Dependencies 📦
graph LR A[index.js] --> B[utils.js]
-
Transform Code (using Babel)
// Before import { greet } from './utils.js'; // After var _utils = require('./utils.js');
-
Bundle Everything
(function(modules){ // Mini-require() system here... })({ 0: [function(){...}, {}], // index.js 1: [function(){...}, {}] // utils.js })
✅ Finds all import
statements
✅ Handles JS files
✅ Super simple (~100 lines)
Try adding:
- Circular dependency support 🔄
- Code splitting ✂️
- Source maps 🗺
- Dynamic import support 🔀
Made with ❤️ for learning! 🕸️