Skip to content

fix(eve): vendor content-hashed declaration chunks (chat, @chat-adapter/twilio) - #1534

Open
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:fix/1500-missing-declaration-chunks
Open

fix(eve): vendor content-hashed declaration chunks (chat, @chat-adapter/twilio)#1534
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:fix/1500-missing-declaration-chunks

Conversation

@iroiro147

Copy link
Copy Markdown
Contributor

Problem

chat and @chat-adapter/twilio both ship content-hashed sibling declaration chunks that their index.d.ts (or sibling entry .d.ts) imports by relative path:

  • chat/dist/messages-BSoJG691.d.ts (145 type/interface/class declarations — Message, Thread, Channel, ActionEvent, Author, MessageData, Attachment, …)
  • @chat-adapter/twilio/dist/types-WYjTBVDi.d.ts (15 declarations — TwilioWebhookUrl, TwilioVerifiedRequest, TwilioVerifyOptions, TwilioWebhookPayload, …)

packages/eve/scripts/vendor-compiled/chat.mjs only matched jsx-runtime-<hash>.d.ts via discoverExtraFiles, and vendor-compiled/@chat-adapter/twilio.mjs had no discovery block at all. Those chunks were dropped from the published eve tarball while index.d.ts still references them by relative path, so consumers of eve's #compiled/chat and #compiled/@chat-adapter/twilio namespaces see:

  • ~120+ type exports degrade to any (skipLibCheck: true, the default),
  • TS2307: Cannot find module './messages-….js' / './types-….js' with skipLibCheck: false,
  • downstream noise like TS2741: Property 'fullName' is missing in type … once the leaked symbols re-route through Author/MessageData/Thread.

Resolves #1500.

Fix

packages/eve/scripts/vendor-compiled/_shared.mjs (createDeclarationCopier) — previously discoverExtraFiles-selected files were copied verbatim via copyFile after the named files went through the rewrite pass. Chat's messages-<hash>.d.ts contains import { Root } from 'mdast' and import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde' — bare specifiers that cannot reach the published package (no @types/mdast, no @workflow/serde declaration in closure). Extras must flow through the same rewrite pipeline.

Fold extras into the declarations array before mergeExternalDeclarationImports runs, so the existing vendored/stub/external rule matrix applies uniformly. Drop the tailing verbatim copyFile block (it would otherwise overwrite the rewritten outputs with the un-rewritten sources).

packages/eve/scripts/vendor-compiled/chat.mjs — broaden the matcher from ^jsx-runtime-[^./]+\.d\.ts$ to ^(jsx-runtime|messages)-[^./]+\.d\.ts$. The hash suffix is content-derived and drifts every upstream build, so keep matching on basename + any tail.

packages/eve/scripts/vendor-compiled/@chat-adapter/twilio.mjs — add a discoverExtraFiles block matching ^types-[^./]+\.d\.ts$, mirroring @chat-adapter/slack.mjs's pre-existing shape.

Type-graph side-effects. Precise types from the copied chunk expose a small set of sites in eve that were silently relying on the previous any fallback:

  • src/public/channels/chat-sdk/chatSdkChannel.ts: ActionEvent.thread is Thread<TRawMessage, unknown>; cast through the declared Thread alias on the ChatSdkSendOptions.thread field so the existing TState = Record<string, unknown> default applies.
  • src/public/channels/photon/inboundContent.test.ts: add the now-required formatted (mdast Root), metadata ({dateSent, edited}), and fullName (Author) fields to the new Message({...}) mock.
  • src/public/channels/photon/photonIMessageChannel.test.ts: same three mocks, plus attachments: [] each.

.changeset/fix-1500-missing-declaration-chunks.md"eve": patch.

Verification

Gate Result
Fresh worktree + pnpm install --frozen-lockfile
node scripts/vendor-compiled.mjs (all 41 modules) messages-BSoJG691.d.ts alongside jsx-runtime-_JEEAotp.d.ts in .generated/compiled/chat/; types-WYjTBVDi.d.ts in .generated/compiled/@chat-adapter/twilio/
Rewrites applied to chunk from './_mdast.js' on line 2, from './_workflow-serde.js' on line 1 of the copied messages-BSoJG691.d.ts
npx tsc --noEmit -p tsconfig.json (full package) 0 errors (baseline main: 5 — all the photon fullName/MessageData mocks tightened here)
npx tsc -p tsconfig.build.json (production build types) ✓ exit 0
pnpm run test:unit 5870 pass / 4 fail — identical to baseline main; all 4 failures are test/bin-bootstrap.test.ts gating on Node.js ≥24 (running on v22.22.3 locally), unrelated
Targeted tsc probe with skipLibCheck: false against .generated/compiled/ ✓ zero TS2307 on ./messages-… or ./types-… — the #1500 repro closes
npx oxlint --fix on touched paths ✓ exit 0

Out of scope maintained

  • Identical 4 bin-bootstrap failures match baseline (Node env).
  • The 5 baseline tsc --noEmit errors were in the same photon test mocks tightened here — those leaks were only visible without the precise type graph.
  • No upstream package edits; no unrelated refactors.

DCO-signed.

/test

The chat and @chat-adapter/twilio vendor configs previously only matched
`jsx-runtime-<hash>.d.ts` (chat) or nothing at all (twilio) via
`discoverExtraFiles`. The upstream bundler emits additional content-hashed
declaration chunks — `messages-BSoJG691.d.ts` (chat) and
`types-WYjTBVDi.d.ts` (twilio) — that index.d.ts imports by relative path.
Drop those chunks from the published tarball and ~120 chat exports plus
~10 twilio exports degrade to `any`; consumers with `skipLibCheck: false`
hit TS2307 + TS2741 (see vercel#1500).

Extend `createDeclarationCopier` so the discoverExtraFiles-selected chunks
flow through the same rewrite pass (mdast stub, @workflow/serde symbol
stub, …) as the named entry files — the chunk contains `import { Root }
from 'mdast'` and would otherwise leak a bare specifier that the published
package cannot resolve. Then broaden the chat regex to also match
`messages-<hash>.d.ts` and add the twilio discovery block patterned after
@chat-adapter/slack's.

Co-copying the chunk surfaces the chat type graph precisely, which
exposes a small set of type-surface leaks in eve sources and tests that
were silently relying on the previous `any` fallback. Tighten them:

- chatSdkChannel.ts: `Thread<TRawMessage, unknown>` from `ActionEvent` no
  longer coerces silently to the declared `Thread` (TState = Record<…>)
  parameter of `ChatSdkSendOptions.thread` — cast the event.thread field
  through the declared alias.
- photon channel tests: `new Message({...})` mocks lacked the now-required
  `formatted` (mdast Root), `metadata` (dateSent + edited), and `attachments`
  fields; supplement them so the strict constructor accepts the object.
- photon channel tests: `Author` mocks lacked the newly-strict `fullName`
  field.

Verified: `pnpm build:compiled` regenerates `.generated/compiled/` with
both chunks present and the mdast/@workflow/serde rewrites applied to the
copied chunk (`from './_mdast.js'`, `from './_workflow-serde.js'`);
`npx tsc --noEmit -p tsconfig.json` drops from 5 pre-existing errors to 0;
`npx tsc -p tsconfig.build.json` passes; `pnpm run test:unit` passes
5870/5875 (the 5 baseline Node-v24-bootstrap failures are unchanged).

Resolves vercel#1500.

Signed-off-by: Sarthak Singh <sarthak.singh@juspay.in>
Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@iroiro147 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@iroiro147

Copy link
Copy Markdown
Contributor Author

Standing-health check (re-verified against current main 021dbbf2, 2 commits past this branch's base):

  • Merge dry-run vs current main: clean, zero conflicts. The 2 new commits touch cli/dev/tui + a version-package bump — disjoint from this PR's fix surface.
  • mergeable_state shows unknown (GitHub recomputing after the main bump) — merge dry-run confirms it resolves to clean/mergeable.
  • CI: unit/windows/e2e/Vercel-deploy failing are fork-CI infrastructure constraints (Vercel deploy Authorization required, e2e needs Pro sandbox credentials), not regressions from this change.

Ready for review whenever convenient; no action required from contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Published package omits two declaration chunks its own .d.ts files import (chat/messages-BSoJG691, @chat-adapter/twilio/types-WYjTBVDi)

1 participant