Skip to content

matanbroner/JS-Bundler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS Bundler

A Rust based toy bundler for Javascript For research purposes only, not production ready!

Currently performs a "webpack" style bundling process that condenses all modules into a single file that provides a module dictionary that grants each module a require and exports object.

ex. 
const modules = {
	"modA": (require, exports) => {...},
	"modB": (require, exports) => {...},
}

Handled Use Cases

  • Transforms relative imports to require statements
ex.
import area from "../square" -> const { default: area} = require("../square");
import area, { anotherFn } from "../square" -> const { default: area, anotherFn} = require("../square");
  • Transforms exports to module exports
export default area -> exports.default = area;
export const area = _area -> exports.area = _area;
export { area } -> exports.area = area;
  • NodeJS modules imports
import express from "express"
  • "Rollup" style bundling
  • Bundle beautifier after generating

To Run

cargo build --release
./target/release/bundler [entry point] [output directory]

# ex. ./target/release/bundler ./test/index.js ./test/out

About

A project to learn Rust while also learning to build a Javascript bundler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published