Skip to content

fix(build): co-copy rollup content-hashed sibling .d.ts chunks (#1500) - #1503

Open
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:claude/issue1500-20260801
Open

fix(build): co-copy rollup content-hashed sibling .d.ts chunks (#1500)#1503
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:claude/issue1500-20260801

Conversation

@iroiro147

Copy link
Copy Markdown
Contributor

Summary

Fixes #1500 — published eve package was silently missing two rollup content-hashed sibling declaration chunks that its own vendored .d.ts files import:

  • chat's messages-BSoJG691.d.ts (referenced from chat/index.d.ts)
  • @chat-adapter/twilio's types-WYjTBVDi.d.ts (referenced from @chat-adapter/twilio/webhook.d.ts)

The type hole degraded ~120 exported names across the Chat SDK surface (Adapter, Chat, ChatInstance, Message, Thread, Attachment, FileUpload, PostableCard, PostableMessage, StateAdapter, UserInfo, …) plus TwilioWebhookUrl / TwilioVerifiedRequest to any under the default skipLibCheck: true, and surfaced as TS2307: Cannot find module './messages-BSoJG691.js' under skipLibCheck: false.

Root cause

createDeclarationCopier (packages/eve/scripts/vendor-compiled/_shared.mjs) had two ways to bring upstream .d.ts files into the vendored output:

  1. Explicit files: — hardcoded list (twilio listed only its 5 entry points).
  2. discoverExtraFiles — a per-package filename matcher (chat listed only jsx-runtime-<hash>.d.ts).

Meanwhile collectExternalDeclarationImports deliberately skips relative specifiers (./…), so nothing in the pipeline noticed when a vendored declaration referenced a sibling content-hashed chunk. The result: both hashed chunks were left behind.

Fix

Add a transitive relative-import co-pass to createDeclarationCopier: after the existing files/extra-files copies, scan each written declaration for relative import specifiers (from './x.js', from '../y.d.ts', export * from './z.js', side-effect import './w.js'), resolve them against the upstream package's dist/, and co-copy any matches — recursively, with cycle protection.

This subsumes discoverExtraFiles for the sibling-chunk class of problem: chat.mjs's jsx-runtime- regex remains in place as belt-and-braces but the new helper catches its matches too. The helper is generic across all vendored packages, so future content-hashed chunks in any vendored dependency are picked up automatically — no more per-package regexes.

Verification

Locally (pnpm build:compiled):

ls .generated/compiled/chat/
# LICENSE  _mdast.d.ts  _workflow-serde.d.ts  index.d.ts  index.js
# jsx-runtime-_JEEAotp.d.ts  messages-BSoJG691.d.ts       ← NEW

ls .generated/compiled/@chat-adapter/twilio/
# LICENSE  api.d.ts  api.js  format.d.ts  format.js  index.d.ts  index.js
# types-WYjTBVDi.d.ts  voice.d.ts  voice.js  webhook.d.ts  webhook.js  ← NEW

Both chunk filenames and contents match the upstream packages the reporter linked:

  • chat@4.34.0dist/messages-BSoJG691.d.ts
  • @chat-adapter/twilio@4.35.0dist/types-WYjTBVDi.d.ts

Test suite: pnpm exec vitest run test/scenarios/compiled-vendor-assets.scenario.test.ts8/8 pass (7 existing + 1 new regression test).

Type check on the changed script + test: clean (pre-existing baseline of 124 errors in 8 unrelated files unchanged).

Regression test

Added (eve#1500) co-copies content-hashed sibling declaration chunks referenced by vendored entries to compiled-vendor-assets.scenario.test.ts:

  • Asserts both chunk files exist on disk.
  • Asserts chat/index.d.ts still references ./messages-BSoJG691 and webhook.d.ts still references ./types-WYjTBVDi (i.e. we copied the target alongside, not stripped the import).

Why this shape and not the cheap fix

Alternative considered: just extend the regexes to include messages-*.d.ts and types-*.d.ts. Rejected because (a) rollup hashes change per version bump and would silently re-break on the next vendored dependency upgrade, and (b) the reactive-regex pattern would have caught this bug only for the two currently-known chunks. The transitive closure approach is immune to hash churn and automatically picks up new chunks in any vendored package.

…l#1500)

Some upstream packages emit rollup content-hashed sibling chunks (e.g.
chat's messages-BSoJG691.d.ts, @chat-adapter/twilio's types-WYjTBVDi.d.ts)
that their public declarations reference via relative import. Because
createDeclarationCopier only co-copied explicit 'files' plus whatever
discoverExtraFiles matched (chat listed 'jsx-runtime-*' specifically,
twilio listed only its 5 entry points), these chunks were silently left
behind. The published package's declarations then resolved those imports
to 'any' under skipLibCheck: true, silently degrading ~120 exported types
across the Chat SDK surface and Twilio's TwilioWebhookUrl /
TwilioVerifiedRequest. With skipLibCheck: false the hole surfaced as
TS2307: Cannot find module './messages-BSoJG691.js'.

Fix it root-causally: after the existing files/co-copy step, scan each
written declaration for relative import specifiers (from './x.js',
from '../y.d.ts', export * from './z.js', side-effect import './w.js'),
resolve them against the upstream dist/, and co-copy any matches —
recursively, with cycle protection. This subsumes discoverExtraFiles for
the sibling-chunk class of problem; chat.mjs's jsx-runtime regex remains
in place as belt-and-braces but the new helper catches its matches too.

Verified locally: pnpm build:compiled now emits
.generated/compiled/chat/messages-BSoJG691.d.ts and
.generated/compiled/@chat-adapter/twilio/types-WYjTBVDi.d.ts, both
content-matching the upstream packages the reporter linked.

Added a regression scenario test that asserts both chunk files exist on
disk and that the chat/twilio entry points still reference their hashed
siblings (i.e. we copied the target alongside rather than stripping the
import).

Refs vercel#1500

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

vercel Bot commented Aug 1, 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

FYI on the current CI failures: the typecheck and downstream E2E failures on this PR come from 5 pre-existing TypeScript errors on main — not from the vendoring change in this PR.

Failing files (all in unrelated subsystems, all on main):

src/public/channels/chat-sdk/chatSdkChannel.ts(273,9): error TS2322
  Type 'Thread<unknown, unknown>' is not assignable to type
  'string | SerializedThread | Thread<Record<string, unknown>, unknown>'.

src/public/channels/photon/inboundContent.test.ts(9,5): error TS2741
src/public/channels/photon/photonIMessageChannel.test.ts(45,7): error TS2741
src/public/channels/photon/photonIMessageChannel.test.ts(68,7): error TS2741
src/public/channels/photon/photonIMessageChannel.test.ts(90,7): error TS2741
  Property 'fullName' is missing in type '{…}' but required in type 'Author'.

I verified by running npx tsc --noEmit -p packages/eve on a clean origin/main checkout — same 5 errors, same files, same line numbers. The E2E failures cascade from the same pnpm run build:js step hitting the typecheck error.

This PR itself only touches scripts/vendor-compiled/_shared.mjs and test/scenarios/compiled-vendor-assets.scenario.test.ts; my smoke test for the new vendoring path passed locally before push.

I'll keep the branch freshly synced with main and re-run CI the moment the upstream typecheck is fixed.

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