Skip to content

ESBuild Builder

Build GitHub Actions using ESBuild.

Installation

bash
pnpm add -D actions-kit @actions-sdk/esbuild-builder
bash
yarn add -D actions-kit @actions-sdk/esbuild-builder
bash
npm install -D actions-kit @actions-sdk/esbuild-builder
bash
bun install -D actions-kit @actions-sdk/esbuild-builder

Set the builder in your actions-kit.config.ts file:

actions-kit.config.ts
ts
import { defineConfig } from "actions-kit/config";
import esbuild from "@actions-sdk/esbuild-builder";

export default defineConfig({
  builder: esbuild({
    ...esbuildOptions,
  }),
});

Customizing ESBuild

You can customize the ESBuild options by passing the options directly into the esbuild function.

NOTE

Not all of ESBuild's options are supported. For a list of the supported options, see ESBuild Options.

actions-kit.config.ts
ts
import { defineConfig } from "actions-kit/config";
import esbuild from "@actions-sdk/esbuild-builder";

export default defineConfig({
  builder: esbuild({
    target: "esnext",
    format: "esm",
    minify: true,
  }),
});

ESBuild Options

These are the supported ESBuild options:

OptionTypeDocumentation
sourcemapboolean | 'linked' | 'inline' | 'external' | 'both'Source Map
legalComments'none' | 'inline' | 'eof' | 'linked' | 'external'Legal Comments
sourceRootstringSource Root
sourcesContentbooleanSources Content
format'iife' | 'cjs' | 'esm'Format
globalNamestringGlobal Name
targetstring | string[]Target
supportedRecord<string, boolean>Supported
platform'browser' | 'node' | 'neutral'Platform
manglePropsRegExpMangle Props
reservePropsRegExpMangle Props
mangleQuotedbooleanMangle Props
mangleCacheRecord<string, string | false>Mangle Props
drop('console' | 'debugger')[]Drop
dropLabelsstring[]Drop Labels
minifybooleanMinify
minifyWhitespacebooleanMinify
minifyIdentifiersbooleanMinify
minifySyntaxbooleanMinify
lineLimitnumberLine Limit
charset'ascii' | 'utf8'Charset
treeShakingbooleanTree Shaking
ignoreAnnotationsbooleanIgnore Annotations
jsx'transform' | 'preserve' | 'automatic'JSX
jsxFactorystringJSX Factory
jsxFragmentstringJSX Fragment
jsxImportSourcestringJSX Import Source
jsxDevbooleanJSX Development
jsxSideEffectsbooleanJSX Side Effects
define{ [key: string]: string }Define
purestring[]Pure
keepNamesbooleanKeep Names
colorbooleanColor
logLevel'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'Log Level
logLimitnumberLog Limit
logOverrideRecord<string, LogLevel>Log Override
bundlebooleanBundle
splittingbooleanSplitting
preserveSymlinksbooleanPreserve Symlinks
outfilestringOutfile
metafilebooleanMetafile
outdirstringOutdir
outbasestringOutbase
externalstring[]External
packages'bundle' | 'external'Packages
aliasRecord<string, string>Alias
loader{ [ext: string]: Loader }Loader
resolveExtensionsstring[]Resolve Extensions
mainFieldsstring[]Main Fields
conditionsstring[]Conditions
writebooleanWrite
allowOverwritebooleanAllow Overwrite
tsconfigstringTSConfig
outExtension{ [ext: string]: string }Out Extension
publicPathstringPublic Path
entryNamesstringEntry Names
chunkNamesstringChunk Names
assetNamesstringAsset Names
injectstring[]Inject
banner{ [type: string]: string }Banner
footer{ [type: string]: string }Footer
entryPointsstring[] | Record<string, string> | { in: string, out: string }[]Entry Points
pluginsPlugin[]Plugins
absWorkingDirstringWorking Directory
nodePathsstring[]Node Paths