Skip to content

Commit 1082808

Browse files
committed
build: emit JS with tsc and move gates out of build
Drop SWC; one tsc pass writes dist JS and declarations. contrast-test and dep-guard run in CI after the build. prepack still runs the build. Remove the stale pnpm-lock.yaml; the repo uses bun. Closes CL-9368
1 parent 5ac6b8b commit 1082808

10 files changed

Lines changed: 27 additions & 7663 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- run: bun install --frozen-lockfile
2424
- run: bun run typecheck
2525
- run: bun run lint
26-
- run: bun run dep-guard
2726
- run: bun test
2827
- run: bun run build
28+
- run: bun run contrast-test
29+
- run: bun run dep-guard

‎.swcrc‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎ARCHITECTURE.md‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,24 @@ points. There is no CLI, no component generator and no docs site, and that is de
2424

2525
## The build
2626

27-
`bun run build` is four steps and a gate, joined by `&&`, in order:
27+
`bun run build` is three steps, joined by `&&`, in order:
2828

2929
| Step | Tool | Output |
3030
| --- | --- | --- |
3131
| `generate` | `scripts/generate-exports.mjs` | `src/index.ts` and the `exports` map in `package.json` |
32-
| `build:js` | SWC | `dist/**/*.js`, one per source file |
33-
| `build:types` | `tsc -p tsconfig.build.json` | `dist/**/*.d.ts` |
32+
| `build:js` | `tsc -p tsconfig.build.json` | `dist/**/*.js` and `dist/**/*.d.ts`, one per source file |
3433
| `build:css` | Tailwind v4 CLI | `dist/styles.css`, plus `dist/theme.css` copied from source |
35-
| `contrast-test` | `scripts/contrast-test.mjs` | the gate — reads `dist/styles.css` |
3634

37-
SWC does the JavaScript because it is fast and per-file; `tsc` does the declarations
38-
because SWC does not emit them. Nothing bundles, so nothing can merge two modules into
39-
one chunk. `prepack` runs the whole thing, so a failing gate cannot be packed or
40-
published.
35+
`tsc` emits the JavaScript and the declarations in one pass. Nothing bundles, so nothing
36+
can merge two modules into one chunk. `prepack` runs the build, so npm publishes a fresh
37+
`dist/`. The gates (`contrast-test`, `dep-guard`) run in CI after the build.
4138

4239
Source imports are relative and carry `.js` extensions. There is no path alias, so the
4340
emitted files are valid ESM for Node as well as for every bundler.
4441

4542
Every component module that calls a hook, creates a context, defines an inline event
4643
handler, or imports an optional peer (Radix dialog, dropdown-menu or tooltip, or
47-
`sonner`) starts with `"use client"`, and SWC carries the directive into `dist/`. A React Server Components consumer renders any
44+
`sonner`) starts with `"use client"`, and `tsc` carries the directive into `dist/`. A React Server Components consumer renders any
4845
component directly; stateless components stay server-renderable. Plain-React bundlers
4946
ignore the directive. `dep-guard` enforces the rule, and checks `dist/` after a build.
5047

@@ -118,7 +115,7 @@ provider; every other component does not.
118115

119116
### Contrast is gated
120117

121-
`contrast-test` is the last step of the build. It parses the **built** `dist/styles.css`
118+
`contrast-test` runs in CI after the build. It parses the **built** `dist/styles.css`
122119
for the `:root` and `.dark` custom properties and derives its pairs from token *names*,
123120
never from listed hexes, so a new `--warning` / `--warning-foreground` is covered on the
124121
next run with no edit. Six rules:

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ contract — modules that are not exported are internal and may change in any re
7979
`ui/menu`, `ui/tooltip` and `ui/toast` leave the root barrel; import them by subpath
8080
(`import { Toaster, toast } from "@corbits/react-ui/ui/toast"`).
8181

82+
### Changed
83+
84+
- **Build emits JavaScript with `tsc`.** SWC is gone; one `tsc` pass writes `dist/**/*.js`
85+
and `.d.ts`. `contrast-test` and `dep-guard` run in CI instead of inside `build`.
86+
8287
### Added
8388

8489
- **`"use client"` on stateful components.** The 45 `ui/` and `blocks/` modules that call

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ consumer's data layer, not in a component — data arrives as props.
2626
## Gates
2727

2828
```sh
29-
bun run build # generate → SWC → tsc → Tailwind → the contrast gate
29+
bun run build # generate → tsc (JS + types) → Tailwind
3030
bun run typecheck # tsc --noEmit
3131
bun run lint # eslint .
3232
bun run dep-guard # forbidden-import checks over src/

‎IMPLEMENTATION.md‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,17 @@ Why the library exists lives in [PRODUCT.md](./PRODUCT.md).
2222

2323
## Toolchain
2424

25-
Development uses **bun**. `bun run build` is four steps and a gate, joined
26-
by `&&`:
25+
Development uses **bun**. `bun run build` is three steps, joined by `&&`:
2726

2827
| Step | Tool | Output |
2928
| --- | --- | --- |
3029
| `generate` | `scripts/generate-exports.mjs` | `src/index.ts` and the `exports` map in `package.json` |
31-
| `build:js` | SWC (`@swc/cli`, `@swc/core`) | `dist/**/*.js`, one per source file |
32-
| `build:types` | `tsc -p tsconfig.build.json` | `dist/**/*.d.ts` |
30+
| `build:js` | `tsc -p tsconfig.build.json` | `dist/**/*.js` and `dist/**/*.d.ts`, one per source file |
3331
| `build:css` | Tailwind v4 CLI | `dist/styles.css`, plus `dist/theme.css` copied from source |
34-
| `contrast-test` | `scripts/contrast-test.mjs` | the gate — reads `dist/styles.css` |
3532

3633
Source imports are relative and carry `.js` extensions. There is no path
37-
alias. `prepack` runs the whole build so a failing gate cannot be packed.
34+
alias. `prepack` runs the build. CI runs `contrast-test` (reads `dist/styles.css`)
35+
and `dep-guard` after it.
3836

3937
Other scripts: `bun run typecheck`, `bun run lint` (eslint),
4038
`bun run dep-guard` (`scripts/dep-guard.mjs` — fails if any file imports

0 commit comments

Comments
 (0)