Code Monkey home page Code Monkey logo

jetpack.js's Introduction

Jetpack.js

Build Status npm version

中文版

jetpack.js is an extremely fast js bundler and minifier.

jetpack.js a well designed tool. It's modulize into parser and bundler. The parser can be used as a library independently.

Features

Parser

  • Can be used standalone
  • Implemented in C++ with excellent performance
  • Full support for ECMAScript 2017(ECMA-262 8th Edition)
  • JSON output of sensible syntax tree format as standardized by ESTree project
  • Experimental support for JSX, a syntax extension for React
  • Syntax node location (index-based and line-column)
  • Friendly error message

Bundler

  • Module resolution.
  • Bundle a ES project into a single file.
  • Scope hoisting.
  • Constant folding.
  • Minify the code.
  • Sourcemap generation

Installation & Usage

Binary Distribution

Download the binary from the release page.

Usage:

jetpack-cli --help

Node.js User

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

Use the parser as a standalone library

jetpack.js is built with CMake, so it can be easily integrated to your project.

add_subdirectory(esparser)
target_include_directories(${PROJECT_NAME} ./esparser/src)
target_link_libraries(${PROJECT_NAME} PUBLIC esparser)

Performance

I do the same benchmark provided by esbuild.

My main benchmark approximates a large codebase by duplicating the three.js library 10 times and building a single bundle from scratch, without any caches. For this benchmark, esbuild is 10-100x faster than the other JavaScript bundlers I tested (Webpack, Rollup, Parcel, and FuseBox). The benchmark can be run with make bench-three.

The tests were done on a 6-core 2018 MacBook Pro with 16GB of RAM (similar to esbuild).

Architecture

The code are well commented, please read the code.

Platform

jetpack.js supports all popular system including:

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

Build Dependencies

  • jemalloc 5.2.1
  • cxxopts
  • fmt
  • nlohmann_json
  • robin-hood-hashing 3.11.1
  • xxHash

jetpack.js's People

Contributors

vincentdchan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.