# @preconstruct/cli

> Dev and build your code painlessly in monorepos

Latest version **2.9.0** (published 2026-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @preconstruct/cli
pnpm add @preconstruct/cli
yarn add @preconstruct/cli
bun add @preconstruct/cli
```

Provides the command `preconstruct`.

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.9.0 |
| Published | 2026-08-18 |
| First published | 2019-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 36 |
| Unpacked size | 279.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1190 |
| Maintainers | emmatown |

## Links

- npm: https://www.npmjs.com/package/@preconstruct/cli
- Repository: https://github.com/preconstruct/preconstruct/tree/main/packages/cli
- npm.io page: https://npm.io/package/@preconstruct/cli

## Dependencies (36)

- [ms](https://npm.io/package/ms.md) ^2.1.2
- [zod](https://npm.io/package/zod.md) ^3.21.4
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [rollup](https://npm.io/package/rollup.md) ^2.79.1
- [semver](https://npm.io/package/semver.md) ^7.3.4
- [terser](https://npm.io/package/terser.md) ^5.16.8
- [ci-info](https://npm.io/package/ci-info.md) ^3.8.0
- [p-limit](https://npm.io/package/p-limit.md) ^3.0.2
- [enquirer](https://npm.io/package/enquirer.md) ^2.3.6
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.4
- [quick-lru](https://npm.io/package/quick-lru.md) ^5.1.1
- [dataloader](https://npm.io/package/dataloader.md) ^2.0.0
- [parse-glob](https://npm.io/package/parse-glob.md) ^3.0.4
- [parse-json](https://npm.io/package/parse-json.md) ^5.1.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.7.7
- [jest-worker](https://npm.io/package/jest-worker.md) ^26.3.0
- [is-reference](https://npm.io/package/is-reference.md) ^1.2.1
- [magic-string](https://npm.io/package/magic-string.md) ^0.30.0
- [npm-packlist](https://npm.io/package/npm-packlist.md) ^2.1.2
- [resolve-from](https://npm.io/package/resolve-from.md) ^5.0.0
- [detect-indent](https://npm.io/package/detect-indent.md) ^6.0.0
- [estree-walker](https://npm.io/package/estree-walker.md) ^2.0.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.7.7
- [normalize-path](https://npm.io/package/normalize-path.md) ^3.0.0
- [builtin-modules](https://npm.io/package/builtin-modules.md) ^3.1.0
- [fast-deep-equal](https://npm.io/package/fast-deep-equal.md) ^2.0.1
- [v8-compile-cache](https://npm.io/package/v8-compile-cache.md) ^2.1.1
- [@babel/code-frame](https://npm.io/package/@babel/code-frame.md) ^7.5.5
- [@preconstruct/hook](https://npm.io/package/@preconstruct/hook.md) ^0.4.0
- [@rollup/plugin-json](https://npm.io/package/@rollup/plugin-json.md) ^4.1.0
- [@rollup/plugin-alias](https://npm.io/package/@rollup/plugin-alias.md) ^3.1.1
- [@rollup/plugin-replace](https://npm.io/package/@rollup/plugin-replace.md) ^2.4.1
- [@rollup/plugin-commonjs](https://npm.io/package/@rollup/plugin-commonjs.md) ^15.0.0
- [@rollup/plugin-node-resolve](https://npm.io/package/@rollup/plugin-node-resolve.md) ^11.2.1
- [@babel/helper-module-imports](https://npm.io/package/@babel/helper-module-imports.md) ^7.10.4

## Recent versions

- 2.9.0 (latest) — 2026-08-18
- 0.0.0-test-20241108011831 (test) — 2024-11-08
- 1.2.2 (one) — 2021-02-24
- 2.8.13 — 2026-05-06
- 2.8.12 — 2025-03-27
- 2.8.11 — 2025-02-25
- 2.8.10 — 2024-11-08
- 0.0.0-test-20241107073624 — 2024-11-07
- 2.8.9 — 2024-10-10
- 2.8.8 — 2024-10-01
- 2.8.7 — 2024-07-08
- 0.0.0-test-20240708054446 — 2024-07-08
- 2.8.6 — 2024-07-05
- 2.8.5 — 2024-07-02
- 2.8.4 — 2024-05-02
- … 85 more at https://npm.io/package/@preconstruct/cli/versions

## README

# Preconstruct 🎁

> Dev and build your code painlessly in monorepos

## Key Features

- In dev mode, your code behaves the same as it will in production, including locally linked in monorepos
- Add multiple entrypoints to your packages for publishing
- CLI helps walk you through set-up and making changes to your configs
- Works with different kinds of JS monorepos
- Also works for single package repos!
- Builds your code with rollup

## Getting Started

Assuming you already have a source file at src/index.js (or src/index.ts) or you're using pnpm workspaces and have packages with src/index.js (or src/index.ts), you can setup Preconstruct like this.

```bash
pnpm add --save-dev @preconstruct/cli
pnpm preconstruct init
```

If you're in a monorepo, you should also run `pnpm preconstruct dev` and add it to a postinstall script(`"postinstall": "preconstruct dev"`) that runs preconstruct dev so that you can import your code without having to rebuild your project every time in changes.

## Publishing packages

Before you publish packages to npm, run `preconstruct build`. reconstruct will use your Babel config and build flat bundles so make sure to [configure Babel](/guides/configuring-babel) with the transforms you want.

> We strongly recomment making a single script in your package.json that runs both build and publish, to stop broken publishes, such as `"release": "preconstruct build && pnpm publish:packages`. If you're in a single-package repo, you could also run `preconstruct build` in a `prepare` or `prepublishOnly` script.

## Further Guides

There are a number of tasks that become easier with preconstruct that lie slightly outside the main workflow. Check out the following guides for setting these up.

- [A more detailed account of getting set up](https://preconstruct.tools/tutorials)
- [Setting up a second entrypoint](https://preconstruct.tools/guides/adding-a-second-entrypoint)
- [CLI command documentation](https://preconstruct.tools/commands)
- [Other configuration](https://preconstruct.tools/configuration)

# See the docs at [preconstruct.tools](https://preconstruct.tools)

# Thanks/Inspiration

- [microbundle](https://github.com/developit/microbundle) was a huge inspiration for this! ❤️
- [rollup](https://rollupjs.org) - rollup has done the really hard stuff that makes preconstruct possible!
- [bolt](https://github.com/boltpkg/bolt) - lots of utils and things in this project were inspired by things in bolt
- [Kye Hohenberger](https://github.com/tkh44) for thinking of the name preconstruct
- Too many awesome people to name at [Thinkmill](https://thinkmill.com.au) who have given so much great feedback to make Preconstruct better and Thinkmill for sponsoring the development of Preconstruct 💝
- all the people who wrote all the dependencies for this project!

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