Skip to content

chore(site): deduplicate CodeSandbox sandbox define-API payload for JS and TS demos - #4467

Merged
RylanBot merged 3 commits into
Tencent:developfrom
jadelike-wine:auto-82dfac3455aeff9437306d4a
Nov 11, 2026
Merged

RylanBot merged 3 commits into
Tencent:developfrom
jadelike-wine:auto-82dfac3455aeff9437306d4a

Conversation

@jadelike-wine

@jadelike-wine jadelike-wine commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

Related to #4465 (docs-site CodeSandbox demo maintenance; this PR addresses the duplicated request-payload code path only).

💡 需求背景和解决方案

Problem: packages/tdesign-react/site/src/components/codesandbox/index.jsx built the CodeSandbox define POST payload twice — once for TypeScript demos and once for JavaScript demos. The two copies share package.json, public/index.html, src/index.css, and the entry file, so any change to the shared template had to be edited in two places and could drift apart.

Solution: The fetch request is now built once. A fileExt variable (tsx/jsx, derived from demoDom?.currentLangIndex === TypeScriptType) selects src/main.<ext> and src/demo.<ext> keys, and tsconfig.json is conditionally included only for TS demos via a spread. On success the action still opens https://codesandbox.io/s/<sandbox_id>?file=/src/demo.<ext>.

Behavior preserved:

  • TS demos still post src/main.tsx, src/demo.tsx, plus tsconfig.json; JS demos still post src/main.jsx, src/demo.jsx without it.
  • Shared files (package.json, public/index.html, src/index.css) are unchanged.
  • No component API, UI, or generated-file changes — docs site internals only.

Validation: The current PR changes only the CodeSandbox component. The earlier source-inspection test was removed and is not part of this diff. The latest published revision has 12 successful GitHub checks, including the site preview/build checks.

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-react

  • refactor(site): deduplicate the CodeSandbox define request so the payload is built once for both JS and TS demos

@tdesign-react/chat

N/A

☑️ 请求合并前的自查清单

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@tdesign-bot

tdesign-bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

TDesign Component Site Preview Open

Component Preview
tdesign-react 完成
@tdesign-react/chat 完成

@pkg-pr-new

pkg-pr-new Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
  • tdesign-react-demo

    npm i https://pkg.pr.new/tdesign-react@4467
    
    npm i https://pkg.pr.new/@tdesign-react/chat@4467
    

commit: 9a943df

@RylanBot RylanBot changed the title fix(site): deduplicate CodeSandbox sandbox define-API payload for JS and TS demos chore(site): deduplicate CodeSandbox sandbox define-API payload for JS and TS demos Nov 9, 2026
@RylanBot
RylanBot merged commit 2bc63e2 into Tencent:develop Nov 11, 2026
12 checks passed
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.

3 participants