Skip to content
forked from evanw/esbuild

An extremely fast JavaScript bundler and minifier - a fork demonstrating installation by `go get`

License

Notifications You must be signed in to change notification settings

prantlf/esbuild

 
 

Repository files navigation

esbuild: An extremely fast JavaScript bundler
Website | Getting started | Documentation | Plugins | FAQ

Why?

Our current build tools for the web are 10-100x slower than they could be:

Bar chart with benchmark results

The main goal of the esbuild bundler project is to bring about a new era of build tool performance, and create an easy-to-use modern bundler along the way.

Major features:

Check out the getting started instructions if you want to give esbuild a try.

About This Fork

This is a fork of the original project that demonstrates experimental features:

  1. Analysis of module dependencies only, without compiling the output bundle. (see the branch analyse)
  2. Support for AMD input (WIP). (see the branch amdjs)
  3. Support for UMD output. (see the branch umdjs)

Installation

If you want to use the command-line in terminal, install the esbuild binary globally by either of:

npm i -g @prantlf/esbuild
pnpm i -g @prantlf/esbuild
yarn global add @prantlf/esbuild

If you want to use the binary from scripts in package.json or as a service from JavaScript, install the esbuild binary as a development dependency of your project:

npm i -D @prantlf/esbuild
pnpm i -D @prantlf/esbuild
yarn add -D @prantlf/esbuild

Analysis

How to perform the source analysis only on the command line:

esbuild --analyse entry.js --metafile=dependencies.json

in Go:

result := api.Analyse(api.AnalyseOptions{
  EntryPoints: []string{"entry.js"},
  Metafile:    "dependencies.json",
  LogLevel:    api.LogLevelInfo,
})

and in JavaScript:

const result = await service.analyse({
  entryPoints: ['entry.js'],
  metafile: 'dependencies.json',
  write: false
});

AMD

How to build an AMD project on the command line:

esbuild --bundle --amdconfig=config.json main.js --outfile=out/bundle.js

with the following config.json:

{
  "baseUrl": "src",
  "paths": {
    "external": "empty:",
    "internal": "."
  },
  "map": {
    "*": {
      "external/libs/jquery": "internal/libs/jquery"
    }
  },
  "plugins": {
    "json": {
      "fileExtensions": [".json"]
    },
    "css": {
      "fileExtensions": [".css"],
      "appendFileExtension": true
    },
    "i18n": {
      "fileExtensions": [".js"],
      "loadScript": {
        "replacementPattern": "/nls/",
        "replacementValue": "/nls/root/"
      }
    }
  }
}

UMD

How to build an UMD library on the command line:

esbuild --bundle --format=umd --global-name=mylib index.js --outfile=bundle.js

About

An extremely fast JavaScript bundler and minifier - a fork demonstrating installation by `go get`

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 77.6%
  • JavaScript 17.4%
  • TypeScript 3.5%
  • Makefile 1.2%
  • HTML 0.3%