-
Notifications
You must be signed in to change notification settings - Fork 4.9k
chore: add tsdown #17746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore: add tsdown #17746
Conversation
""" Walkthrough本次变更主要将 Changes
Sequence Diagram(s)sequenceDiagram
participant 开发者
participant tsdown
participant 源码(src)
participant 输出(dist)
开发者->>tsdown: 执行 tsdown 构建命令 (build/dev)
tsdown->>源码(src): 读取 TypeScript 源码文件
tsdown->>输出(dist): 生成多格式构建产物(ESM、CJS),附带 sourcemap
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 7
🧹 Nitpick comments (6)
.gitignore (1)
87-88
: 建议明确忽略目录或文件范围
当前忽略条目chrome
过于宽泛,可能会将同名文件或目录一并忽略。建议使用斜杠限定目录,例如:- chrome + /chrome/以确保仅忽略项目根目录下的
chrome
文件夹。CONTRIBUTING.md (2)
5-5
: 统一标题编号风格以保持一致
## 一、Pull Request 贡献指南
与后续### 1. 环境准备
等使用了阿拉伯数字编号不一致,建议改为:- ## 一、Pull Request 贡献指南 + ## 1. Pull Request 贡献指南来统一数字格式。
127-127
: “关于”介词短语建议使用“对于”
根据规范,“关于”引导的介词短语需位于句首,当前处于句中,可改为:- > 如果对 PR(Pull Request)不了解,请阅读 [《关于拉取请求》](...) + > 如果对于 PR(Pull Request)不了解,请阅读 [《关于拉取请求》](...)以满足语法要求。
🧰 Tools
🪛 LanguageTool
[uncategorized] ~127-~127: “关于”组成的介词短语必需位于句首,或请改用"对于"代替。
Context: ...equest > 如果对 PR(Pull Request)不了解,请阅读 [《关于拉取请求》](https://docs.github.com/zh/pull-r...(wb2)
packages/taro-runtime/tsdown.config.ts (1)
1-6
: 建议显式指定输出目录和格式
当前配置中只定义了entry
和sourcemap
,依赖 tsdown 默认输出到dist
目录(ESM)可能会在未来产生不一致。
可以考虑增加:export default defineConfig({ entry: ['./src/index.ts', './src/dom-external/index.ts'], + outDir: './dist', + format: 'esm', sourcemap: true, })packages/taro-runtime/src/__tests__/dom.spec.js (1)
1-5
: 建议对window
导入添加别名以避免与全局变量冲突
当前写法import { window } ...
会直接覆盖(shadow)测试环境中的全局window
,推荐改为:-import { document as Document, navigator, window } from '../../dist/index' +import { document as Document, navigator, window as runtimeWindow } from '../../dist/index'并在后续统一使用
runtimeWindow
,提高可读性。packages/taro-framework-react/src/runtime/connect-native.ts (1)
13-14
: 合并type
导入以去除冗余
当前对@tarojs/runtime
进行了两次type
导入,可将它们合并为一次:-import type { Instance, TaroRootElement } from '@tarojs/runtime' -import type { MpInstance } from '@tarojs/runtime' +import type { Instance, TaroRootElement, MpInstance } from '@tarojs/runtime'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (51)
.github/ISSUE_TEMPLATE/bug_report.yml
(3 hunks).github/ISSUE_TEMPLATE/config.yml
(1 hunks).github/ISSUE_TEMPLATE/feature_request.yml
(2 hunks).gitignore
(1 hunks)CONTRIBUTING.md
(4 hunks)package.json
(1 hunks)packages/taro-api/jest.config.js
(1 hunks)packages/taro-components-react/src/components/view/index.tsx
(1 hunks)packages/taro-extend/jest.config.js
(1 hunks)packages/taro-framework-react/src/runtime/connect-native.ts
(7 hunks)packages/taro-framework-solid/src/runtime/hooks.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/URL.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/history.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/location.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/navigator.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/raf.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/constant.ts
(2 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/dom/event-source.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/emitter/emitter.ts
(2 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/env.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/index.ts
(2 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/interface/index.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/utils/router.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/bom/URL.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/bom/history.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/bom/location.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/bom/navigator.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/bom/raf.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/constant.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/dom/event-source.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/emitter/emitter.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/env.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/index.ts
(2 hunks)packages/taro-platform-harmony/src/runtime-ets/interface/index.ts
(1 hunks)packages/taro-platform-harmony/src/runtime-ets/utils/router.ts
(1 hunks)packages/taro-plugin-http/jest.config.js
(1 hunks)packages/taro-runtime/jest.config.js
(1 hunks)packages/taro-runtime/package.json
(3 hunks)packages/taro-runtime/rollup.config.ts
(0 hunks)packages/taro-runtime/src/__tests__/class.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/dom.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/event.spec.js
(13 hunks)packages/taro-runtime/src/__tests__/eventSource.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/exports.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/html.spec.js
(3 hunks)packages/taro-runtime/src/__tests__/location.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/mutation.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/react.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/style.spec.js
(1 hunks)packages/taro-runtime/src/__tests__/vue.spec.js
(1 hunks)packages/taro-runtime/tsdown.config.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/taro-runtime/rollup.config.ts
🧰 Additional context used
🧬 Code Graph Analysis (6)
packages/taro-runtime/src/__tests__/style.spec.js (5)
packages/taro-runtime/src/__tests__/react.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/html.spec.js (1)
runtime
(10-10)packages/taro-runtime/src/__tests__/vue.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/location.spec.js (1)
runtime
(2-2)packages/taro-runtime/src/__tests__/mutation.spec.js (1)
runtime
(3-3)
packages/taro-runtime/src/__tests__/react.spec.js (5)
packages/taro-runtime/src/__tests__/html.spec.js (1)
runtime
(10-10)packages/taro-runtime/src/__tests__/style.spec.js (1)
runtime
(4-4)packages/taro-runtime/src/__tests__/vue.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/location.spec.js (1)
runtime
(2-2)packages/taro-runtime/src/__tests__/mutation.spec.js (1)
runtime
(3-3)
packages/taro-runtime/src/__tests__/vue.spec.js (5)
packages/taro-runtime/src/__tests__/react.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/html.spec.js (1)
runtime
(10-10)packages/taro-runtime/src/__tests__/style.spec.js (1)
runtime
(4-4)packages/taro-runtime/src/__tests__/location.spec.js (1)
runtime
(2-2)packages/taro-runtime/src/__tests__/mutation.spec.js (1)
runtime
(3-3)
packages/taro-runtime/src/__tests__/mutation.spec.js (5)
packages/taro-runtime/src/__tests__/react.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/html.spec.js (1)
runtime
(10-10)packages/taro-runtime/src/__tests__/style.spec.js (1)
runtime
(4-4)packages/taro-runtime/src/__tests__/vue.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/location.spec.js (1)
runtime
(2-2)
packages/taro-runtime/src/__tests__/location.spec.js (5)
packages/taro-runtime/src/__tests__/react.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/html.spec.js (1)
runtime
(10-10)packages/taro-runtime/src/__tests__/style.spec.js (1)
runtime
(4-4)packages/taro-runtime/src/__tests__/vue.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/mutation.spec.js (1)
runtime
(3-3)
packages/taro-runtime/src/__tests__/html.spec.js (5)
packages/taro-runtime/src/__tests__/react.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/style.spec.js (1)
runtime
(4-4)packages/taro-runtime/src/__tests__/vue.spec.js (1)
runtime
(3-3)packages/taro-runtime/src/__tests__/location.spec.js (1)
runtime
(2-2)packages/taro-runtime/src/__tests__/mutation.spec.js (1)
runtime
(3-3)
🪛 LanguageTool
CONTRIBUTING.md
[uncategorized] ~127-~127: “关于”组成的介词短语必需位于句首,或请改用"对于"代替。
Context: ...equest > 如果对 PR(Pull Request)不了解,请阅读 [《关于拉取请求》](https://docs.github.com/zh/pull-r...
(wb2)
🪛 YAMLlint (1.37.1)
.github/ISSUE_TEMPLATE/feature_request.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Testing on Node.js (macos-13)
- GitHub Check: Testing on Node.js 20.x (ubuntu-latest)
- GitHub Check: Testing on Node.js 18.x (ubuntu-latest)
🔇 Additional comments (67)
.github/ISSUE_TEMPLATE/config.yml (5)
3-3
: 优化 contact_links 名称格式
在📖 文档问题
与英文标签Docs Issue
之间添加了空格,增强了可读性,与其他模板保持一致。
6-6
: 统一创建提案链接名称
将📑 创建提案
后增加英文标签Proposal
并添加空格,对齐仓库内其它模板格式。
9-9
: 调整发起投票链接名称
在🙋🏻♂️ 发起投票
添加空格并追加英文Vote
,提升模板一致性。
12-12
: 规范社区支持链接名称
🙌🏼 社区支持
后新增英文标签General Question
,使用户更易理解用途。
15-15
: 完善生态建设链接名称
在🏗 生态建设
后添加空格与英文说明Ecosystem
,与其他模板统一格式。.github/ISSUE_TEMPLATE/feature_request.yml (3)
1-2
: 更新 Feature Request 模板标题与描述
将模板名称改为🚀 功能请求 Feature Request
并将描述调整为更完整的提出新的功能特性
,提升中英文并存的清晰度。🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 1-1: wrong new line character: expected \n
(new-lines)
11-11
: 调整复选框组标签
将重复校验组的label
改为更简洁的请先确认
,与 Bug Report 模板保持一致。
13-14
: 将重复确认校验移至选项级别
- 选项标签改为
我已搜索并确定这个提交不是重复的
- 在该选项上添加
required: true
强制校验
与其他模板的 checkbox 校验方式统一。.github/ISSUE_TEMPLATE/bug_report.yml (4)
1-1
: 同步 Bug Report 模板名称格式
将名称更新为🐞 错误报告 Bug Report
,在 emoji 后添加空格并引入英文说明,格式与其他模板保持一致。
11-11
: 简化 Bug Report 重复校验组标签
将复选框组label
修改为请先确认
,统一仓库内所有模板的重复校验提示。
13-14
: 将重复确认必填校验移动至选项级别
- 选项标签改为
我已搜索并确定这个提交不是重复的
- 单独添加
required: true
校验
改动与 Feature Request 模板保持一致。
73-74
: 为复现步骤添加必填校验
在复现步骤
文本框下增加validations.required: true
,确保用户提供复现步骤信息。CONTRIBUTING.md (2)
35-35
: 文档链接已正确指向 npm CLI v11
链接已从 v7 更新至 v11,与描述一致,无需修改。
113-113
: Snapshot 更新命令修正有效
已在命令前后添加空格:run updateSnapshot
,修复了原始命令的拼写问题,符合其他命令格式。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/interface/index.ts (1)
2-2
: 统一导入路径,移除深层依赖
将PageConfig
和TFunc
从深层路径切换为根包导出,保持与其他子包一致,提升可维护性。
请确认在@tarojs/runtime
根入口已正确导出这两个符号,以免出现模块解析或类型缺失的问题。packages/taro-framework-solid/src/runtime/hooks.ts (1)
18-18
: 类型导入路径优化
将TFunc
的类型导入改为从根包获取,避免引用dist/runtime.esm
,符合 ES Module 规范统一性。
请检验@tarojs/runtime
的根入口是否已声明此类型,确保编译与类型校验通过。packages/taro-platform-harmony/src/runtime-ets/constant.ts (1)
19-19
: 常量导出源路径统一
已将所有常量从根包导出,移除对dist/runtime.esm
的依赖,增强包入口一致性。
请确认根包@tarojs/runtime
中包含这些常量的导出,以避免运行时找不到符号。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/utils/router.ts (1)
1-1
: 路由工具函数导出路径调整
将addLeadingSlash
等路由相关工具函数的导入统一到根包,和其他模块保持同步,简化依赖管理。
请验证新路径下各函数依旧存在并且接口未变动,防止调用方出错。packages/taro-extend/jest.config.js (1)
17-17
: Jest 模块映射更新
已将@tarojs/runtime
的映射从dist/runtime.esm.js
更新为dist/index.js
,对应运行时入口变更。
建议执行本地测试验证映射生效,确保单元测试和快照测试正常运行。packages/taro-runtime/src/__tests__/style.spec.js (1)
4-4
: 统一测试文件的 runtime 引入路径
将原先指向../../dist/runtime.esm
的导入改为../../dist/index
,与其他测试文件保持一致,符合新入口约定。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/location.ts (1)
1-1
: 更新导出路径为包根引入
将Location
的来源从深度路径切换到@tarojs/runtime
根入口,符合统一的 ES Module 规范。packages/taro-platform-harmony/src/runtime-ets/bom/URL.ts (1)
1-2
: 更新导出路径为包根引入
将parseUrl
、URL
和URLSearchParams
的来源都改为@tarojs/runtime
根入口,保持与运行时包的构建产物一致。packages/taro-api/jest.config.js (1)
18-18
: 更新 Jest moduleNameMapper 映射
将@tarojs/runtime
指向packages/taro-runtime/dist/index.js
,与新的构建输出保持一致。package.json (1)
159-161
: 新增 tsdown 构建依赖
在devDependencies
中添加tsdown
,为后续使用新工具构建taro-runtime
做准备。packages/taro-runtime/src/__tests__/react.spec.js (1)
3-3
: 导入路径已更新,符合新的模块结构这个修改将导入路径从原来的
'../../dist/runtime.esm'
更改为'../../dist/index'
,符合项目将@tarojs/runtime
包切换为 ES Module 规范的整体变更方向。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/constant.ts (2)
17-17
: 导入路径已更新,符合新的模块结构这个修改将导入路径从
'@tarojs/runtime/dist/runtime.esm'
更改为'@tarojs/runtime'
,符合项目将@tarojs/runtime
包切换为 ES Module 规范的整体变更方向。
28-28
: 注释格式美化注释格式调整,提高了可读性。
packages/taro-components-react/src/components/view/index.tsx (1)
6-6
: 类型导入路径已更新,符合新的模块结构这个修改将类型导入路径从
'@tarojs/runtime/dist/runtime.esm'
更改为'@tarojs/runtime'
,符合项目将@tarojs/runtime
包切换为 ES Module 规范的整体变更方向。packages/taro-runtime/src/__tests__/mutation.spec.js (1)
3-3
: 导入路径已更新,符合新的模块结构这个修改将导入路径从原来的
'../../dist/runtime.esm'
更改为'../../dist/index'
,符合项目将@tarojs/runtime
包切换为 ES Module 规范的整体变更方向。packages/taro-platform-harmony/src/runtime-ets/dom/event-source.ts (1)
1-1
: 统一导出路径至包根将
eventSource
的导出从深层路径切换为包根,简化了引入路径并与新的 ES Module 入口保持一致。packages/taro-plugin-http/jest.config.js (1)
19-19
: 更新 Jest moduleNameMapper 映射将
'@tarojs/runtime'
映射指向dist/index.js
,与 runtime 包的新入口保持一致,确保测试环境中正确加载模块。packages/taro-platform-harmony/src/runtime-ets/bom/navigator.ts (1)
1-1
: 统一导出路径至包根将
navigator
的导出路径从子路径调整为包根,保持与其他 runtime 导出的统一方式。packages/taro-platform-harmony/src/runtime-ets/bom/history.ts (1)
1-1
: 统一导出路径至包根将
History
的导出路径切换为包根,简化模块解析并配合新的入口文件。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/navigator.ts (1)
1-1
: 统一导出路径至包根同样将 C++ 平台的
navigator
导出路径统一为包根,保证跨平台一致性。packages/taro-runtime/src/__tests__/vue.spec.js (1)
3-3
: 导入路径与其他测试保持一致已将 Vue3 测试中的运行时模块路径更新为
../../dist/index
,与同目录下其他测试文件导入方式一致,可确保模块解析正确。packages/taro-platform-harmony/src/runtime-ets/utils/router.ts (1)
9-9
:❓ Verification inconclusive
确认路由工具方法根入口导出
addLeadingSlash
、getCurrentPage
、getHomePage
等路由工具函数已切换至根导入,请在@tarojs/runtime/dist/index.js
中验证它们是否暴露,以免构建后缺少相关 API。建议使用:
🏁 Script executed:
#!/bin/bash # 验证 addLeadingSlash 等路由工具函数导出 rg "addLeadingSlash" packages/taro-runtime/dist/index.jsLength of output: 132
🏁 Script executed:
#!/bin/bash # 查找所有 runtime 包的 dist 下 .js 文件,并验证路由工具函数导出 echo "正在查找 packages 目录下所有 */runtime/dist/*.js 文件……" files=$(find packages -type f -path "*/runtime/dist/*.js") if [ -z "$files" ]; then echo "未找到任何 runtime/dist/*.js 文件,请确认包名称或路径是否正确" exit 1 fi echo "找到以下文件:" echo "$files" echo echo "检查 addLeadingSlash、getCurrentPage、getHomePage 导出情况:" echo "$files" | xargs -r rg -nE "(addLeadingSlash|getCurrentPage|getHomePage)" || echo "上述函数未在任何文件中导出,请手动确认"Length of output: 276
请手动验证
@tarojs/runtime/dist/index.js
是否导出路由工具函数
由于本地仓库中找不到runtime/dist/index.js
,请在已安装的@tarojs/runtime
包中确认以下函数是否暴露,以免构建后缺少相关 API:
- addLeadingSlash
- getCurrentPage
- getHomePage
可在项目根目录下执行:
# 若已安装到 node_modules: rg "addLeadingSlash|getCurrentPage|getHomePage" node_modules/@tarojs/runtime/dist/index.jspackages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/dom/event-source.ts (1)
1-1
:❓ Verification inconclusive
验证 eventSource 在根入口中的导出
已将
eventSource
从深度路径改为根路径导出,请检查dist/index.js
是否包含此导出项,以避免运行或类型声明错误。运行命令:
🏁 Script executed:
#!/bin/bash # 验证 eventSource 导出是否存在 rg "eventSource" packages/taro-runtime/dist/index.jsLength of output: 128
为确保定位到正确的
dist/index.js
后再验证eventSource
导出,请先批量扫描所有子包的入口文件:
🏁 Script executed:
#!/bin/bash # 查找所有 dist/index.js 并验证 eventSource 导出 find . -type f -path "*/dist/index.js" | while read file; do echo "文件: $file" rg -n "eventSource" "$file" || echo " ⚠️ 未在此文件中找到 eventSource" doneLength of output: 14409
请先定位真正的
@tarojs/runtime
包路径,再检查其dist/index.js
中是否导出了eventSource
:
🏁 Script executed:
#!/bin/bash # 定位 @tarojs/runtime 包路径 pkg_manifest=$(grep -R '"name": *"@tarojs/runtime"' -n packages | head -n1 | cut -d: -f1) if [ -z "$pkg_manifest" ]; then echo "⚠️ 未在 packages 目录中找到 @tarojs/runtime 的 package.json" exit 1 fi pkg_dir=$(dirname "$pkg_manifest") echo "📦 包路径: $pkg_dir" # 验证 dist/index.js 是否存在并包含 eventSource 导出 dist_file="$pkg_dir/dist/index.js" if [ ! -f "$dist_file" ]; then echo "⚠️ 未找到 $dist_file" exit 1 fi echo "🔍 检查 $dist_file" rg -n "export.*eventSource" "$dist_file" || echo "⚠️ 未在此文件中找到 eventSource 导出"Length of output: 528
请构建 @tarojs/runtime 包并验证根入口导出
由于当前未检测到
packages/taro-runtime/dist/index.js
,请先执行构建,然后检查eventSource
是否已从根入口导出:# 构建 runtime 包 pnpm build --filter packages/taro-runtime # 验证 dist/index.js 中是否包含 eventSource 导出 rg -n "export.*eventSource" packages/taro-runtime/dist/index.jspackages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/emitter/emitter.ts (2)
1-2
: 更新导入路径以使用新的运行时入口
导入路径已从深层次子路径调整为@tarojs/runtime
,符合统一模块入口策略,无功能变化。
29-29
: 更新导出路径以使用新的运行时入口
已将Events
和EventsType
的导出路径从深层路径更新为@tarojs/runtime
,保持与项目入口一致。packages/taro-platform-harmony/src/runtime-ets/interface/index.ts (1)
2-2
: 统一接口导出路径
已将PageConfig
和TFunc
的导出路径改为@tarojs/runtime
,保持与运行时包入口一致,无功能影响。packages/taro-platform-harmony/src/runtime-ets/bom/raf.ts (1)
1-1
: 统一 BOM 方法导出
已将cancelAnimationFrame
、now
、requestAnimationFrame
改为从@tarojs/runtime
导出,与新的模块结构保持一致。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/env.ts (1)
1-1
: 统一环境变量导出路径
已将env
的导出路径更新为@tarojs/runtime
,符合一致性。请验证新入口中env
确已正确导出。packages/taro-runtime/src/__tests__/class.spec.js (1)
1-1
: 统一测试导入为 ES Module 入口
已将测试中对 runtime 的导入路径从../../dist/runtime.esm
更新为../../dist/index
,与新配置保持一致,无功能改动。packages/taro-platform-harmony/src/runtime-ets/env.ts (1)
1-1
: 简化 env 的重导出路径
将env
从深层子路径改为直接从包根导出,符合新的模块入口策略,保持功能不变。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/history.ts (1)
1-1
: 更新 History 重导出源为包根
将History
的导出源切换为@tarojs/runtime
根路径,与构建输出统一,无副作用。packages/taro-platform-harmony/src/runtime-ets/bom/location.ts (1)
1-1
: 重新导出 Location 的路径对齐
将Location
重导出源更改为包根@tarojs/runtime
,保持接口不变,符合新构建配置。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/URL.ts (1)
1-1
: 合并并简化 URL 相关接口导出
将parseUrl
,URL
,URLSearchParams
一并从包根导出,去除深层路径,保持原有功能一致性。packages/taro-runtime/src/__tests__/eventSource.spec.js (2)
1-2
: 更新了导入路径,符合ES模块规范导入路径从
../../dist/runtime.esm
改为../../dist/index
,这符合PR目标中提到的使用tsdown来构建taro-runtime包的变更。使用更具体的导入语法也提高了代码可读性。
5-6
: 更新了变量赋值,与新的导入方式匹配通过别名导入后,这里相应地更新了变量赋值,确保测试代码的正确性。这种方式更清晰地表明了依赖关系。
packages/taro-runtime/src/__tests__/html.spec.js (2)
10-10
: 更新了导入路径,符合ES模块规范导入路径从
../../dist/runtime.esm
改为../../dist/index
,这符合PR中使用tsdown构建taro-runtime包的目标。这与其他测试文件的修改保持一致。
331-331
: 优化了测试用例中的文本内容在测试用例中添加了空格,使文本内容
"测试换行 xxxx"
更加清晰,并相应地更新了测试断言。这是一个小的改进,提高了测试的可读性。Also applies to: 340-340
packages/taro-platform-harmony/src/runtime-ets/index.ts (1)
33-33
: 简化了导入路径导入路径从
@tarojs/runtime/dist/runtime.esm
改为@tarojs/runtime
,这简化了模块导入路径,统一了整个代码库中的导入方式。这符合PR中提到的移除Rollup配置,使用tsdown构建的目标。packages/taro-runtime/src/__tests__/event.spec.js (3)
1-2
: 更新了导入方式,符合ES模块规范使用ES模块导入语法直接从
../../dist/index
导入所需的函数和对象,取代了之前从../../dist/runtime.esm
导入的方式。这与PR中提到的使用tsdown构建taro-runtime包的目标一致。
4-4
: 更新了document变量的赋值通过别名导入后,这里相应地更新了document变量的赋值,确保测试代码的正确性。
14-14
: 更新了createEvent函数的调用方式将之前通过runtime对象调用createEvent的方式改为直接调用导入的createEvent函数,这与新的导入方式相匹配。这种变更保持了代码的一致性,使代码更加简洁。
Also applies to: 23-23, 33-33, 45-45, 57-57, 73-73, 101-101, 117-117, 135-135, 150-150, 165-165, 177-177
packages/taro-runtime/src/__tests__/dom.spec.js (1)
7-11
: 静态引入使测试更清晰
将原先的动态require
改为 ESModuleimport
大大提升了可读性,且便于 IDE 跳转和静态检查。packages/taro-runtime/jest.config.js (1)
1-4
: ESModule 格式的 Jest 配置转换正确
将require
替换为import
,并通过import.meta.url
推导__dirname
,使整个文件保持一致的 ESM 风格,符合package.json
中的"type": "module"
。packages/taro-runtime/src/__tests__/exports.spec.js (5)
1-1
: 使用 ESModule 静态导入导出项
将原先的 CJSrequire
换为静态import
,对createComponentConfig
,createEvent
, 等一并按需导入,提高打包和 Tree-shaking 效果。
8-14
: 验证基础 BOM 导出
expect(document).toBe(window.document)
及expect(navigator).toBe(window.navigator)
逻辑清晰,确保全局对象正确映射。
17-21
: 验证 DOM 导出项
断言TaroElement
,TaroNode
,TaroText
存在,覆盖了主要 DOM 类型导出。
23-26
: 验证事件系统导出项
断言createEvent
,TaroEvent
存在,保证事件 API 已正确导出。
28-31
: 验证 DSL 导出项
断言createComponentConfig
,createPageConfig
存在,确认 DSL 构建工具 API 未缺失。packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/index.ts (2)
25-25
: 注释格式调整统一性
这些改动仅涉及注释的中英文标点和空格格式化,无需深入审查。Also applies to: 27-27, 29-29, 31-31, 33-33, 35-35, 37-37, 39-39, 46-46
79-79
: 简化导出路径
将深度路径@tarojs/runtime/dist/runtime.esm
替换为包根导入@tarojs/runtime
,与package.json
中的exports
声明保持一致。请验证模块解析和打包配置已正确生效。packages/taro-runtime/package.json (3)
3-3
: 启用 ES 模块
新增"type": "module"
用于包级 ESM 支持,符合迁移到 tsdown 构建后的需求。
9-10
: 统一入口配置
新增"main:h5": "dist/index.js"
与"exports": "./dist/index.js"
,简化模块暴露路径。请确认这两个字段满足各环境加载需求,并与其他平台包配置保持一致。
39-39
: 确认 React 版本及依赖位置
将react
以devDependencies
引入以支持类型或测试,请确认版本与 monorepo 其它包保持一致,或根据使用场景决定是否应移至peerDependencies
。
packages/taro-platform-harmony/src/runtime-ets/emitter/emitter.ts
Outdated
Show resolved
Hide resolved
packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/raf.ts
Outdated
Show resolved
Hide resolved
|
|
第一项帮忙合一下? #17753 |
|
||
module.exports = { | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) |
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.
@tarojs/runtime
并没有声明 "type": "module",
这样有问题吧,建议变动尽量小。
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.
在 package.json 里加了 "type": "module"
,而且本来之前导出的文件也都是esm
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.
我个人倾向于先保持 commonjs 的效果,避免一些意外。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17746 +/- ##
========================================
Coverage 59.37% 59.37%
========================================
Files 387 387
Lines 23417 23417
Branches 5141 5145 +4
========================================
Hits 13903 13903
- Misses 8020 8153 +133
+ Partials 1494 1361 -133
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
这个合了应该就可以支持node22了 |
@yoyo837 还有啥要改的吗 |
@yoyo837 这样如何? |
@yoyo837 这样更符合 |
我还是倾向于尽量兼容现状,避免一些意外来回 revert 和 fix. |
Beyond compare |
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.
Actionable comments posted: 2
♻️ Duplicate comments (1)
packages/taro-runtime/tsdown.config.ts (1)
1-1
: 请确认 tsdown 依赖项声明根据之前的评审意见,需要在
packages/taro-runtime/package.json
中添加 tsdown 的 devDependencies 声明。请确认该依赖项是否已正确添加。
🧹 Nitpick comments (1)
packages/taro-runtime/tsdown.config.ts (1)
16-24
: 简化配置并优化输出设置CommonJS 配置存在几个可优化的点:
outExtensions
函数可能不必要,CJS 格式默认使用.js
扩展名- 禁用 treeshake 可能增加包体积
- 缺少输出目录配置
建议简化配置:
defineConfig({ entry: { 'index.cjs': 'src/index.ts', }, + outDir: 'dist', format: 'cjs', - outExtensions: () => ({ js: '.js' }), - treeshake: false, + treeshake: true, sourcemap: true, }),如果需要保持禁用 treeshake,请在注释中说明原因。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (4)
package.json
(1 hunks)packages/shared/src/shortcuts.ts
(1 hunks)packages/taro-runtime/tsconfig.json
(1 hunks)packages/taro-runtime/tsdown.config.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- package.json
- packages/taro-runtime/tsconfig.json
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
🔇 Additional comments (3)
packages/shared/src/shortcuts.ts (2)
2-15
: LGTM!从 const enum 到 as const 对象的重构很好!这个变更很棒,理由如下:
- 避免了 const enum 的陷阱:正如注释中提到的,const enum 确实存在一些问题,特别是在模块系统和构建工具兼容性方面
- 保持了类型安全性:使用
as const
断言可以获得与 const enum 类似的类型推断和代码提示- 更好的工具兼容性:这种写法与现代构建工具(如 tsdown)兼容性更好
- 保持向后兼容:导出的值保持不变,不会影响现有代码
这个重构与项目迁移到 tsdown 的目标完全一致。
17-17
: 新增的类型定义设计合理
Shortcuts
类型别名的定义很有用:export type Shortcuts = typeof Shortcuts[keyof typeof Shortcuts]这创建了一个联合类型
'container' | 'cn' | 'v' | 'nt' | 'nn' | 'sid' | 'st' | 'cl' | 'src'
,可以在其他地方用来约束函数参数或返回值类型,提供更好的类型安全性。packages/taro-runtime/tsdown.config.ts (1)
3-25
:❓ Verification inconclusive
验证输出结构一致性并添加配置说明
根据 PR 讨论中的反馈,需要确保 tsdown 构建输出与原有 Rollup 构建保持一致性,避免意外的回归问题。
建议:
- 添加配置注释说明每个构建配置的用途
- 验证输出结构是否与原有构建一致
同时建议在配置文件中添加注释:
export default [ + // 无束化构建:保持源文件目录结构 defineConfig({ entry: 'src/index.ts', sourcemap: true, unbundle: true, }), + // ESM 束化构建:用于现代环境 defineConfig({ entry: { 'runtime.esm': 'src/index.ts', }, treeshake: false, sourcemap: true, }), + // CommonJS 构建:用于兼容性 defineConfig({ entry: { 'index.cjs': 'src/index.ts', }, format: 'cjs', outExtensions: () => ({ js: '.js' }), treeshake: false, sourcemap: true, }), ]
🏁 Script executed:
#!/bin/bash # 描述:检查原有 Rollup 配置以对比输出结构 # 预期:找到被删除的 rollup.config.ts 以了解原有输出结构 # 查找可能的 Rollup 配置备份或 git 历史 rg -l "rollup.config" --type ts --type js git log --oneline --follow -- packages/taro-runtime/rollup.config.ts | head -5Length of output: 218
为了进一步确认
taro-runtime
原有的 Rollup 输出结构,请检查历史中的rollup.config.ts
:
🏁 Script executed:
#!/bin/bash # 检查 taro-runtime 包是否曾经存在 rollup.config.ts 及其变更记录 git log --oneline --follow -- packages/taro-runtime/rollup.config.ts | head -10Length of output: 0
请手动验证 taro-runtime 构建输出结构一致性
在
packages/taro-runtime
中未能找到原始的rollup.config.ts
历史记录,自动对比不可行。为避免潜在回归,请手动对比新旧打包产物,确认输出目录、文件命名及内容保持一致。建议:
- 在
tsdown.config.ts
(packages/taro-runtime/tsdown.config.ts)中为每段配置添加注释,说明各自用途- 本地执行 tsdown 构建,并与原有 Rollup 打包结果对比(目录结构、文件名称、模块格式、sourcemap 等)
- 在项目文档(如 README 或 CONTRIBUTING)中补充此配置变更及输出结构说明
这个 PR 做了什么? (简要描述所做更改)
使用 tsdown 对 taro-runtime 进行构建,删除不兼容 node22 的 rollup 插件
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
构建与依赖
@tarojs/runtime
包声明为 ES module,构建脚本和配置已相应调整。其他变更