fix(eve): vendor content-hashed declaration chunks (chat, @chat-adapter/twilio) - #1534
Open
iroiro147 wants to merge 1 commit into
Open
fix(eve): vendor content-hashed declaration chunks (chat, @chat-adapter/twilio)#1534iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
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>
Contributor
|
@iroiro147 is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
Standing-health check (re-verified against current
Ready for review whenever convenient; no action required from contributors. |
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.
Problem
chatand@chat-adapter/twilioboth ship content-hashed sibling declaration chunks that theirindex.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.mjsonly matchedjsx-runtime-<hash>.d.tsviadiscoverExtraFiles, andvendor-compiled/@chat-adapter/twilio.mjshad no discovery block at all. Those chunks were dropped from the publishedevetarball whileindex.d.tsstill references them by relative path, so consumers ofeve's#compiled/chatand#compiled/@chat-adapter/twilionamespaces see:any(skipLibCheck: true, the default),TS2307: Cannot find module './messages-….js'/'./types-….js'withskipLibCheck: false,TS2741: Property 'fullName' is missing in type …once the leaked symbols re-route throughAuthor/MessageData/Thread.Resolves #1500.
Fix
packages/eve/scripts/vendor-compiled/_shared.mjs(createDeclarationCopier) — previouslydiscoverExtraFiles-selected files were copied verbatim viacopyFileafter the namedfileswent through the rewrite pass. Chat'smessages-<hash>.d.tscontainsimport { Root } from 'mdast'andimport { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde'— bare specifiers that cannot reach the published package (no@types/mdast, no@workflow/serdedeclaration in closure). Extras must flow through the same rewrite pipeline.Fold extras into the
declarationsarray beforemergeExternalDeclarationImportsruns, so the existing vendored/stub/external rule matrix applies uniformly. Drop the tailing verbatimcopyFileblock (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 adiscoverExtraFilesblock 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
anyfallback:src/public/channels/chat-sdk/chatSdkChannel.ts:ActionEvent.threadisThread<TRawMessage, unknown>; cast through the declaredThreadalias on theChatSdkSendOptions.threadfield so the existingTState = Record<string, unknown>default applies.src/public/channels/photon/inboundContent.test.ts: add the now-requiredformatted(mdastRoot),metadata({dateSent, edited}), andfullName(Author) fields to thenew Message({...})mock.src/public/channels/photon/photonIMessageChannel.test.ts: same three mocks, plusattachments: []each..changeset/fix-1500-missing-declaration-chunks.md—"eve": patch.Verification
pnpm install --frozen-lockfilenode scripts/vendor-compiled.mjs(all 41 modules)messages-BSoJG691.d.tsalongsidejsx-runtime-_JEEAotp.d.tsin.generated/compiled/chat/;types-WYjTBVDi.d.tsin.generated/compiled/@chat-adapter/twilio/from './_mdast.js'on line 2,from './_workflow-serde.js'on line 1 of the copiedmessages-BSoJG691.d.tsnpx tsc --noEmit -p tsconfig.json(full package)fullName/MessageData mocks tightened here)npx tsc -p tsconfig.build.json(production build types)pnpm run test:unittest/bin-bootstrap.test.tsgating on Node.js ≥24 (running on v22.22.3 locally), unrelatedtscprobe withskipLibCheck: falseagainst.generated/compiled/TS2307on./messages-…or./types-…— the #1500 repro closesnpx oxlint --fixon touched pathsOut of scope maintained
bin-bootstrapfailures match baseline (Node env).tsc --noEmiterrors were in the same photon test mocks tightened here — those leaks were only visible without the precise type graph.DCO-signed.
/test