# Dumpling
A fast JavaScript runtime and bundler implemented in Rust.
## Features
- 🚀 Fast JavaScript runtime using the Boa engine
- 📦 Package manager functionality
- 📦 Module bundling with support for ES modules, CommonJS, and IIFE formats
- 🔥 Hot module replacement in development mode
- 📁 Advanced module resolution with support for node_modules
- ⚡ Built with Rust for performance and safety
## Installation
```bash
cargo install dumpling
```
## Usage
### Initialize a new project
```bash
dumpling init
```
This creates a new project with:
- `package.json` with basic scripts
- `src/index.js` as the entry point
- `dist/` directory for build outputs
### Run a JavaScript file
```bash
dumpling run src/index.js
```
### Start development server
```bash
dumpling dev
```
### Bundle your code
```bash
# ES modules format (default)
dumpling bundle src/index.js --output dist/bundle.js
# CommonJS format
dumpling bundle src/index.js --output dist/bundle.js --format cjs
# IIFE format with minification
dumpling bundle src/index.js --output dist/bundle.js --format iife --minify
# With source map
dumpling bundle src/index.js --output dist/bundle.js --sourcemap
```
### Install packages
```bash
# Install a package (fetches from npm registry)
dumpling install lodash
# Install as dev dependency
dumpling install typescript --dev
# Install all dependencies from package.json
dumpling install
```
### Run package.json scripts
```bash
dumpling run-script build
dumpling run-script test
```
## Configuration
Dumpling uses a `package.json` file for configuration:
```json
{
"name": "my-project",
"version": "0.1.0",
"scripts": {
"start": "dumpling run src/index.js",
"dev": "dumpling dev",
"build": "dumpling bundle src/index.js --output dist/bundle.js"
},
"dependencies": {
"lodash": "^4.17.21"
},
"devDependencies": {
"typescript": "^4.9.4"
}
}
```
## Module Resolution
Dumpling supports modern JavaScript module resolution:
```javascript
// Relative imports
import utils from "./utils.js";
import helper from "../helper.js";
// Node modules imports
import _ from "lodash";
import express from "express";
// Dynamic imports
const module = await import("./module.js");
// JSON imports
const data = require("./data.json");
```
## Development
```bash
# Clone the repository
git clone https://github.com/yourusername/dumpling.git
cd dumpling
# Build
cargo build
# Run tests
cargo test
# Run in development mode
cargo run -- run examples/hello.js
```
## License
MIT