Skip to content

Latest commit

 

History

History
298 lines (249 loc) · 4.67 KB

README.md

File metadata and controls

298 lines (249 loc) · 4.67 KB

ESBuilder

Simple and easy to use solution for building your modules to native ES syntax.

You can found this project on Deno.land registry.

Installations

  1. Install Deno 🦕
  2. Check if your .deno folder is in PATH
  3. Install it!

Install from Deno (Simpliest way)

Run the following command:

deno install \
 --allow-read \
 --allow-write \
 --allow-env \
 --allow-run \
 --name esbuilder \
 https://deno.land/x/esbuilder/builder.ts

Install by VSCode task runner (No terminal way)

  • Clone this repository
  • Open repo in VS Code
  • Open Command Pallete (Ctrl + Shift + P / ⌘ + Shift + P)
    • Select → Tasks: Run Task
    • Run → Install ESBuilder

Install in Terminal from Repository

  • Clone this repository
  • Run the following command:
deno install \
 --allow-read \
 --allow-write \
 --allow-env \
 --allow-run \
 --allow-net \
 --no-prompt \
 --name esbuilder \
 ./builder.ts

Uninstallations

Simple!

deno uninstall esbuilder

Usage

esbuilder --config=./config.json

Help

esbuilder --help

Alternative

deno run --allow-all ./builder.ts --config=./config.json
deno run --allow-all ./builder.bundled.js --config=./config.json

Configuration

Example

{
    "version": "1.0",
    "sourceDir": "./src",
    "outDir": "./dist",
    "files": [
        "./file1.ts",
        "./file2.ts",
    ],
    "build": {
        "bundle": true,
        "minify": true,
        "sourcemap": true
    },
    "options": {
        "watch": true,
        "gitignore": true,
    }
}

Properties

Version — Required

Version of config schema/syntax. Defaults to current version of Builder.

{
    "version": "1.0"
}

The notation "1.0" and "1.0.0" are equivalent.

Source directory — Optional

Path to source directory. Defaults to ./.

{
    "sourceDir": "./src"
}

Output directory — Optional

Path to output directory. Defaults to ./build.

{
    "outDir": "./dist"
}

Files / Entry points — Optional

Paths to entry files relative to sourceDir.

{
    "files": [
        "./file1.ts",
        "./dir/file2.ts",
    ]
}
{
    "files": {
        "MyGroupA": "./file1.ts",
        "MyGroupB": [
            "./file1.ts",
            "./dir/file2.ts"
        ]
    }
}

Build Settings — Optional

Bundle — Optional

Whether to bundle entry file (with dependecies) into a single file. Defaults to false.

{
    "build": {
        "bundle": true
    }
}

Minify — Optional

Whether to minify the output. Defaults to false.

{
    "build": {
        "minify": true
    }
}

Source Maps — Optional

Whether to create source map files. Defaults to false.

{
    "build": {
        "sourcemap": true
    }
}

Options — Optional

Verbose — Optional

Whether to print verbose output. Defaults to true.

{
    "options": {
        "verbose": false
    }
}

Watch — Optional

If true, watch for changes in source files and rebuild. Defaults to false.

You can forced by passing --watch flag.

{
    "options": {
        "watch": true
    }
}

tsconfig — Optional

Path to tsconfig.json. Defaults to null.

{
    "options": {
        "tsconfig": "./tsconfig.json"
    }
}

Generate .gitignoreOptional

Whether to create .gitignore with built outputs. Defaults to false.

{
    "options": {
        "gitignore": true
    }
}

Generate Output summary — Optional

Whether to create json file with description of all built outputs. Defaults to false.

{
    "options": {
        "outputSummary": true
    }
}

Example I of output summary:

{
    "version": "1.0",
    "files": [
        "./file1.js",
        "./file1.js.map",
        "./dir/file2.js",
        "./dir/file2.js.map"
    ]
}

Example II of output summary:

{
    "version": "1.0",
    "files": {
        "MyGroupA": [
            "./file1.js",
            "./file1.js.map"
        ],
        "MyGroupB": [
            "./file1.js",
            "./file1.js.map",
            "./dir/file2.js",
            "./dir/file2.js.map"
        ]
    }
}

Output Summary Filename — Optional

Name of the output summary file. Defaults to output-summary.json.

{
    "options": {
        "outputSummaryFilename": "output-summary.json"
    }
}