Commit 4793bee
fix(internal): fix broken builds with fresh checkout on both typecheck and api-check (tldraw#8249)
While working on tldraw#8194 I came upon
some issues with tldraw/driver, I threw Claude at it until I could
actually yarn typecheck and yarn api-check locally and it fixed the
issue on my branch.
### Commit 1: "Fix: internal typecheck"
This fixes the internal/scripts/typecheck.ts script, which runs tsgo
--build across all workspace packages.
The problem: On a fresh checkout, tsgo --build can't always resolve the
full project-reference graph correctly when all package tsconfigs are
passed in a single invocation. The previous workaround was to
"bootstrap" packages first, but it was passing them all at once — which
still left ordering issues if package A depends on package B but B
hadn't been built yet.
The fix: It adds a topoSortTsconfigs() function that reads each
tsconfig's references field and performs a topological sort
(depth-first). Then instead of one bulk tsgo --build ...all-packages, it
builds each package tsconfig one at a time in topological order — leaves
first, dependents after. This ensures each package's declaration outputs
exist before any package that depends on them is built.
### Commit 2: "fix(internal): api-check"
This fixes the internal/scripts/api-check.ts script, which verifies that
the public API surface of published packages type-checks correctly
against their declared dependencies.
Two problems fixed:
Broken tiptap versions from npm. The script was doing a bare npm install
@tiptap/core which pulled the latest version from the registry (3.20.3),
which turned out to be a broken release missing its dist/ directory. The
fix introduces a getPinnedVersions() function that reads the actual
installed version from the workspace's node_modules and installs that
exact version (e.g. @tiptap/core@3.13.0). It also adds @tiptap/pm,
react, and react-dom as dependencies (previously missing), while
removing the old @tiptap/react and @tiptap/core entries from the
unpinned list.
Module resolution for tiptap subpath exports. Packages like @tiptap/pm
use subpath exports (@tiptap/pm/state, @tiptap/pm/model, etc.) which
only resolve when TypeScript's moduleResolution is set to "bundler". The
generated tsconfig had no explicit module settings, so tsc defaulted to
node10 resolution which ignores the exports field entirely. The fix adds
module: "esnext" and moduleResolution: "bundler" to the generated
tsconfig.
### Change type
- [x] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [x] `api`
- [x] `other`
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches internal build/typecheck tooling and changes dependency
resolution/order; mistakes could break CI or local developer workflows
but does not affect runtime product behavior.
>
> **Overview**
> Fixes fresh-checkout failures in internal TypeScript verification
scripts.
>
> `internal/scripts/typecheck.ts` now topologically sorts package
`tsconfig.json` files by their `references` and bootstraps `tsgo
--build` one package at a time (leaves first) to ensure declarations
exist before dependents build.
>
> `internal/scripts/api-check.ts` updates the generated `tsconfig` to
use `module: "esnext"` and `moduleResolution: "bundler"` and pins
`@tiptap/*` installs to the workspace-resolved versions (plus adds
`react`/`react-dom` deps) to avoid broken upstream releases and subpath
export resolution issues during the API typecheck.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d2f78eb. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Guillaume <guillaume@tldraw.com>1 parent a91c1d1 commit 4793bee
2 files changed
Lines changed: 68 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
21 | 33 | | |
22 | 34 | | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
| 40 | + | |
| 41 | + | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
| |||
61 | 75 | | |
62 | 76 | | |
63 | 77 | | |
64 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
65 | 81 | | |
66 | 82 | | |
67 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
106 | 152 | | |
107 | 153 | | |
108 | 154 | | |
| |||
0 commit comments