Skip to content

Commit 5b777b8

Browse files
marcjAgent
authored andcommitted
docs: clarify single package build instructions in CLAUDE.md
1 parent c41fb2d commit 5b777b8

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

CLAUDE.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,27 @@ npm run clean # Clean artifacts
9494

9595
**Important:** After modifying TypeScript source files, run `tsc --build` (or `npm run tsc`) to compile the changes before running tests. Tests execute the compiled JavaScript in `dist/`, not the TypeScript source directly.
9696

97-
### Package Build Structure
97+
### Building a Single Package
9898

99-
Each package has a dual build output:
99+
To build a specific package (e.g., `@deepkit/bson`) from the repo root:
100100

101-
- `dist/cjs/` - CommonJS build (from `tsconfig.json`)
102-
- `dist/esm/` - ES Modules build (from `tsconfig.esm.json`)
101+
```bash
102+
npx tsc --build packages/bson/tsconfig.json packages/bson/tsconfig.esm.json
103+
cd packages/bson && npm run build
104+
```
103105

104-
**CRITICAL:** Each package's `npm run build` script creates a `dist/esm/package.json` with `{"type": "module"}` to enable ES modules. If you delete `dist/` manually, you MUST run `npm run build` in that package to recreate this file, otherwise ES module imports will fail.
106+
The order matters:
107+
1. `tsc --build` compiles TypeScript and creates the `dist/` directories
108+
2. `npm run build` creates `dist/esm/package.json` for ES module support
105109

106-
```bash
107-
# If you deleted dist/ in a package, run:
108-
cd packages/<package-name> && npm run build
110+
### Package Build Structure
109111

110-
# Or rebuild everything:
111-
npm run build
112-
```
112+
Each package has a dual build output:
113113

114-
**When rebuilding a single package:** Always build both tsconfig files:
114+
- `dist/cjs/` - CommonJS build (from `tsconfig.json`)
115+
- `dist/esm/` - ES Modules build (from `tsconfig.esm.json`)
115116

116-
```bash
117-
npm run tsc -- --build packages/core/tsconfig.json packages/core/tsconfig.esm.json
118-
cd packages/core && npm run build # Creates dist/esm/package.json
119-
```
117+
**CRITICAL:** The `npm run build` script in each package creates `dist/esm/package.json` with `{"type": "module"}`. This file is required for ES module imports to work. If you delete `dist/` manually, you MUST run `npm run build` to recreate it.
120118

121119
## Architecture Overview
122120

0 commit comments

Comments
 (0)