-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
|
好的,这是将 pull request review guide 翻译成简体中文的结果: 🧙 Sourcery 已经完成了对您的 pull request 的审查! 提示和命令与 Sourcery 互动
自定义您的体验访问您的 仪表盘 以:
获取帮助Original review guide in English🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
🎉 🎉 🎉 构建完成! 你可以通过以下命令安装该版本: |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @shiwuliya - 我已经查看了你的更改 - 这里有一些反馈:
- tsdown.config.ts 中的重命名钩子当前将
.js文件重命名为.mjs,但 package.json 导出路径仍然指向.js——请对齐扩展名或相应地更新导出。 - 你的 tsdown 目标设置为
node22,但 package.json 引擎允许>=20.0.0,因此要么降低目标以匹配,要么提高引擎字段以要求 Node 22。 copyExpFiles钩子仅删除.d.cts文件,但不会为 exports 文件夹将.js输出重命名为.mjs——添加匹配的重命名逻辑或调整导出映射。
AI 代理的提示
请解决此代码审查中的评论:
## 总体评论
- tsdown.config.ts 中的重命名钩子当前将 `.js` 文件重命名为 `.mjs`,但 package.json 导出路径仍然指向 `.js`——请对齐扩展名或相应地更新导出。
- 你的 tsdown 目标设置为 `node22`,但 package.json 引擎允许 `>=20.0.0`,因此要么降低目标以匹配,要么提高引擎字段以要求 Node 22。
- `copyExpFiles` 钩子仅删除 `.d.cts` 文件,但不会为 exports 文件夹将 `.js` 输出重命名为 `.mjs`——添加匹配的重命名逻辑或调整导出映射。
## 单独评论
### 评论 1
<location> `tsdown.config.ts:59` </location>
<code_context>
+ const distDir = path.join(file_path, 'dist')
+
+ // 删除 .d.cts 文件
+ fs.readdirSync(distDir).forEach((file) => {
+ if (file.endsWith('.d.cts')) {
+ fs.rmSync(path.join(distDir, file))
+ }
</code_context>
<issue_to_address>
直接删除 dist 目录中的文件可能会导致问题,如果目录结构发生变化。
此逻辑仅删除 dist 顶层的文件,并且会遗漏子目录中的 .d.cts 文件。使用递归方法或 glob 模式来处理所有情况。
建议的实现方式:
```typescript
const distDir = path.join(file_path, 'dist')
// 递归删除所有 .d.cts 文件
import glob from 'glob'
glob.sync('**/*.d.cts', { cwd: distDir, absolute: true }).forEach((file) => {
fs.rmSync(file)
})
// 仅重命名顶层 .js 文件为 .mjs
fs.readdirSync(distDir).forEach((file) => {
if (file.endsWith('.js')) {
const oldPath = path.join(distDir, file)
const newPath = path.join(distDir, file.replace('.js', '.mjs'))
fs.renameSync(oldPath, newPath)
}
})
```
- 确保 `glob` 包已安装在您的项目中 (`npm install glob`)。
- 如果您的项目使用 ES 模块,您可能需要将 glob 导入为 `import glob from 'glob'` 在文件顶部,或者如果使用 CommonJS,则使用 `const glob = require('glob')`。
- 如果您还想递归地将子目录中的 `.js` 文件重命名为 `.mjs`,您应该为 `.js` 文件应用类似的 glob 模式。
</issue_to_address>帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进您的评论。
Original comment in English
Hey @shiwuliya - I've reviewed your changes - here's some feedback:
- The renaming hook in tsdown.config.ts currently renames
.jsfiles to.mjs, but package.json export paths still point to.js—please align the extensions or update the exports accordingly. - Your tsdown target is set to
node22but package.json engines allow>=20.0.0, so either lower the target to match or bump the engines field to require Node 22. - The
copyExpFileshook only removes.d.ctsfiles but doesn’t rename.jsoutputs to.mjsfor the exports folder—add matching rename logic or adjust the exports mapping.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The renaming hook in tsdown.config.ts currently renames `.js` files to `.mjs`, but package.json export paths still point to `.js`—please align the extensions or update the exports accordingly.
- Your tsdown target is set to `node22` but package.json engines allow `>=20.0.0`, so either lower the target to match or bump the engines field to require Node 22.
- The `copyExpFiles` hook only removes `.d.cts` files but doesn’t rename `.js` outputs to `.mjs` for the exports folder—add matching rename logic or adjust the exports mapping.
## Individual Comments
### Comment 1
<location> `tsdown.config.ts:59` </location>
<code_context>
+ const distDir = path.join(file_path, 'dist')
+
+ // 删除 .d.cts 文件
+ fs.readdirSync(distDir).forEach((file) => {
+ if (file.endsWith('.d.cts')) {
+ fs.rmSync(path.join(distDir, file))
+ }
</code_context>
<issue_to_address>
Directly deleting files in the dist directory may cause issues if the directory structure changes.
This logic only deletes files in the top level of dist and will miss .d.cts files in subdirectories. Use a recursive method or glob pattern to handle all cases.
Suggested implementation:
```typescript
const distDir = path.join(file_path, 'dist')
// 递归删除所有 .d.cts 文件
import glob from 'glob'
glob.sync('**/*.d.cts', { cwd: distDir, absolute: true }).forEach((file) => {
fs.rmSync(file)
})
// 仅重命名顶层 .js 文件为 .mjs
fs.readdirSync(distDir).forEach((file) => {
if (file.endsWith('.js')) {
const oldPath = path.join(distDir, file)
const newPath = path.join(distDir, file.replace('.js', '.mjs'))
fs.renameSync(oldPath, newPath)
}
})
```
- Make sure the `glob` package is installed in your project (`npm install glob`).
- If your project uses ES modules, you may need to import glob as `import glob from 'glob'` at the top of the file, or use `const glob = require('glob')` if using CommonJS.
- If you want to also recursively rename `.js` files to `.mjs` in subdirectories, you should apply a similar glob pattern for `.js` files.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| fs.readdirSync(distDir).forEach((file) => { | ||
| if (file.endsWith('.d.cts')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): 直接删除 dist 目录中的文件可能会导致问题,如果目录结构发生变化。
此逻辑仅删除 dist 顶层的文件,并且会遗漏子目录中的 .d.cts 文件。使用递归方法或 glob 模式来处理所有情况。
建议的实现方式:
const distDir = path.join(file_path, 'dist')
// 递归删除所有 .d.cts 文件
import glob from 'glob'
glob.sync('**/*.d.cts', { cwd: distDir, absolute: true }).forEach((file) => {
fs.rmSync(file)
})
// 仅重命名顶层 .js 文件为 .mjs
fs.readdirSync(distDir).forEach((file) => {
if (file.endsWith('.js')) {
const oldPath = path.join(distDir, file)
const newPath = path.join(distDir, file.replace('.js', '.mjs'))
fs.renameSync(oldPath, newPath)
}
})- 确保
glob包已安装在您的项目中 (npm install glob)。 - 如果您的项目使用 ES 模块,您可能需要将 glob 导入为
import glob from 'glob'在文件顶部,或者如果使用 CommonJS,则使用const glob = require('glob')。 - 如果您还想递归地将子目录中的
.js文件重命名为.mjs,您应该为.js文件应用类似的 glob 模式。
Original comment in English
suggestion (bug_risk): Directly deleting files in the dist directory may cause issues if the directory structure changes.
This logic only deletes files in the top level of dist and will miss .d.cts files in subdirectories. Use a recursive method or glob pattern to handle all cases.
Suggested implementation:
const distDir = path.join(file_path, 'dist')
// 递归删除所有 .d.cts 文件
import glob from 'glob'
glob.sync('**/*.d.cts', { cwd: distDir, absolute: true }).forEach((file) => {
fs.rmSync(file)
})
// 仅重命名顶层 .js 文件为 .mjs
fs.readdirSync(distDir).forEach((file) => {
if (file.endsWith('.js')) {
const oldPath = path.join(distDir, file)
const newPath = path.join(distDir, file.replace('.js', '.mjs'))
fs.renameSync(oldPath, newPath)
}
})- Make sure the
globpackage is installed in your project (npm install glob). - If your project uses ES modules, you may need to import glob as
import glob from 'glob'at the top of the file, or useconst glob = require('glob')if using CommonJS. - If you want to also recursively rename
.jsfiles to.mjsin subdirectories, you should apply a similar glob pattern for.jsfiles.
- 移除 tsconfig.module.json 文件 - 新增 tsdown.config.ts 文件,配置 tsdown 构建工具 - 删除 tsup.config.ts 和 tsup.modules.ts 文件,移除 tsup 构建工具 - 更新构建选项,包括入口文件、格式、依赖处理等 - 添加复制文件和清理目录的钩子函数
|
🎉 🎉 🎉 构建完成! 你可以通过以下命令安装该版本: |
|
🎉 🎉 🎉 构建完成! 你可以通过以下命令安装该版本: |
|
🎉 🎉 🎉 构建完成! 你可以通过以下命令安装该版本: |
|
🎉 🎉 🎉 构建完成! 你可以通过以下命令安装该版本: |
🤖 I have created a release *beep* *boop* --- ## [1.2.0](v1.1.1...v1.2.0) (2025-07-06) ### ✨ 新功能 * **common:** 添加差异渲染函数 ([26064ac](26064ac)) ### ♻️ 代码重构 * **deps:** 用 radash 替代 lodash ([aa365e4](aa365e4)) ### 📦️ 构建系统 * 重构构建配置并迁移至 tsdown ([#77](#77)) ([0996820](0996820)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: candriajs[bot] <206545521+candriajs[bot]@users.noreply.github.com>
Sourcery 总结
将构建管道从 tsup 迁移到 tsdown,相应地更新包导出和脚本,并引入构建后钩子来清理和重命名输出文件。
增强功能:
构建:
杂项:
Original summary in English
Summary by Sourcery
Migrate the build pipeline from tsup to tsdown, update package exports and scripts accordingly, and introduce post–build hooks to clean and rename output files.
Enhancements:
Build:
Chores: