# @marijn/buildtool

> Tool for building TypeScript packages

Latest version **1.2.1** (published 2026-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @marijn/buildtool
pnpm add @marijn/buildtool
yarn add @marijn/buildtool
bun add @marijn/buildtool
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2026-09-24 |
| First published | 2022-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 32.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Marijn Haverbeke |
| Maintainers | marijn |

## Links

- npm: https://www.npmjs.com/package/@marijn/buildtool
- Repository: https://code.haverbeke.berlin/marijn/buildtool
- npm.io page: https://npm.io/package/@marijn/buildtool

## Dependencies (6)

- [acorn](https://npm.io/package/acorn.md) ^8.10.0
- [rollup](https://npm.io/package/rollup.md) ^4.8.0
- [acorn-walk](https://npm.io/package/acorn-walk.md) ^8.2.0
- [typescript](https://npm.io/package/typescript.md) ^5.3.3
- [@types/mocha](https://npm.io/package/@types/mocha.md) ^9.1.1
- [rollup-plugin-dts](https://npm.io/package/rollup-plugin-dts.md) ^6.1.0

## Recent versions

- 1.2.1 (latest) — 2026-09-24
- 1.2.0 — 2025-11-08
- 1.1.0 — 2025-02-14
- 1.0.0 — 2023-12-11
- 0.1.6 — 2023-08-17
- 0.1.5 — 2023-08-17
- 0.1.4 — 2023-05-17
- 0.1.3 — 2023-03-23
- 0.1.2 — 2022-05-20
- 0.1.1 — 2022-05-17
- 0.1.0 — 2022-05-17

## README

# @marijn/buildtool

Utility to build TypeScript projects that conform to a given set of
conventions quickly and cleanly. Exports functions that wrap the
TypeScript compiler and Rollup to build or watch one or more projects
in one go, performing a single shared build (so that files from
different projects aren't compiled twice).

Assumes your projects are set up like this:

 - TypeScript files in an `src` directory, will be compiled to
   `dist/index.js` (ES module), `dist/index.cjs` (CommonJS), and
   `dist/index.d.ts` (TypeScript) files.

 - Tests, if any, under `test`, will be compiled in-place to `.js`
   files, which are ES modules.

 - Doc comments prefixed with triple slash `///` syntax will be
   converted to `/**` JSDoc comments in the output, so that TypeScript
   tooling picks them up.

## API

 * **`build`**`(main: string | readonly string[], options?: BuildOptions = {}) → Promise`\
   Build the package with main entry point `main`, or the set of
   packages with the given entry point files. Output files will be
   written to the `dist` directory one level up from the entry file.
   Any TypeScript files in a `test` directory one level up from main
   files will be built in-place.


 * **`watch`**`(mains: readonly string[], extra?: readonly string[] = [], options?: BuildOptions = {})`\
   Build the given packages, along with an optional set of extra
   files, and keep rebuilding them every time an input file changes.


### interface BuildOptions

Options passed to `build` or `watch`.

 * **`typeCheck`**`?: boolean`\
   Fail the build on type errors. defaults to false

 * **`sourceMap`**`?: boolean`\
   Generate sourcemap when generating bundle. defaults to false

 * **`tsOptions`**`?: any`\
   Additional compiler options to pass to TypeScript.

 * **`bundleName`**`?: string`\
   Base filename to use for the output bundle and declaration
   files. Defaults to `"index"`.

 * **`expandLink`**`?: fn(anchor: string) → string | null`\
   When given, this is used to convert anchor links in the `///`
   comments to full URLs.

 * **`expandRootLink`**`?: string`\
   When given, prefix this to links in the comments that start with
   a `/`.

 * **`outputPlugin`**`?: fn(root: string) → Plugin | Promise`\
   Adds a Rollup output plugin to use.

 * **`cjsOutputPlugin`**`?: fn(root: string) → Plugin`\
   Adds an output plugin to use only for CommonJS bundles.

 * **`pureTopCalls`**`?: boolean`\
   When set to true, add a `/*@__PURE__*/` comment before top level
   function calls, so that tree shakers will consider them pure.
   Note that this can break your code if it makes top-level
   function calls that have side effects.

 * **`onRebuildStart`**`?: fn(packages: readonly string[])`\
   Function to call when starting a rebuild via `watch`, passing
   the root directories of the packages that are being built. The
   default is to just log the base names of the directories.

 * **`onRebuildEnd`**`?: fn(packages: readonly string[])`\
   Function to call when finishing a rebuild.


## Community

This is open source software released under an
[MIT license](https://code.haverbeke.berlin/marijn/buildtool/src/branch/main/LICENSE).

Development happens on
[Forgejo](https://code.haverbeke.berlin/marijn/buildtool). Use the [bug
tracker](https://code.haverbeke.berlin/marijn/buildtool/issues) to report
problems.

---
_Source: https://npm.io/package/@marijn/buildtool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
