Skip to content

A JavaScript bundler and minifier implemented in C++ aimed at excellent performance.

License

Notifications You must be signed in to change notification settings

vincentdchan/jetpack.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3ec5fdf · Nov 23, 2021
Apr 13, 2020
Oct 18, 2021
Oct 18, 2021
Nov 22, 2021
Oct 18, 2021
Nov 23, 2021
Oct 25, 2019
Nov 22, 2021
Nov 9, 2021
Apr 6, 2021
Apr 3, 2021
Sep 10, 2021
Oct 17, 2019
Oct 17, 2021
Oct 17, 2021

Repository files navigation

Jetpack.js

Build Status npm version

| 中文版 | WASM Online Demo

jetpack.js is an extremely fast js bundler and minifier written in C++.

Features

  • Implemented in C++ with excellent performance
  • Full support for ECMAScript 2017(ECMA-262 8th Edition)
  • Experimental support for JSX, a syntax extension for React
  • Friendly error message
  • Bundle a ES project into a single file.
  • Scope hoisting.
  • Constant folding.
  • Minify the code.
  • Sourcemap generation

Installation & Usage

npm install -g jetpp

Use command line to bundle a js module.

jetpp main.js --out bundle.js

Help command:

$ jetpp --help

Jetpack command line
Usage:
  Jetpack [OPTION...] positional parameters

      --tolerant            tolerant parsing error
      --jsx                 support jsx syntax
      --library             bundle as library, do not bundle node_modules
      --help                produce help message
      --analyze-module arg  analyze a module and print result
      --no-trace            do not trace ref file when analyze module
      --minify              minify the code
      --out arg             output filename of bundle
      --sourcemap           generate sourcemaps

Node.js Program

const jetpp = require('jetpp');

console.log(jetpp.minify('let hello = "world";'));

WebAssembly User

WASM gives you the power of running Jetpack.js in the browser environment.

Install the WASM version

yarn add jetpp-wasm

Include Jetpack.js in your project

import loadJetpack from 'jetpp-wasm';

async function main(code) {
    const jetpack = await loadJetpack();
    console.log(jetpack.minify(code));  // minify
    console.log(jetpack.parse(code));  // parse
}

Platform

jetpack.js supports all popular system including:

  • macOS x64/arm64
  • Windows 64bit
  • Linux 64bit/arm64
  • WebAssembly

Build Dependencies

  • cxxopts
  • fmt
  • nlohmann_json
  • robin-hood-hashing 3.11.1
  • boost(Header-only) 1.76