Skip to content

Conversation

@liweijie0812
Copy link
Collaborator

@liweijie0812 liweijie0812 commented Aug 28, 2025

🤔 这个 PR 的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

优化#5800
移除编译生成catalogs.ts,改用vite 插件生成站点数据存储依赖版本号

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-vue-next

@tdesign-vue-next/chat

@tdesign-vue-next/auto-import-resolver

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

⚠️ 请自检并全部勾选全部选项⚠️

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

@tdesign-bot
Copy link
Collaborator

tdesign-bot commented Aug 28, 2025

TDesign Component Site Preview Open

Component Preview
tdesign-vue-next 完成
@tdesign-vue-next/chat 完成

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 28, 2025

tdesign-vue-next-demo

npm i https://pkg.pr.new/Tencent/tdesign-vue-next/@tdesign-vue-next/auto-import-resolver@5947
npm i https://pkg.pr.new/Tencent/tdesign-vue-next@5947
npm i https://pkg.pr.new/Tencent/tdesign-vue-next/@tdesign-vue-next/chat@5947

commit: 74d4ff7

@liweijie0812 liweijie0812 requested a review from Copilot August 29, 2025 00:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new site metadata management system that replaces the previous approach of generating a catalogs.ts file at build time. The change introduces a Vite plugin that dynamically loads package version information from the workspace YAML configuration and makes it available as a global constant.

  • Adds a new Vite plugin siteMetadata that reads package versions from pnpm-workspace.yaml
  • Replaces static catalog imports with a global TD_SITE_METADATA constant for dependency management
  • Removes the catalogs.ts generation step from the build process

Reviewed Changes

Copilot reviewed 12 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/tdesign-vue-next/site/vite.config.ts Adds the new siteMetadata plugin to the Vite configuration
packages/tdesign-vue-next/site/src/components/stackblitz/content.ts Replaces catalog imports with TD_SITE_METADATA global references
packages/tdesign-vue-next/site/src/components/codeSandbox/content.ts Updates to use TD_SITE_METADATA instead of imported catalogs
packages/tdesign-vue-next/site/plugins/site-metadata/index.ts New Vite plugin that defines TD_SITE_METADATA from workspace YAML
packages/tdesign-vue-next-chat/site/vite.config.ts Adds siteMetadata plugin and updates import paths
packages/tdesign-vue-next-chat/site/src/components/stackblitz/content.js Replaces catalog imports with TD_SITE_METADATA references
packages/tdesign-vue-next-chat/site/plugins/site-metadata/index.js Chat package version of the siteMetadata plugin
packages/tdesign-vue-next-chat/site/plugins/plugin-doc/md-to-vue.js Fixes import path for common docs utilities
packages/tdesign-vue-next-chat/site/package.json Adds --configLoader runner flag to Vite commands
internal/utils/src/catalogs.ts Removes the generated catalogs file entirely
internal/utils/scripts/postinstall-tasks.ts Removes catalog generation from build process
internal/utils/index.ts Removes catalogs export from utils package

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +2 to +7
import { readFileSync } from 'fs';
import { joinWorkspaceRoot, tdesignVueNextPackageJson } from '@tdesign/internal-utils';
export default function siteMetadata() {
const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml');
const yamlContent = readFileSync(sourcePath, 'utf-8');
const documents = parse(yamlContent);
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the YAML file synchronously on every plugin initialization could cause performance issues and lacks error handling. Consider adding try-catch blocks and validating the file exists.

Suggested change
import { readFileSync } from 'fs';
import { joinWorkspaceRoot, tdesignVueNextPackageJson } from '@tdesign/internal-utils';
export default function siteMetadata() {
const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml');
const yamlContent = readFileSync(sourcePath, 'utf-8');
const documents = parse(yamlContent);
import { readFileSync, existsSync } from 'fs';
import { joinWorkspaceRoot, tdesignVueNextPackageJson } from '@tdesign/internal-utils';
export default function siteMetadata() {
const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml');
let documents: any = {};
if (existsSync(sourcePath)) {
try {
const yamlContent = readFileSync(sourcePath, 'utf-8');
documents = parse(yamlContent);
} catch (err) {
console.warn(`[site-metadata] Failed to read or parse YAML file at ${sourcePath}:`, err);
documents = {};
}
} else {
console.warn(`[site-metadata] YAML file not found at ${sourcePath}.`);
documents = {};
}

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +7
import { readFileSync } from 'fs';
import { joinWorkspaceRoot, tdesignVueNextPackageJson, tdesignVueNextChatPackageJson } from '@tdesign/internal-utils';
export default function siteMetadata() {
const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml');
const yamlContent = readFileSync(sourcePath, 'utf-8');
const documents = parse(yamlContent);
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the YAML file synchronously on every plugin initialization could cause performance issues and lacks error handling. Consider adding try-catch blocks and validating the file exists.

Suggested change
import { readFileSync } from 'fs';
import { joinWorkspaceRoot, tdesignVueNextPackageJson, tdesignVueNextChatPackageJson } from '@tdesign/internal-utils';
export default function siteMetadata() {
const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml');
const yamlContent = readFileSync(sourcePath, 'utf-8');
const documents = parse(yamlContent);
import { readFileSync, existsSync } from 'fs';
import { joinWorkspaceRoot, tdesignVueNextPackageJson, tdesignVueNextChatPackageJson } from '@tdesign/internal-utils';
export default function siteMetadata() {
const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml');
let documents = {};
if (existsSync(sourcePath)) {
try {
const yamlContent = readFileSync(sourcePath, 'utf-8');
documents = parse(yamlContent);
} catch (err) {
// eslint-disable-next-line no-console
console.warn(`[site-metadata] Failed to read or parse YAML file at ${sourcePath}:`, err);
documents = {};
}
} else {
// eslint-disable-next-line no-console
console.warn(`[site-metadata] YAML file not found at ${sourcePath}.`);
documents = {};
}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@zhangpaopao0609 zhangpaopao0609 Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以聊聊为什么要这样修改吗?我的疑问在于

  1. 本质上没有改变获取 catalogs 的思路,都是读 yml
  2. 无法复用:由于当前 site 没有整合的缘故,还是重复的,多个 site 就要编写多次;同时还无法给到其它模块使用

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要获取依赖版本只有站点在使用,而且每次动到依赖版本catalogs.ts都会产生一个变更出来,我认为做成插件供站点使用好点

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.

4 participants