Skip to content

Build

Helper functions for build scripts.

function checkCompiledOutputInRepo(): Promise<void>;

Defined in: functions/build.ts:25

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.

Promise<void>

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


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

Defined in: functions/build.ts:64

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

The following invocation is used:

Terminal window
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.)
Parameter Type Description
packageRoot string The path to the root of the package.
target? string Optional. The target binary format. Defaults to match the current system. See: https://bun.com/docs/bundler/executables#supported-targets

Promise<void>

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

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