Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

chore: add tsdown #17746

wants to merge 3 commits into from

Conversation

ianzone
Copy link
Contributor

@ianzone ianzone commented May 19, 2025

这个 PR 做了什么? (简要描述所做更改)
使用 tsdown 对 taro-runtime 进行构建,删除不兼容 node22 的 rollup 插件

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

Summary by CodeRabbit

  • 构建与依赖

    • 构建工具从 Rollup 切换为 tsdown,相关配置和依赖已更新。
    • 移除了 Rollup 相关的脚本和依赖,新增 tsdown 相关配置文件。
    • @tarojs/runtime 包声明为 ES module,构建脚本和配置已相应调整。
  • 其他变更

    • 优化了部分导出语句顺序,不影响功能和对外接口。
    • Jest 配置文件切换为 ES module 语法,保持测试功能不变。
    • TypeScript 配置调整,移除对已删除 Rollup 配置文件的编译包含。

Copy link

coderabbitai bot commented May 19, 2025

"""

Walkthrough

本次变更主要将 @tarojs/runtime 包的构建工具从 Rollup 迁移到 tsdown,相关配置文件与脚本做了相应调整。涉及 ES module 语法替换、依赖项更新、构建脚本和配置文件的增删,以及部分导出顺序调整。

Changes

文件/路径分组 变更摘要
package.json devDependencies 新增 tsdown,位置在 typescript 之前。
packages/taro-runtime/jest.config.js Jest 配置由 CommonJS 改为 ES module 语法,使用 ES import/export。
packages/taro-runtime/package.json 添加 "type": "module",构建脚本由 rollup 切换为 tsdown,移除 rollup 相关依赖。
packages/taro-runtime/rollup.config.ts 删除 Rollup 配置文件。
packages/taro-runtime/tsdown.config.ts 新增 tsdown 配置文件,导出两个不同 entry 的构建配置。
packages/taro-runtime/tsconfig.json "include" 移除 rollup.config.ts,仅包含 src 目录。
packages/taro-rn/src/lib/index.ts 调整导出语句顺序,无功能变化。

Sequence Diagram(s)

sequenceDiagram
    participant 开发者
    participant tsdown
    participant 源码(src)
    participant 输出(dist)

    开发者->>tsdown: 运行 tsdown (build/dev)
    tsdown->>源码(src): 读取 TypeScript 源码
    tsdown->>输出(dist): 生成 ESM 构建产物(runtime.esm.js),带 sourcemap
Loading

Suggested reviewers

  • yoyo837

Poem

🐇
换下 rollup,迎来 tsdown,
构建流程轻快又轻松。
配置新旧交替转,
源码依旧稳如松。
兔子拍手跳一跳,
新工具上线乐无穷!
"""

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cce5917 and a86deca.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.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/tsdown.config.ts
⏰ 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
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot requested review from luckyadam and tutuxxx May 19, 2025 18:40
Copy link

@coderabbitai coderabbitai bot left a 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: 建议显式指定输出目录和格式
当前配置中只定义了 entrysourcemap,依赖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e390b4 and f2147a5.

⛔ 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: 统一导入路径,移除深层依赖
PageConfigTFunc 从深层路径切换为根包导出,保持与其他子包一致,提升可维护性。
请确认在 @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: 更新导出路径为包根引入
parseUrlURLURLSearchParams 的来源都改为 @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

确认路由工具方法根入口导出

addLeadingSlashgetCurrentPagegetHomePage 等路由工具函数已切换至根导入,请在 @tarojs/runtime/dist/index.js 中验证它们是否暴露,以免构建后缺少相关 API。

建议使用:


🏁 Script executed:

#!/bin/bash
# 验证 addLeadingSlash 等路由工具函数导出
rg "addLeadingSlash" packages/taro-runtime/dist/index.js

Length 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.js
packages/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.js

Length 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"
done

Length 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.js
packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/emitter/emitter.ts (2)

1-2: 更新导入路径以使用新的运行时入口
导入路径已从深层次子路径调整为 @tarojs/runtime,符合统一模块入口策略,无功能变化。


29-29: 更新导出路径以使用新的运行时入口
已将 EventsEventsType 的导出路径从深层路径更新为 @tarojs/runtime,保持与项目入口一致。

packages/taro-platform-harmony/src/runtime-ets/interface/index.ts (1)

2-2: 统一接口导出路径
已将 PageConfigTFunc 的导出路径改为 @tarojs/runtime,保持与运行时包入口一致,无功能影响。

packages/taro-platform-harmony/src/runtime-ets/bom/raf.ts (1)

1-1: 统一 BOM 方法导出
已将 cancelAnimationFramenowrequestAnimationFrame 改为从 @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 改为 ESModule import 大大提升了可读性,且便于 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 静态导入导出项
将原先的 CJS require 换为静态 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 版本及依赖位置
reactdevDependencies 引入以支持类型或测试,请确认版本与 monorepo 其它包保持一致,或根据使用场景决定是否应移至 peerDependencies

CONTRIBUTING.md Outdated

### 1. 环境准备

> 需要安装 [Node.js 16](https://nodejs.org/en/)(建议安装 `16.20.0` 及以上版本)及 [pnpm 7](https://pnpm.io/zh/installation)
> 需要安装 [Node.js 20](https://nodejs.org/en/)(建议安装 `20.19.2` 及以上版本)及 [pnpm 10](https://pnpm.io/zh/installation)
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

请验证 package.json 中的 engines 是否同步更新
文档中要求 Node.js 20.x(>=20.19.2)及 pnpm 10,请检查根目录 package.json"engines" 字段是否一致,以避免版本不匹配。


🏁 Script executed:

#!/usr/bin/env bash
# 检查 package.json 中 engines 设置
rg -n '"engines"' -A2 package.json

Length of output: 36


请运行以下脚本以确认仓库中是否存在 package.json 及其 "engines" 字段的当前设置:


🏁 Script executed:

#!/usr/bin/env bash
# 查找 package.json 文件
files=$(fd -t f -n package.json)
if [ -z "$files" ]; then
  echo "未找到 package.json"
  exit 0
fi
echo "找到的 package.json 文件:"
echo "$files"

# 检查 engines 字段
for f in $files; do
  echo
  echo "文件: $f"
  rg -n '"engines"' -A2 $f || echo "未检测到 engines 字段"
done

Length of output: 334


请运行以下脚本,确认仓库中是否存在 package.json 及其 "engines" 字段的具体内容:


🏁 Script executed:

#!/usr/bin/env bash
# 搜索仓库中的 package.json 文件并查看 engines 设置
echo "正在查找 package.json..."
mapfile -t files < <(find . -type f -name 'package.json')
if [ ${#files[@]} -eq 0 ]; then
  echo "未找到任何 package.json 文件"
  exit 0
fi

for f in "${files[@]}"; do
  echo
  echo "文件: $f"
  grep -n '"engines"' -A3 "$f" || echo "  ❌ 未检测到 engines 字段"
done

Length of output: 295


请确认 package.json 存在性及 engines 字段同步
仓库中未检测到任何 package.json 文件:

  • 如果该项目确实使用 Node.js,请在根目录添加 package.json 并在 "engines" 字段中指定 node: ">=20.19.2"pnpm: ">=10"
  • 如果不使用 Node.js 或不需要限制版本,请移除或调整 CONTRIBUTING.md 中关于 Node.js 20.x 和 pnpm 10 的说明,以免文档与项目不符。
🤖 Prompt for AI Agents
In CONTRIBUTING.md at line 9, the document requires Node.js 20.x (>=20.19.2) and
pnpm 10, but the repository lacks a package.json file with an "engines" field
specifying these versions. To fix this, either add a package.json file in the
root directory with an "engines" field that sets node to ">=20.19.2" and pnpm to
">=10" if Node.js is used, or if Node.js is not used or version restrictions are
unnecessary, update CONTRIBUTING.md to remove or adjust the Node.js and pnpm
version requirements to keep documentation consistent with the project setup.

@@ -1 +1 @@
export { eventCenter, Events, EventsType } from '@tarojs/runtime/dist/runtime.esm'
export { eventCenter, Events, EventsType } from '@tarojs/runtime'
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

确认导出路径更新正确

已将 eventCenterEventsEventsType 从深度路径切换至 @tarojs/runtime 根入口,请确保在构建产物 dist/index.js 中实际导出这些符号,以防模块解析错误或类型缺失。

运行以下脚本验证:


🏁 Script executed:

#!/bin/bash
# 验证 eventCenter 导出是否存在
rg "eventCenter" packages/taro-runtime/dist/index.js

Length of output: 128


下面脚本会在 packages 目录下查找所有 dist/index.js 并检查 eventCenter 导出是否存在,请查看输出:


🏁 Script executed:

#!/bin/bash
# 查找所有 dist/index.js 并验证 eventCenter 导出
if ! command -v fd &>/dev/null; then
  echo "请先安装 fd (fd-find) 后重试"
  exit 1
fi

files=$(fd --type f --glob 'dist/index.js' packages)
if [ -z "$files" ]; then
  echo "未在 packages 目录下找到任何 dist/index.js"
  exit 0
fi

for file in $files; do
  echo "检查文件:$file"
  if rg "eventCenter" "$file"; then
    echo "✔ 找到 eventCenter 导出或引用"
  else
    echo "✖ 未找到 eventCenter,可能需要在该文件中添加导出"
  fi
done

Length of output: 171


下面我们进一步确认 taro-runtime 包的构建输出目录和入口文件,确保能定位到实际的产物并检查 eventCenter 导出:


🏁 Script executed:

#!/bin/bash
# 列出 packages/taro-runtime 下的所有文件,查看输出结构
echo "=== packages/taro-runtime 文件列表 ==="
if ! command -v fd &>/dev/null; then
  echo "请安装 fd (fd-find) 后重试"
  exit 1
fi
fd --max-depth 3 --type f "" packages/taro-runtime

# 查看 package.json 中的 main 字段
echo "=== 查看 package.json main 字段 ==="
grep -R "\"main\"" -n packages/taro-runtime/package.json || echo "未在 package.json 中找到 main 字段"

# 在可能的入口文件中查找 eventCenter 导出
echo "=== 在疑似入口文件中查找 eventCenter ==="
ENTRY=$(grep -R "\"main\"" -m1 packages/taro-runtime/package.json | sed -E 's/.*: *"([^"]+)".*/\1/')
if [ -n "$ENTRY" ]; then
  echo "检测到入口:$ENTRY"
  rg "eventCenter" "packages/taro-runtime/$ENTRY" || echo "✖ 未在入口文件中找到 eventCenter"
else
  echo "⚠ 无法自动定位入口文件,请手动确认"
fi

Length of output: 3837


下面我们针对 taro-platform-harmony 包的构建产物再次核验,确保在最终的产物里正确导出 eventCenterEventsEventsType

请根据输出确认 eventCenterEventsEventsType 已在产物中正确导出,否则需要在 packages/taro-platform-harmony/dist/index.js(或对应入口文件)添加相应导出。


🏁 Script executed:

#!/bin/bash
# 列出 packages/taro-platform-harmony 下所有生成文件
echo "=== packages/taro-platform-harmony 文件列表 ==="
if ! command -v fd &>/dev/null; then
  echo "请安装 fd (fd-find) 后重试"
  exit 1
fi
fd --max-depth 3 --type f "" packages/taro-platform-harmony

# 查看 package.json 中的 main 或 module 字段
echo "=== 查看 package.json 入口字段 ==="
grep -R -n "\"main\"\|\"module\"" packages/taro-platform-harmony/package.json || echo "⚠ 未找到 main/module 字段"

# 寻找所有可能的 index.js 并检查导出
echo "=== 在所有 index.js 中查找 eventCenter, Events, EventsType ==="
for file in $(fd --type f --glob 'index.js' packages/taro-platform-harmony); do
  echo "检查:$file"
  for symbol in eventCenter Events EventsType; do
    if rg "export.*${symbol}" "$file"; then
      echo "  ✔ 找到 ${symbol} 导出"
    else
      echo "  ✖ 未找到 ${symbol} 导出"
    fi
  done
done

Length of output: 28815


缺少 eventCenter、Events 和 EventsType 在产物入口文件中的导出

脚本验证发现 packages/taro-platform-harmony/index.js(rollup 输出的入口文件)中并未导出以下符号:

  • eventCenter
  • Events
  • EventsType

请在该文件(或对应的 dist/index.js)中添加导出:

+ export { eventCenter, Events, EventsType } from '@tarojs/runtime'

确保构建产物能够正确向外暴露这三个符号,避免模块解析或类型缺失的问题。

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/taro-platform-harmony/src/runtime-ets/emitter/emitter.ts at line 1,
the export statement re-exports eventCenter, Events, and EventsType from
'@tarojs/runtime', but the built output (dist/index.js) does not actually export
these symbols. To fix this, ensure that the build configuration and entry files
for taro-platform-harmony explicitly export eventCenter, Events, and EventsType
so they appear in the final dist/index.js. This may involve adding explicit
export statements or adjusting the rollup/build setup to include these exports
in the output entry file.

@@ -1 +1 @@
export { cancelAnimationFrame, now, requestAnimationFrame } from '@tarojs/runtime/dist/runtime.esm'
export { cancelAnimationFrame, now, requestAnimationFrame } from '@tarojs/runtime'
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

检查 raf API 根导出是否完整

cancelAnimationFramenowrequestAnimationFrame 已从根入口导出,请确认 @tarojs/runtime/dist/index.js 中包含这些导出,以保证平台兼容性及功能可用性。

执行以下命令进行验证:


🏁 Script executed:

#!/bin/bash
# 验证 requestAnimationFrame 等 API 导出是否存在
rg "requestAnimationFrame" packages/taro-runtime/dist/index.js

Length of output: 138


为了准确定位并验证 @tarojs/runtime/dist/index.js 中是否完整导出了 requestAnimationFramecancelAnimationFramenow,请执行以下脚本:


🏁 Script executed:

#!/bin/bash
set -e
# 1. 列出仓库中所有 dist/index.js 的路径
echo "查找所有 dist/index.js 文件:"
find . -type f -path "*/dist/index.js"

# 2. 在这些文件中搜索相关 API 的导出声明
echo -e "\n检查 requestAnimationFrame 导出:"
rg -n "export\s*{[^}]*requestAnimationFrame" -g "*dist/index.js"

echo -e "\n检查 cancelAnimationFrame 导出:"
rg -n "export\s*{[^}]*cancelAnimationFrame" -g "*dist/index.js"

echo -e "\n检查 now 导出:"
rg -n "export\s*{[^}]*now" -g "*dist/index.js"

Length of output: 4022


请进一步定位 @tarojs/runtime 包的入口并验证导出:


🏁 Script executed:

#!/bin/bash
set -e

# 1. 查找 packages 目录下 name 为 @tarojs/runtime 的 package.json
echo "查找 @tarojs/runtime 包所在位置:"
pkg_json=$(rg -l '"name":\s*"@tarojs/runtime"' -g 'packages/*/package.json' || true)
if [[ -z "$pkg_json" ]]; then
  echo "未找到 @tarojs/runtime 包的 package.json" >&2
  exit 1
fi
echo "$pkg_json"

# 2. 获取包根目录
pkg_dir=$(dirname "$pkg_json")
echo -e "\n包目录:$pkg_dir"

# 3. 查看 package.json 中 main/module/exports 字段
echo -e "\n读取入口字段:"
jq '{main, module, exports}' "$pkg_json"

# 4. 检查 main 指向的文件是否存在
main_entry=$(jq -r '.main' "$pkg_json")
echo -e "\nmain 指向:$main_entry"
if [[ -f "$pkg_dir/$main_entry" ]]; then
  echo "入口文件存在:$pkg_dir/$main_entry"
else
  echo "入口文件不存在:$pkg_dir/$main_entry" >&2
fi

# 5. 在入口文件中搜索导出符号
entry="$pkg_dir/$main_entry"
echo -e "\n检查 requestAnimationFrame:"
rg -n "requestAnimationFrame" "$entry" || true

echo -e "\n检查 cancelAnimationFrame:"
rg -n "cancelAnimationFrame" "$entry" || true

echo -e "\n检查 now:"
rg -n "now" "$entry" || true

Length of output: 713


请修正 jq 用法并读取入口字段后再验证导出,执行以下脚本:


🏁 Script executed:

#!/bin/bash
set -e

# 定位 @tarojs/runtime 包
pkg_json=$(rg -l '"name":\s*"@tarojs/runtime"' -g 'packages/*/package.json' || true)
if [[ -z "$pkg_json" ]]; then
  echo "❌ 未找到 packages/*/package.json 中 name 为 @tarojs/runtime 的包" >&2
  exit 1
fi
pkg_dir=$(dirname "$pkg_json")
echo "包目录:$pkg_dir"

# 正确读取 main、module、exports 字段
echo "读取 package.json 中的入口字段:"
jq '{main: .main, module: .module, exports: .exports}' "$pkg_json"

# 分别检查 main 和 module 指定的文件
for field in main module; do
  entry=$(jq -r ".${field} // empty" "$pkg_json")
  [[ -z "$entry" ]] && continue
  echo -e "\n$field 指向:$entry"
  if [[ -f "$pkg_dir/$entry" ]]; then
    echo "✅ 文件存在:$pkg_dir/$entry"
    # 搜索导出符号
    for sym in requestAnimationFrame cancelAnimationFrame now; do
      echo "  ↳ 检查 $sym"
      rg -n "$sym" "$pkg_dir/$entry" || echo "    ❌ 未找到 $sym"
    done
  else
    echo "❌ 文件不存在:$pkg_dir/$entry" >&2
  fi
done

Length of output: 816


下面再针对 exports 指向的 dist/index.js 文件进行导出符号检查,请执行:


🏁 Script executed:

#!/bin/bash
set -e

entry="packages/taro-runtime/dist/index.js"
echo "检查文件:$entry"
if [[ -f "$entry" ]]; then
  echo -e "\n查找 export 语句中是否包含 API:"
  rg -n "export\s*{[^}]*requestAnimationFrame" "$entry" \
    || echo "  ❌ 未在 export 里找到 requestAnimationFrame"
  rg -n "export\s*{[^}]*cancelAnimationFrame" "$entry" \
    || echo "  ❌ 未在 export 里找到 cancelAnimationFrame"
  rg -n "export\s*{[^}]*now" "$entry" \
    || echo "  ❌ 未在 export 里找到 now"

  echo -e "\n全文件检索 API 出现位置:"
  rg -n "requestAnimationFrame|cancelAnimationFrame|now" "$entry" || echo "  ❌ 在文件中未找到任何匹配"
else
  echo "❌ 文件不存在:$entry" >&2
  exit 1
fi

Length of output: 352


请先列出 packages/taro-runtime 目录下的文件结构,以确认 dist 目录及入口文件名:


🏁 Script executed:

#!/bin/bash
set -e
echo "列出 packages/taro-runtime 目录下所有文件:"
find packages/taro-runtime -type f

Length of output: 3938


请确认 @tarojs/runtime 根导出中包含 RAF 相关 API

由于仓库中并未提交 dist 产物,请先在源码入口验证:

如果源码中已正确 re-export,上线前请构建并在最终产物 dist/index.js 中再次确认:

以确保 cancelAnimationFrame, now, requestAnimationFrame 都会被包含在发布包中。


🏁 Script executed:

#!/bin/bash
# 1. 在 src/index.ts 中检查 re-export
rg -n "export\s*{[^}]*requestAnimationFrame" packages/taro-runtime/src/index.ts || echo "未找到 requestAnimationFrame 的导出"
rg -n "export\s*{[^}]*cancelAnimationFrame" packages/taro-runtime/src/index.ts || echo "未找到 cancelAnimationFrame 的导出"
rg -n "export\s*{[^}]*now" packages/taro-runtime/src/index.ts || echo "未找到 now 的导出"

Length of output: 763


🏁 Script executed:

rg "requestAnimationFrame\|cancelAnimationFrame\|now" packages/taro-runtime/dist/index.js

Length of output: 167


为进一步确认 @tarojs/runtime 是否在根入口正确暴露了 raf 相关 API,请执行以下脚本:

请根据输出确认 cancelAnimationFramerequestAnimationFramenow 在源码和最终构建产物中均有导出,否则需要在 packages/taro-runtime/src/index.ts 中补充:

export * from './bom/raf'

并确保构建后 dist/index.js 中包含这三项导出。


🏁 Script executed:

#!/bin/bash
set -e

# 1. 检查根入口是否 re-export 了 raf 模块
echo "→ 检查 packages/taro-runtime/src/index.ts 中的 raf re-export:"
rg -n "export \\* from './bom/raf'" packages/taro-runtime/src/index.ts \
  || echo "  ❌ 未在根入口找到 raf 模块的 re-export"

# 2. 查看 raf.ts 源码,确认内部 API 导出
echo -e "\n→ 打印 packages/taro-runtime/src/bom/raf.ts 前 50 行:"
sed -n '1,50p' packages/taro-runtime/src/bom/raf.ts

Length of output: 1561


确保 @tarojs/runtime 根入口导出 RAF 相关 API

当前问题:

  • packages/taro-runtime/src/index.ts 中并未从 ./bom/raf 导出任何 RAF 相关符号。
  • 而在 packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/raf.ts 里,代码尝试
    export { cancelAnimationFrame, now, requestAnimationFrame } from '@tarojs/runtime'
    但根入口缺少这三项,因此会导致运行时无法找到对应导出。

修复建议:
packages/taro-runtime/src/index.ts 中添加对 RAF 模块的 re-export,示例如下:

--- a/packages/taro-runtime/src/index.ts
+++ b/packages/taro-runtime/src/index.ts
@@ 1,5 +1,8 @@
 // … 已有导出
 export * from './bom/window'
+// 重新导出 raf 相关 API,映射为标准名称
+export { now } from './bom/raf'
+export { raf as requestAnimationFrame, caf as cancelAnimationFrame } from './bom/raf'
+
 // … 其他导出

完成后,请重新构建并在最终产物 dist/index.js 中验证:

rg "requestAnimationFrame\|cancelAnimationFrame\|now" packages/taro-runtime/dist/index.js

确保这三项导出均存在。

🤖 Prompt for AI Agents
In packages/taro-platform-harmony-cpp/src/runtime/runtime-cpp/bom/raf.ts at line
1, the code exports cancelAnimationFrame, now, and requestAnimationFrame from
'@tarojs/runtime', but these are not re-exported from the root entry of
@tarojs/runtime. To fix this, add a re-export statement for the RAF module in
packages/taro-runtime/src/index.ts by including "export * from './bom/raf'".
After this change, rebuild the project and verify that the final dist/index.js
in packages/taro-runtime includes exports for cancelAnimationFrame, now, and
requestAnimationFrame.

@yoyo837
Copy link
Contributor

yoyo837 commented May 20, 2025

  1. 混合了其他修改;
  2. tsdown 会不会不够热门?
  3. 改动略大,有没有更保守一点的方案?

@ianzone
Copy link
Contributor Author

ianzone commented May 20, 2025

  1. 混合了其他修改;
  2. tsdown 会不会不够热门?
  3. 改动略大,有没有更保守一点的方案?
  1. 我可以另提PR
  2. tsdown属于尤雨溪的rolldown项目,而rolldown即将代替rollup成为vite的默认打包工具,所以无论从代码质量还是流行程度我认为都不是问题
  3. 我需要明确到底啥能改啥不能改,还请解答一下这里的问题 chore(release): publish 4.1.0 #17714 (comment)

@ianzone ianzone mentioned this pull request May 20, 2025
18 tasks
@ianzone
Copy link
Contributor Author

ianzone commented May 22, 2025

  1. 混合了其他修改;
  2. tsdown 会不会不够热门?
  3. 改动略大,有没有更保守一点的方案?

第一项帮忙合一下? #17753


module.exports = {
const __dirname = path.dirname(fileURLToPath(import.meta.url))
Copy link
Contributor

@yoyo837 yoyo837 May 22, 2025

Choose a reason for hiding this comment

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

@tarojs/runtime 并没有声明 "type": "module", 这样有问题吧,建议变动尽量小。

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

我个人倾向于先保持 commonjs 的效果,避免一些意外。

@coderabbitai coderabbitai bot requested a review from yoyo837 May 22, 2025 15:01
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.37%. Comparing base (5d19bfa) to head (a86deca).
Report is 1 commits behind head on main.

❌ Your project check has failed because the head coverage (59.37%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17746    +/-   ##
========================================
  Coverage   59.37%   59.37%            
========================================
  Files         387      387            
  Lines       23417    23417            
  Branches     5141     5131    -10     
========================================
  Hits        13903    13903            
- Misses       8020     8177   +157     
+ Partials     1494     1337   -157     
Flag Coverage Δ
taro-cli 72.37% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.19% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 44 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ianzone
Copy link
Contributor Author

ianzone commented May 22, 2025

这个合了应该就可以支持node22了

@ianzone
Copy link
Contributor Author

ianzone commented May 23, 2025

@yoyo837 还有啥要改的吗

@yoyo837
Copy link
Contributor

yoyo837 commented May 23, 2025

image

能保持原来的结构吗?不要文件hash,作为 lib,dist下的文件应该尽量保持名称不变。

@ianzone
Copy link
Contributor Author

ianzone commented May 23, 2025

@yoyo837 这样如何?
image

@ianzone
Copy link
Contributor Author

ianzone commented May 23, 2025

@yoyo837 这样更符合
image

@ianzone
Copy link
Contributor Author

ianzone commented May 23, 2025

image 能保持原来的结构吗?不要文件hash,作为 lib,dist下的文件应该尽量保持名称不变。

已更新

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.

2 participants