Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

tml-2766: untangle authoring data from runtime target descriptors - #688

Merged
SevInf merged 6 commits into
mainfrom
bundle-size-opt
Jun 2, 2026
Merged

SevInf merged 6 commits into
mainfrom
bundle-size-opt

Conversation

@SevInf

@SevInf SevInf commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Restores the invariant that a targets runtime descriptor carries only metadata the runtime plane reads. Drops 74.0 KiB raw / 17.3 KiB gzipped from the examples/bundle-size postgres emit-minified bundle (445.7 → 371.7 KiB raw, 125.3 → 108.0 KiB gzipped).

Fixes TML-2766.

What changed

postgresTargetDescriptorMeta and sqliteTargetDescriptorMeta were silently carrying an authoring: { type, field, entityTypes } slot — control-plane data read at contract-construction time, never at runtime. The runtime export was spreading the same constant pack + control did, pulling authoring.ts → temporalAuthoringPresets from @prisma-next/family-sql/control → verify-sql-schema-*.mjs into the runtime closure for no benefit.

For postgres and sqlite:

  • New descriptor-meta-runtime.ts carries only runtime-safe metadata (kind/familyId/targetId/id/version/capabilities + the __codecTypes phantom).
  • Existing descriptor-meta.ts composes runtime-safe base + authoring slot; same exported name + shape, so pack + control consumers dont change.
  • Runtime export re-points at the runtime-safe file.

The architectural invariant survives at the source level. Rolldowns auto-chunker then merged authoring.ts and descriptor-meta-runtime.ts into a single dist chunk anyway (they share a reachability set via descriptor-meta.ts), defeating the source-level split at the dist level. To close the loop at the bundler level:

  • temporalAuthoringPresets in @prisma-next/family-sql/src/core/timestamp-now-generator.ts gets /* @__NO_SIDE_EFFECTS__ */ on the function definition.
  • Its two call sites in postgres + sqlite authoring.ts get per-call-site /* @__PURE__ */ (esbuild ignores NSE on imported function declarations; the per-call annotation is what actually closes the chain at the examples bundling step).
  • @prisma-next/contracts CrossReferenceSchema initializer gets /* @__PURE__ */ on both blindCast(...) and type({...}) — pure tidying. No measurable bundle effect today because arktypes all-or-nothing module-init keeps the @ark/schema graph alive through other workspace importers, but the annotation is a true statement and harmless to keep.

Tooling

examples/bundle-size/scripts/bundle.ts now persists esbuild metafiles next to each artifact; examples/bundle-size/scripts/why.ts is a new metafile reverse-graph BFS tracer.

Out of scope

  • The @ark/schema/* graph (~150 KiB) still in the postgres bundle. Removing it would require closing every runtime-reachable workspace importer of import { type } from "arktype" simultaneously (arktypes type factory is a module-init-time singleton that touches the whole schema graph; partial closure achieves nothing). Separate architectural decision: does the SQL runtime need arktype validation on hot paths at all?
  • Lazy-loading sql-orm-client from the postgres factory (155.8 KiB). Behavioural change to the public runtime surface, separate design call.

Verification

  • pnpm typecheck workspace-wide: clean.
  • pnpm lint:deps: clean.
  • pnpm test:packages for @prisma-next/{target-postgres,target-sqlite,contract,family-sql}: green.
  • examples/bundle-size pnpm test postgres path: green (mongo env-blocked on local NixOS host).
postgres / emit / minified gzip
Baseline 445.7 KiB 125.3 KiB
This PR 371.7 KiB (–74.0) 108.0 KiB (–17.3)

Note on lint: per-package biome lint is env-blocked on the local NixOS development host (biomes linux-arm64 binary, NixOS dynamic linker incompatibility). pnpm lint gate must be re-verified in CI before merge.

Summary by CodeRabbit

  • New Features

    • Added a bundle-analysis CLI to inspect build metafiles and show shortest import chains to matched inputs.
    • Bundle tooling now saves a readable metafile alongside each bundled output.
  • Chores

    • Added runtime-only target metadata modules and changed runtime descriptors to compose from them.
    • Marked helpers and presets as side-effect-free to improve tree-shaking and dead-code elimination.

@SevInf
SevInf requested a review from a team as a code owner June 2, 2026 09:25
@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@SevInf, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 18 minutes and 14 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: e69aad99-dbd8-4b34-a745-a4d403830307

📥 Commits

Reviewing files that changed from the base of the PR and between 16c6fea and 39e8182.

📒 Files selected for processing (13)
  • examples/bundle-size/scripts/bundle.ts
  • examples/bundle-size/scripts/why.ts
  • packages/1-framework/0-foundation/contract/src/cross-reference.ts
  • packages/2-sql/9-family/src/core/timestamp-now-generator.ts
  • packages/3-targets/3-targets/postgres/src/core/authoring.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta.ts
  • packages/3-targets/3-targets/postgres/src/exports/runtime.ts
  • packages/3-targets/3-targets/sqlite/src/core/authoring.ts
  • packages/3-targets/3-targets/sqlite/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/sqlite/src/core/descriptor-meta.ts
  • packages/3-targets/3-targets/sqlite/src/core/runtime-target.ts
  • skills/upgrade/prisma-next-upgrade/upgrades/0.12-to-0.13/instructions.md
📝 Walkthrough

Walkthrough

This PR writes esbuild metafiles beside bundle outputs, adds a CLI to analyze metafiles (reverse-import graph + shortest entry→target chains), and separates runtime-only target metadata while annotating helper/schema calls for bundler tree-shaking.

Changes

Bundle Analysis & Runtime Tree-Shaking

Layer / File(s) Summary
Bundle metafile output and analysis tooling
examples/bundle-size/scripts/bundle.ts, examples/bundle-size/scripts/why.ts
bundle.ts writes esbuild metafile JSON next to outputs; why.ts CLI reads a metafile, builds a reverse-import graph, identifies entry points, and prints shortest entry→target chains for matched inputs sorted by bytes.
Foundation contract pure annotations
packages/1-framework/0-foundation/contract/src/cross-reference.ts
CrossReferenceSchema construction is wrapped with /* @PURE */ annotations to mark it pure for bundlers.
Temporal authoring presets tree-shaking annotations
packages/2-sql/9-family/src/core/timestamp-now-generator.ts, packages/3-targets/3-targets/postgres/src/core/authoring.ts, packages/3-targets/3-targets/sqlite/src/core/authoring.ts
Core temporalAuthoringPresets marked /* @NO_SIDE_EFFECTS */ and call sites in Postgres/SQLite authoring presets wrapped with /* @PURE */ to enable dead-code elimination when presets are unreachable.
Postgres runtime-only descriptor metadata separation
packages/3-targets/3-targets/postgres/src/core/descriptor-meta-runtime.ts, packages/3-targets/3-targets/postgres/src/core/descriptor-meta.ts, packages/3-targets/3-targets/postgres/src/exports/runtime.ts
Adds postgresTargetDescriptorMetaRuntime with runtime-safe metadata and updates descriptor composition and runtime export to use it.
SQLite runtime-only descriptor metadata separation
packages/3-targets/3-targets/sqlite/src/core/descriptor-meta-runtime.ts, packages/3-targets/3-targets/sqlite/src/core/descriptor-meta.ts, packages/3-targets/3-targets/sqlite/src/core/runtime-target.ts
Adds sqliteTargetDescriptorMetaRuntime and updates descriptor composition and runtime target to derive metadata from the runtime module.
Upgrade instructions metadata
skills/upgrade/prisma-next-upgrade/upgrades/0.12-to-0.13/instructions.md
Updates front-matter to indicate upgrade from 0.12 to 0.13 with an empty changes array.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • prisma/prisma-next#621: Touches examples/bundle-size tooling, related to bundle-size scripts and metafile usage.

Suggested Reviewers

  • wmadden
  • aqrln

"I hop through bundles, sniff each tiny trace,
I mark what's pure so trees leave no waste,
Metadata split keeps runtime light and neat,
Gzips and maps saved for curious feet,
A rabbit cheers as builders shrink their feat."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective: untangling authoring data from runtime target descriptors, which is the core architectural change across postgres and sqlite descriptor modules.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bundle-size-opt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/@prisma-next/extension-author-tools@688

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/@prisma-next/mongo-runtime@688

@prisma-next/family-mongo

npm i https://pkg.pr.new/@prisma-next/family-mongo@688

@prisma-next/sql-runtime

npm i https://pkg.pr.new/@prisma-next/sql-runtime@688

@prisma-next/family-sql

npm i https://pkg.pr.new/@prisma-next/family-sql@688

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/@prisma-next/extension-arktype-json@688

@prisma-next/middleware-cache

npm i https://pkg.pr.new/@prisma-next/middleware-cache@688

@prisma-next/mongo

npm i https://pkg.pr.new/@prisma-next/mongo@688

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/@prisma-next/extension-paradedb@688

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/@prisma-next/extension-pgvector@688

@prisma-next/extension-postgis

npm i https://pkg.pr.new/@prisma-next/extension-postgis@688

@prisma-next/postgres

npm i https://pkg.pr.new/@prisma-next/postgres@688

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/@prisma-next/sql-orm-client@688

@prisma-next/sqlite

npm i https://pkg.pr.new/@prisma-next/sqlite@688

@prisma-next/target-mongo

npm i https://pkg.pr.new/@prisma-next/target-mongo@688

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/@prisma-next/adapter-mongo@688

@prisma-next/driver-mongo

npm i https://pkg.pr.new/@prisma-next/driver-mongo@688

@prisma-next/contract

npm i https://pkg.pr.new/@prisma-next/contract@688

@prisma-next/utils

npm i https://pkg.pr.new/@prisma-next/utils@688

@prisma-next/config

npm i https://pkg.pr.new/@prisma-next/config@688

@prisma-next/errors

npm i https://pkg.pr.new/@prisma-next/errors@688

@prisma-next/framework-components

npm i https://pkg.pr.new/@prisma-next/framework-components@688

@prisma-next/operations

npm i https://pkg.pr.new/@prisma-next/operations@688

@prisma-next/ts-render

npm i https://pkg.pr.new/@prisma-next/ts-render@688

@prisma-next/contract-authoring

npm i https://pkg.pr.new/@prisma-next/contract-authoring@688

@prisma-next/ids

npm i https://pkg.pr.new/@prisma-next/ids@688

@prisma-next/psl-parser

npm i https://pkg.pr.new/@prisma-next/psl-parser@688

@prisma-next/psl-printer

npm i https://pkg.pr.new/@prisma-next/psl-printer@688

@prisma-next/cli

npm i https://pkg.pr.new/@prisma-next/cli@688

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/@prisma-next/cli-telemetry@688

@prisma-next/emitter

npm i https://pkg.pr.new/@prisma-next/emitter@688

@prisma-next/migration-tools

npm i https://pkg.pr.new/@prisma-next/migration-tools@688

prisma-next

npm i https://pkg.pr.new/prisma-next@688

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/@prisma-next/vite-plugin-contract-emit@688

@prisma-next/mongo-codec

npm i https://pkg.pr.new/@prisma-next/mongo-codec@688

@prisma-next/mongo-contract

npm i https://pkg.pr.new/@prisma-next/mongo-contract@688

@prisma-next/mongo-value

npm i https://pkg.pr.new/@prisma-next/mongo-value@688

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/@prisma-next/mongo-contract-psl@688

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/@prisma-next/mongo-contract-ts@688

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/@prisma-next/mongo-emitter@688

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/@prisma-next/mongo-schema-ir@688

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/@prisma-next/mongo-query-ast@688

@prisma-next/mongo-orm

npm i https://pkg.pr.new/@prisma-next/mongo-orm@688

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/@prisma-next/mongo-query-builder@688

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/@prisma-next/mongo-lowering@688

@prisma-next/mongo-wire

npm i https://pkg.pr.new/@prisma-next/mongo-wire@688

@prisma-next/sql-contract

npm i https://pkg.pr.new/@prisma-next/sql-contract@688

@prisma-next/sql-errors

npm i https://pkg.pr.new/@prisma-next/sql-errors@688

@prisma-next/sql-operations

npm i https://pkg.pr.new/@prisma-next/sql-operations@688

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/@prisma-next/sql-schema-ir@688

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/@prisma-next/sql-contract-psl@688

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/@prisma-next/sql-contract-ts@688

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/@prisma-next/sql-contract-emitter@688

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/@prisma-next/sql-lane-query-builder@688

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/@prisma-next/sql-relational-core@688

@prisma-next/sql-builder

npm i https://pkg.pr.new/@prisma-next/sql-builder@688

@prisma-next/target-postgres

npm i https://pkg.pr.new/@prisma-next/target-postgres@688

@prisma-next/target-sqlite

npm i https://pkg.pr.new/@prisma-next/target-sqlite@688

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/@prisma-next/adapter-postgres@688

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/@prisma-next/adapter-sqlite@688

@prisma-next/driver-postgres

npm i https://pkg.pr.new/@prisma-next/driver-postgres@688

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/@prisma-next/driver-sqlite@688

commit: 39e8182

@github-actions

github-actions Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 135.96 KB (+0.03% 🔺)
postgres / emit 108.24 KB (-13.82% 🔽)
mongo / no-emit 75.69 KB (0%)
mongo / emit 70.68 KB (0%)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/3-targets/3-targets/sqlite/src/core/authoring.ts (1)

5-13: ⚡ Quick win

Trim this block comment and point to the bundler docs instead.

This explanation is doing too much inline. Please keep a short invariant note here and link the canonical esbuild pure-annotation/tree-shaking docs instead of embedding the tool-behavior details in source.

As per coding guidelines, "Prefer links to canonical docs over long comments."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/3-targets/3-targets/sqlite/src/core/authoring.ts` around lines 5 -
13, Replace the long explanatory block above the temporalAuthoringPresets call
with a short invariant note and a canonical-link to esbuild's
pure-annotation/tree-shaking docs: keep a one-line comment that states why the
call is marked pure (so esbuild can tree-shake the
sqliteAuthoringFieldPresets/temporalAuthoringPresets path) and include a URL to
esbuild's documentation instead of the detailed tool-behavior text; ensure the
reference still mentions temporalAuthoringPresets and family-sql/control so
intent is clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/3-targets/3-targets/sqlite/src/core/authoring.ts`:
- Around line 5-13: Replace the long explanatory block above the
temporalAuthoringPresets call with a short invariant note and a canonical-link
to esbuild's pure-annotation/tree-shaking docs: keep a one-line comment that
states why the call is marked pure (so esbuild can tree-shake the
sqliteAuthoringFieldPresets/temporalAuthoringPresets path) and include a URL to
esbuild's documentation instead of the detailed tool-behavior text; ensure the
reference still mentions temporalAuthoringPresets and family-sql/control so
intent is clear.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: b37b9426-2b46-49f5-9ff4-0d6632313d11

📥 Commits

Reviewing files that changed from the base of the PR and between a6cb914 and bcf43aa.

📒 Files selected for processing (12)
  • examples/bundle-size/scripts/bundle.ts
  • examples/bundle-size/scripts/why.ts
  • packages/1-framework/0-foundation/contract/src/cross-reference.ts
  • packages/2-sql/9-family/src/core/timestamp-now-generator.ts
  • packages/3-targets/3-targets/postgres/src/core/authoring.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta.ts
  • packages/3-targets/3-targets/postgres/src/exports/runtime.ts
  • packages/3-targets/3-targets/sqlite/src/core/authoring.ts
  • packages/3-targets/3-targets/sqlite/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/sqlite/src/core/descriptor-meta.ts
  • packages/3-targets/3-targets/sqlite/src/core/runtime-target.ts

@SevInf
SevInf force-pushed the bundle-size-opt branch 3 times, most recently from b2ba33e to 87cda35 Compare June 2, 2026 10:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/2-sql/9-family/src/core/timestamp-now-generator.ts`:
- Around line 47-59: Shorten the long bundler note around the /*
`@__NO_SIDE_EFFECTS__` */ annotation to a concise Rollup/Rollup-family specific
remark (remove references to esbuild and the long walkthrough), state that the
annotation allows Rollup-style tree-shaking of a no-side-effect call, and add a
pointer to the canonical notation spec URL
(https://github.com/javascript-compiler-hints/compiler-notations-spec/blob/main/no-side-effects-notation-spec.md)
so readers can follow the authoritative definition; keep the actual /*
`@__NO_SIDE_EFFECTS__` */ comment in place and only replace the surrounding
explanatory block with the shorter Rollup-specific note.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: ff1947ba-05cc-48ef-a476-b7611e1d121c

📥 Commits

Reviewing files that changed from the base of the PR and between ef3628a and b2ba33e.

📒 Files selected for processing (12)
  • examples/bundle-size/scripts/bundle.ts
  • examples/bundle-size/scripts/why.ts
  • packages/1-framework/0-foundation/contract/src/cross-reference.ts
  • packages/2-sql/9-family/src/core/timestamp-now-generator.ts
  • packages/3-targets/3-targets/postgres/src/core/authoring.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta.ts
  • packages/3-targets/3-targets/postgres/src/exports/runtime.ts
  • packages/3-targets/3-targets/sqlite/src/core/authoring.ts
  • packages/3-targets/3-targets/sqlite/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/sqlite/src/core/descriptor-meta.ts
  • packages/3-targets/3-targets/sqlite/src/core/runtime-target.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/1-framework/0-foundation/contract/src/cross-reference.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • examples/bundle-size/scripts/bundle.ts
  • packages/3-targets/3-targets/postgres/src/core/authoring.ts
  • packages/3-targets/3-targets/sqlite/src/core/authoring.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta.ts
  • packages/3-targets/3-targets/postgres/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/postgres/src/exports/runtime.ts
  • examples/bundle-size/scripts/why.ts
  • packages/3-targets/3-targets/sqlite/src/core/descriptor-meta-runtime.ts
  • packages/3-targets/3-targets/sqlite/src/core/runtime-target.ts

@SevInf
SevInf force-pushed the bundle-size-opt branch from 87cda35 to 16c6fea Compare June 2, 2026 10:27
SevInf added 6 commits June 2, 2026 10:36
Persist each bundle’s esbuild metafile alongside the .mjs/.gz output and
add scripts/why.ts, a metafile reverse-graph BFS that traces the shortest
import path from an entry point to a given input substring.

Used to diagnose the bundle-size regression closed by TML-2766: the
metafiles surface the actual top inputs, and why.ts pinpoints the import
chain that drags each unwanted module into a target’s runtime closure.

Kept as a permanent investigative tool so future bundle-size investigations
can reuse the same workflow.

Signed-off-by: Serhii Tatarintsev <[email protected]>
…L-2766)

Add packages/3-targets/3-targets/postgres/src/core/descriptor-meta-runtime.ts
carrying only the identifiers + capabilities the runtime plane reads
(kind/familyId/targetId/id/version/capabilities + the __codecTypes phantom).
Refactor descriptor-meta.ts to compose from that base and add the authoring
slot on top. Re-point exports/runtime.ts at the new runtime-safe meta;
exports/control.ts and exports/pack.ts continue to import the full meta and
remain shape-compatible.

The runtime descriptor never read descriptor.authoring.*; only
assembleAuthoringContributions (control plane) and the PSL interpreter
do. Spreading the full meta into the runtime export was dragging
@prisma-next/family-sql/control (and its sibling verify-sql-schema chunk)
into the runtime closure for no runtime benefit. With the split, the
runtime entry’s reachability graph is genuinely free of ./authoring, so
the bundler can drop the control-plane modules.

External shape and name (postgresTargetDescriptorMeta) are preserved.

Signed-off-by: Serhii Tatarintsev <[email protected]>
…2766)

Mirror of the postgres split. Add core/descriptor-meta-runtime.ts carrying
only the identifiers + capabilities the runtime plane reads
(kind/familyId/targetId/id/version/capabilities + the __codecTypes
phantom). Refactor core/descriptor-meta.ts to compose from that base and
add the authoring slot on top (sqlite’s authoring slot only carries
field). Re-point core/runtime-target.ts at the runtime-safe meta;
core/control-target.ts and exports/pack.ts continue to import the full
meta unchanged.

External shape and name (sqliteTargetDescriptorMeta) are preserved.

Signed-off-by: Serhii Tatarintsev <[email protected]>
…haking (TML-2766)

Annotate both the outer blindCast(...) and the inner type({...}) call with
/* @__PURE__ */. arktype does not declare sideEffects: false, so without
these hints any consumer of @prisma-next/contract/types pulls the full
@ark/schema runtime — including type-only consumers, since the barrel
re-exports CrossReferenceSchema as a value alongside the types.

Both annotations are required. The inner annotation lets the bundler drop
the type({...}) call when blindCast(...) is unreferenced; without it, the
outer call can be dropped but type(...) would remain, dragging @ark/schema
with it.

The annotations are pure comments and do not affect runtime behaviour for
consumers that do reference CrossReferenceSchema — they still receive a
constructed schema.

Signed-off-by: Serhii Tatarintsev <[email protected]>
…or tree-shaking (TML-2766)

Annotate the `temporalAuthoringPresets` function declaration in
packages/2-sql/9-family/src/core/timestamp-now-generator.ts with
/* @__NO_SIDE_EFFECTS__ */. tsdown preserves the annotation through to
family-sql/dist/timestamp-now-generator-*.mjs (verified), so any rolldown
or esbuild consumer that reads the function declaration sees the marker.

Fallback after NSE-on-definition turned out to be ineffective at the
final esbuild bundling step: esbuild does propagate /* @__PURE__ */ on
call expressions but does NOT honour @__NO_SIDE_EFFECTS__ on imported
function declarations (rolldown/rollup do — that mismatch is what bit
the bundle measurement in R1). The fallback per-call-site annotation in
postgres/src/core/authoring.ts and sqlite/src/core/authoring.ts marks
each top-level temporalAuthoringPresets({...}) call pure at the consumer
end, which esbuild does respect.

With the call expressions marked pure and the call sites unreachable
from the runtime entry (per the R1 descriptor split), esbuild drops the
whole authoring chunk from the runtime closure:

* family-sql/dist/control.mjs        — 67.8 KiB in inputs / 0 bytes in output
* family-sql/dist/verify-sql-schema  — 43.2 KiB in inputs / 0 bytes in output

The metafile still records the modules as touched (esbuild keeps dead
imports in the input graph) but their bytesInOutput is zero. Result:
postgres emit minified drops from 445.7 KiB baseline to 371.7 KiB
(74.0 KiB drop). The remaining gap to the 365 KiB AC is occupied
entirely by @ark/schema/* (~80 KiB in output) coming in via
sql-orm-client → contract/types → arktype, which is Sibling B and
deferred to a follow-up Linear ticket.

Signed-off-by: Serhii Tatarintsev <[email protected]>
…766)

The diff in `examples/bundle-size/scripts/` (metafile emission + why.ts tracer) is internal tooling for the bundle-size example. No consumer-facing API changed; `changes: []` is the explicit record per the record-upgrade-instructions skill.

Signed-off-by: Serhii Tatarintsev <[email protected]>
@SevInf
SevInf force-pushed the bundle-size-opt branch from 16c6fea to 39e8182 Compare June 2, 2026 10:36
@SevInf
SevInf merged commit 3ff5e1f into main Jun 2, 2026
20 checks passed
@SevInf
SevInf deleted the bundle-size-opt branch June 2, 2026 10:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant