Skip to main content

Build

Helper functions for build scripts.

Functions

checkCompiledOutputInRepo()

function checkCompiledOutputInRepo(): Promise<void>;

Defined in: functions/build.ts:24

Helper function to see if the compiled output that is checked-in to the Git repository is up-to-date.

Note that compiled output (in e.g. the "dist" directory) is not usually committed to a Git repository, but this is necessary in certain cases, such as when writing a custom GitHub Action in TypeScript. In these situations, this function should be run as part of the linting stage in order to ensure that the compiled output is always up to date.

Returns

Promise<void>

Throws

If the compiled output is not up-to-date.


compileToSingleFileWithBun()

function compileToSingleFileWithBun(packageRoot, target): Promise<void>;

Defined in: functions/build.ts:61

Helper function to compile a TypeScript project to a single file using Bun.

The following invocation is used:

bun build --compile --target=${target} --sourcemap --outfile=${outfile} ${entryPointPath}

Note that:

  • The outfile is "dist/[package-name]".
  • The entrypoint is assumed to be "src/main.ts".
  • We do not use the "--minify" flag because it mangles the function names in stack traces. (The size reduction from this flag is minor anyway.)

Parameters

ParameterTypeDefault valueDescription
packageRootstringundefinedThe path to the root of the package.
targetstring"bun-linux-x64"Optional. The target binary format. Defaults to "bun-linux-x64". See: https://bun.com/docs/bundler/executables#supported-targets

Returns

Promise<void>

Throws

If the "package.json" file does not exist or cannot be parsed.

See

https://bun.com/docs/bundler/executables