Repository navigation
Bug : Client bundle fails with "Missing field 'code'" due to RolldownMagicString returned from renderChunk #12981
Replies: 1 comment
|
The hooks return the MagicString, not
The explicit object shape you propose is the right fix; keep the I read the source only; I did not run You can hand this to an AI assistant to prepare the two-hook patch. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
During
pnpm run build(specifically theClient bundlegate runningtsdown --config-loader native --env.DSH_BUILD_FACE client), bundling client packages (such as@deepseek-ai/dsh-client-ui-brand-official/client) crashes with the following error:Root Cause Analysis
In
packages/client/tsdown.client.ts, theasyncChunkRequirePluginandpackageAssetsplugins returntransformed(an instance ofRolldownMagicString) directly from theirrenderChunkhooks:When
tsdownruns with--config-loader native, Rolldown'sbindingifyRenderChunkinspects the hook output:Because
tsdown.client.tsis loaded through the native loader, theRolldownMagicStringconstructor imported in the config file is not reference-identical to the constructor instance inside Rolldown's bundled module. As a result,ret instanceof RolldownMagicStringevaluates tofalse.Rolldown then falls back to extracting
{ code: ret.code, map: bindingifySourcemap(ret.map) }. BecauseRolldownMagicStringdoes not have an own.codeproperty (it produces its string output via.toString()),ret.codeisundefined. Passing{ code: undefined }across the NAPI bridge to Rust'sBindingHookRenderChunkOutputcauses Rust to reject the struct with:Reproduction
pnpm run build(or specifically run the client bundle step):pnpm exec tsdown --config-loader native --env.DSH_BUILD_FACE clientCurrent behavior
The build fails during
Client bundle:Expected behavior
pnpm run buildandtsdown --config-loader native --env.DSH_BUILD_FACE clientshould build all client packages without errors.Suggested Fix
In
packages/client/tsdown.client.ts, have therenderChunkhooks return an explicit object with.code,.map, and.toString()(for test compatibility):Environment
rolldown: 1.1.1tsdown: 0.22.2All reactions