chore(glyph): drop the @types/three patch and unship typescript - #83
Merged
Conversation
size-limit report 📦
|
Two dependency problems that both landed on consumers. TypeScript was a hard runtime dependency, so every consumer downloaded a 3.5 MB alpha to render text. The module graph was already lazy: the built `dist/node/bake.js` reaches discovery only through `await import()`, discovery is reachable only from the Node-only `./bake` subpath, and nothing in the browser graph touches the compiler. It was a manifest bug, not an architecture problem. It becomes a devDependency rather than a peer. An exact `7.0.2` peer would demand every consumer's project sit on a TypeScript alpha and warn at all of them, and it only mirrored an assertion the code already makes: `compiler-adapter` version-checks at runtime and throws a message naming the required version. That assertion is the real contract. Project- discovery bake resolves the compiler from wherever the consumer has it; everyone else never sees it. For reference, r3f ships no typescript dependency in any field and no runtime reference to it. The 171-line `@types/three` patch existed because `Node<T>` was a 20-deep conditional chain that made ordinary TSL expressions expand pathologically, and because `Node<T>` is a type alias, module augmentation could never have replaced it. That fix is upstream in `@types/three@0.185.4` -- `NodeExtras` lookup table present, conditional chain gone -- so the pin moves up across all four workspace manifests and the patch is deleted. Two residuals are not upstream. `modelViewProjection` is still declared as an unparameterized `Node`, which is narrowed once at the boundary in `bitmap-shader.ts` rather than cast per use; the TSL fixture keeps a `@ts-expect-error` tripwire that fails when DefinitelyTyped narrows it, so the local narrowing gets deleted rather than forgotten. The patch's `Loop` hunk turned out to be unnecessary and is simply gone. This matters beyond tidiness: the published declarations import from `three/webgpu` nine times and were only ever type-checked against the patched types, while consumers resolve stock ones. Package-size evidence and the package concept digests are regenerated. Neither concept doc asserts anything about the dependency set or the patch, so only the pins moved.
thejustinwalsh
force-pushed
the
chore/drop-types-three-patch
branch
from
August 20, 2026 14:24
a12ee09 to
797a523
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two dependency problems that both landed on consumers. Found while auditing canary readiness; fixed rather than filed.
TypeScript was a hard runtime dependency
Every consumer downloaded
typescript@7.0.2— a 3.5 MB alpha — to render text.The module graph was already correct. The built
dist/node/bake.jsreaches discovery only through a dynamic import, and nothing outsidecompiler-adapterreferences the compiler:Discovery is reachable only from the Node-only
./bakesubpath, and nothing in the browser graph touches the compiler. So this was a manifest bug, not an architecture problem, and needed no restructuring.It becomes a devDependency, not a peer. An exact
7.0.2peer would demand every consumer's project sit on a TypeScript alpha and warn at all of them — and it only mirrored an assertion the code already makes:That runtime check is the real contract. Project-discovery bake resolves the compiler from wherever the consumer has it; everyone else never sees it.
For reference,
@react-three/fiber@10.0.0-alpha.2declarestypescriptin no field at all and its shippeddist/contains zero references to it — TypeScript is purely a build tool at their monorepo root.The
@types/threepatch is deleted, because the fix is upstreamThe 171-line patch existed for a real reason:
Node<T>was a 20-deep nested conditional chain that made ordinary TSL expressions expand pathologically. And becauseNode<T>is a type alias, module augmentation could never have replaced it — TypeScript can't augment type aliases. That's why it was a patch and not a.d.tsin our tree.That fix landed upstream in
@types/three@0.185.4:interface NodeExtrasNodeExtras[TNodeType]indexed accessWe were one patch release behind a fix we were carrying locally. All four workspace pins move to
0.185.4and the patch is deleted.Two residuals, handled internally
Not upstream yet:
modelViewProjectionis still declared as an unparameterizedNode. Narrowed once at the boundary intsl/bitmap-shader.tsrather than cast at each use.Loophunk turned out to be unnecessary — removing it produced no errors.The TSL fixture keeps a
@ts-expect-errortripwire rather than a silent workaround: it fails when DefinitelyTyped narrows the export, so the local narrowing gets deleted rather than forgotten.Why this mattered beyond tidiness
The published
.d.tsimport fromthree/webgpunine times and were only ever type-checked against the patched types. Consumers resolve stock ones. With the patch gone and the pin bumped, what we ship and what they resolve are finally the same declarations.Verification
pnpm check— exit 0, OKF 0 errors / 0 warningstsc -p tsconfig.build.json— 0 errors with the patch removedthree-runtime-jsraw 376,899 against the 377,000 ceiling (101 bytes headroom); minified is 6 bytes smaller than baseline, since the narrowing collapsed a repeated reference. gzip and brotli unchanged or better.Not in this PR
@pmndrs/glyphstill has no README, so the npm page is blank — including no note that TypeScript consumers supply their own@types/three, which is the ecosystem convention rather than a peer declaration. That belongs with the other canary-readiness doc fixes.