Skip to content

fazalilahi/mini-bundler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌟 Mini Bundler 🌟

A tiny JavaScript bundler to learn how Webpack/Rollup work!


🚀 Quick Start

  1. Create example/index.js:

    import { greet } from './utils.js';
    console.log(greet('Developer'));
  2. Run the bundler:

    node bundler.js

    Output: dist/bundle.js


🔧 How It Works in 3 Steps

  1. Find Dependencies 📦

    graph LR
      A[index.js] --> B[utils.js]
    
    Loading
  2. Transform Code (using Babel)

    // Before
    import { greet } from './utils.js';
    // After
    var _utils = require('./utils.js');
  3. Bundle Everything

    (function(modules){
      // Mini-require() system here...
    })({
      0: [function(){...}, {}], // index.js
      1: [function(){...}, {}]  // utils.js
    })

🎯 Key Features

✅ Finds all import statements ✅ Handles JS files ✅ Super simple (~100 lines)


🛠 Want to Improve It?

Try adding:

  • Circular dependency support 🔄
  • Code splitting ✂️
  • Source maps 🗺
  • Dynamic import support 🔀

🤓 Learn More

🔗 AST Explorer
🔗 Babel tools


Made with ❤️ for learning! 🕸️

About

To understand modern module bundlers in javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published