Skip to main content

esbuild

Usage

// build.mjs
import { buildCode, getEntryPoints, getEntrypointFolders } from '@rtorcato/js-tooling/esbuild'

const folders = await getEntrypointFolders('src')
const entryPoints = (await Promise.all(folders.map(getEntryPoints))).flat()

await buildCode(entryPoints)

API

buildCode(entryPoints)

Runs an esbuild build with opinionated defaults:

OptionValue
outdirdist
platformnode
formatesm
targetesnext
bundletrue
splittingtrue
sourcemapdevelopment only
minifyproduction only
pluginsesbuild-node-externals

getEntryPoints(dir, fileExtension?, excludeTestFiles?)

Returns all .ts files in dir, excluding test files by default.

getEntrypointFolders(dir)

Returns subdirectories of dir that contain an index.ts.