Skip to content

Comments

fix(taro-runtime): 修复 taro runtime node22 编译失败#17848

Merged
Single-Dancer merged 3 commits intomainfrom
fix/taro-runtime-compile
Jun 23, 2025
Merged

fix(taro-runtime): 修复 taro runtime node22 编译失败#17848
Single-Dancer merged 3 commits intomainfrom
fix/taro-runtime-compile

Conversation

@Single-Dancer
Copy link
Collaborator

@Single-Dancer Single-Dancer commented Jun 16, 2025

这个 PR 做了什么? (简要描述所做更改)
修复 Node22 编译报错 "Unexpected identifier assert"

这个 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

  • 重构
    • 优化了打包配置,提升了构建流程的清晰度和可维护性。
  • 杂项
    • 更新了开发依赖,新增了类型声明打包插件,无影响于最终用户体验。
    • 统一更新了多个包的版本号至4.1.4-beta.0,确保版本一致性。

@coderabbitai
Copy link

coderabbitai bot commented Jun 16, 2025

"""

Walkthrough

本次更改主要重构了 @tarojs/runtime 包的 Rollup 构建配置。通过引入 rollup-plugin-dts,将类型声明文件的生成流程与 JavaScript 构建流程分离,并移除了 lodash 及旧的 TypeScript 插件,改用更显式和模块化的配置方式。同时,多个包的版本号统一从 4.1.3-alpha.1 更新至 4.1.4-beta.0

Changes

文件/分组 变更摘要
packages/taro-runtime/package.json 版本号更新至 4.1.4-beta.0,新增 rollup-plugin-dtsdevDependencies
packages/taro-runtime/rollup.config.ts 重构 Rollup 配置,移除 lodash 和旧的 rollup-plugin-ts,分离 JS 与 DTS 构建流程,使用 @rollup/plugin-typescriptrollup-plugin-dts
多个包的 package.json 文件(如 crates/native_binding/package.jsonnpm/darwin-arm64/package.jsonpackages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json 等) 统一将版本号从 4.1.3-alpha.1 更新至 4.1.4-beta.0,无其他改动。

Sequence Diagram(s)

sequenceDiagram
    participant Dev as 开发者
    participant Rollup as Rollup
    participant PluginTS as @rollup/plugin-typescript
    participant PluginDTS as rollup-plugin-dts

    Dev->>Rollup: 启动构建
    Rollup->>PluginTS: 构建 JS(声明生成关闭)
    Rollup->>PluginDTS: 构建 .d.ts 类型声明文件
    PluginTS-->>Rollup: 输出 JS 文件
    PluginDTS-->>Rollup: 输出 DTS 文件
    Rollup-->>Dev: 生成所有格式的 JS 与 DTS 文件
Loading

Possibly related PRs

Suggested reviewers

  • luckyadam
  • tutuxxx

Poem

🐇
新插件加入队,类型声明更明快,
构建流程分两路,JS、DTS各精彩。
Rollup 配置更清晰,兔子跳跃心中开,
代码世界新气象,春风拂面把歌唱!
🎉✨
"""


📜 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 b94ec2e and 08558b4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (79)
  • crates/native_binding/package.json (1 hunks)
  • npm/darwin-arm64/package.json (1 hunks)
  • npm/darwin-x64/package.json (1 hunks)
  • npm/linux-x64-gnu/package.json (1 hunks)
  • npm/linux-x64-musl/package.json (1 hunks)
  • npm/win32-x64-msvc/package.json (1 hunks)
  • package.json (1 hunks)
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json (1 hunks)
  • packages/babel-plugin-transform-solid-jsx/package.json (1 hunks)
  • packages/babel-plugin-transform-taroapi/package.json (1 hunks)
  • packages/babel-preset-taro/package.json (1 hunks)
  • packages/create-app/package.json (1 hunks)
  • packages/css-to-react-native/package.json (1 hunks)
  • packages/eslint-config-taro/package.json (1 hunks)
  • packages/eslint-plugin-taro/package.json (1 hunks)
  • packages/jest-helper/package.json (1 hunks)
  • packages/postcss-html-transform/package.json (1 hunks)
  • packages/postcss-plugin-constparse/package.json (1 hunks)
  • packages/postcss-pxtransform/package.json (1 hunks)
  • packages/postcss-unit-transform/package.json (1 hunks)
  • packages/rollup-plugin-copy/package.json (1 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/stylelint-config-taro-rn/package.json (1 hunks)
  • packages/stylelint-taro-rn/package.json (1 hunks)
  • packages/stylelint-taro/package.json (1 hunks)
  • packages/taro-api/package.json (1 hunks)
  • packages/taro-cli-convertor/package.json (1 hunks)
  • packages/taro-cli/package.json (1 hunks)
  • packages/taro-components-advanced/package.json (1 hunks)
  • packages/taro-components-library-react/package.json (1 hunks)
  • packages/taro-components-library-solid/package.json (1 hunks)
  • packages/taro-components-library-vue3/package.json (1 hunks)
  • packages/taro-components-react/package.json (1 hunks)
  • packages/taro-components-rn/package.json (1 hunks)
  • packages/taro-components/package.json (1 hunks)
  • packages/taro-extend/package.json (1 hunks)
  • packages/taro-framework-react/package.json (1 hunks)
  • packages/taro-framework-solid/package.json (1 hunks)
  • packages/taro-framework-vue3/package.json (1 hunks)
  • packages/taro-h5/package.json (1 hunks)
  • packages/taro-helper/package.json (1 hunks)
  • packages/taro-loader/package.json (1 hunks)
  • packages/taro-platform-alipay/package.json (1 hunks)
  • packages/taro-platform-ascf/package.json (1 hunks)
  • packages/taro-platform-h5/package.json (1 hunks)
  • packages/taro-platform-harmony-cpp/package.json (1 hunks)
  • packages/taro-platform-harmony-hybrid/package.json (1 hunks)
  • packages/taro-platform-harmony/package.json (1 hunks)
  • packages/taro-platform-jd/package.json (1 hunks)
  • packages/taro-platform-qq/package.json (1 hunks)
  • packages/taro-platform-swan/package.json (1 hunks)
  • packages/taro-platform-tt/package.json (1 hunks)
  • packages/taro-platform-weapp/package.json (1 hunks)
  • packages/taro-plugin-html/package.json (1 hunks)
  • packages/taro-plugin-http/package.json (1 hunks)
  • packages/taro-plugin-inject/package.json (1 hunks)
  • packages/taro-plugin-mini-ci/package.json (1 hunks)
  • packages/taro-plugin-react-devtools/package.json (1 hunks)
  • packages/taro-plugin-vue-devtools/package.json (1 hunks)
  • packages/taro-react/package.json (1 hunks)
  • packages/taro-rn-runner/package.json (1 hunks)
  • packages/taro-rn-style-transformer/package.json (1 hunks)
  • packages/taro-rn-supporter/package.json (1 hunks)
  • packages/taro-rn-transformer/package.json (1 hunks)
  • packages/taro-rn/package.json (1 hunks)
  • packages/taro-router-rn/package.json (1 hunks)
  • packages/taro-router/package.json (1 hunks)
  • packages/taro-runner-utils/package.json (1 hunks)
  • packages/taro-runtime-rn/package.json (1 hunks)
  • packages/taro-runtime/package.json (2 hunks)
  • packages/taro-runtime/rollup.config.ts (1 hunks)
  • packages/taro-service/package.json (1 hunks)
  • packages/taro-transformer-wx/package.json (1 hunks)
  • packages/taro-vite-runner/package.json (1 hunks)
  • packages/taro-webpack5-prebundle/package.json (1 hunks)
  • packages/taro-webpack5-runner/package.json (1 hunks)
  • packages/taro-with-weapp/package.json (1 hunks)
  • packages/taro/package.json (1 hunks)
  • packages/taroize/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (9)
  • packages/taro-platform-ascf/package.json
  • packages/taro-platform-jd/package.json
  • packages/eslint-plugin-taro/package.json
  • packages/taro-with-weapp/package.json
  • packages/taro-transformer-wx/package.json
  • npm/win32-x64-msvc/package.json
  • packages/stylelint-taro/package.json
  • packages/taro-framework-react/package.json
  • packages/stylelint-config-taro-rn/package.json
🚧 Files skipped from review as they are similar to previous changes (70)
  • packages/taro-platform-weapp/package.json
  • npm/darwin-x64/package.json
  • packages/taro-framework-vue3/package.json
  • packages/taro-plugin-mini-ci/package.json
  • npm/linux-x64-musl/package.json
  • packages/taro-plugin-inject/package.json
  • packages/postcss-unit-transform/package.json
  • packages/taro-webpack5-prebundle/package.json
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json
  • packages/postcss-pxtransform/package.json
  • packages/taro-loader/package.json
  • packages/taro-platform-alipay/package.json
  • packages/taro-components/package.json
  • packages/taro-runtime-rn/package.json
  • crates/native_binding/package.json
  • packages/taro-cli/package.json
  • packages/taro-components-library-solid/package.json
  • packages/taro-rn/package.json
  • packages/taro-components-react/package.json
  • packages/taro-plugin-react-devtools/package.json
  • packages/taro-vite-runner/package.json
  • packages/taro-platform-harmony-cpp/package.json
  • npm/linux-x64-gnu/package.json
  • packages/taro-platform-tt/package.json
  • packages/postcss-plugin-constparse/package.json
  • packages/taro-api/package.json
  • packages/taro-cli-convertor/package.json
  • packages/taro-rn-runner/package.json
  • packages/taro-framework-solid/package.json
  • packages/taro-rn-style-transformer/package.json
  • packages/taro-components-library-vue3/package.json
  • packages/taro-h5/package.json
  • packages/jest-helper/package.json
  • packages/taro-extend/package.json
  • packages/taro-platform-swan/package.json
  • packages/babel-plugin-transform-taroapi/package.json
  • packages/taro-rn-transformer/package.json
  • packages/taro-components-library-react/package.json
  • packages/css-to-react-native/package.json
  • packages/taro-platform-h5/package.json
  • packages/taro-plugin-http/package.json
  • packages/taro-runner-utils/package.json
  • packages/rollup-plugin-copy/package.json
  • npm/darwin-arm64/package.json
  • packages/taro-webpack5-runner/package.json
  • packages/taro-plugin-vue-devtools/package.json
  • packages/taro-platform-harmony/package.json
  • packages/create-app/package.json
  • packages/taro-router/package.json
  • packages/taro-components-advanced/package.json
  • packages/taro-react/package.json
  • packages/taro-helper/package.json
  • packages/shared/package.json
  • packages/taro-rn-supporter/package.json
  • packages/taro-service/package.json
  • packages/taro-components-rn/package.json
  • packages/postcss-html-transform/package.json
  • packages/taro-runtime/package.json
  • packages/taro/package.json
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/eslint-config-taro/package.json
  • packages/babel-plugin-transform-solid-jsx/package.json
  • package.json
  • packages/babel-preset-taro/package.json
  • packages/taroize/package.json
  • packages/taro-router-rn/package.json
  • packages/taro-platform-qq/package.json
  • packages/stylelint-taro-rn/package.json
  • packages/taro-plugin-html/package.json
  • packages/taro-runtime/rollup.config.ts
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • 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
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch fix/taro-runtime-compile

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 auto-generate unit tests to generate unit tests for 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 a review from tutuxxx June 16, 2025 06:06
@Single-Dancer Single-Dancer added this to the 4.1.4 milestone Jun 16, 2025
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: 1

🧹 Nitpick comments (2)
packages/taro-runtime/package.json (1)

45-48: rollup-plugin-tslodash 似乎已不再被使用,可移除以避免冗余依赖

新的 Rollup 配置仅使用 @rollup/plugin-typescriptrollup-plugin-dts,代码中已不再引用 rollup-plugin-tslodash。继续保留它们会导致:

  1. 冗余安装时间与体积;
  2. 依赖版本潜在安全风险;
  3. 误导维护者认为仍有使用场景。

建议在后续 commit 中移除:

-    "lodash": "^4.17.21",
-    "rollup-plugin-ts": "^3.4.5",

如确有遗留场景,请在代码中保留引用并补充说明。

packages/taro-runtime/rollup.config.ts (1)

44-48: 建议显式覆盖 tsconfig 中的 declaration 选项

若根目录 tsconfig.json 仍启用了 declaration: true@rollup/plugin-typescript 会优先生效,导致重复生成 .d.ts,与下方 rollup-plugin-dts 冲突。可通过 tsconfigtsconfigOverride 明确关闭:

 ts({
+  tsconfig: './tsconfig.json',
   // 不生成类型定义文件,由 dts 插件负责
-  declaration: false,
+  tsconfigOverride: {
+    compilerOptions: { declaration: false }
+  },
 })

这能彻底避免因全局 tsconfig 配置泄漏造成的重复 / 冲突输出。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f097d5 and c885f46.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • packages/taro-runtime/package.json (1 hunks)
  • packages/taro-runtime/rollup.config.ts (1 hunks)
🔇 Additional comments (1)
packages/taro-runtime/rollup.config.ts (1)

8-28: 输出格式拆分清晰 👍

将多格式输出显式列出,移除 lodash 深合并,结构直观可读,符合 KISS 原则。

Comment on lines 51 to 66
// DTS 配置
const dtsOutput = { ...format }

// 修改输出文件名,将 .js 替换为 .d.ts
if (dtsOutput.file) {
dtsOutput.file = dtsOutput.file.replace(/\.js$/, '.d.ts')
} else if (dtsOutput.entryFileNames) {
dtsOutput.entryFileNames = dtsOutput.entryFileNames.replace(/\.js$/, '.d.ts')
}
return _.mergeWith({}, baseConfig, v, customizer)
}))

configs.push({
input: 'src/index.ts',
output: dtsOutput,
plugins: [dts()],
})
})
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

DTS 配置对每种 format 均执行,可能造成重复写入与竞态

rollup-plugin-dts 针对同一输入多次运行时会:

  • 重复解析同一依赖树,增加构建时间;
  • dist/index.d.ts 等文件产生多次写入,最后一次结果覆盖前者,潜藏竞态风险;
  • preserveModules 场景下可能出现 “文件已存在” 报错。

考虑改为“仅执行一次”生成声明:

-// DTS 配置
-formats.forEach((format) => {
-  ...
-  configs.push({ input: 'src/index.ts', output: dtsOutput, plugins: [dts()] })
-})
+// 仅生成一次统一的声明文件
+configs.push({
+  input: 'src/index.ts',
+  output: { file: 'dist/index.d.ts', format: 'es' },
+  plugins: [dts()],
+})

这样可避免重复工作,构建更稳定。

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// DTS 配置
const dtsOutput = { ...format }
// 修改输出文件名,将 .js 替换为 .d.ts
if (dtsOutput.file) {
dtsOutput.file = dtsOutput.file.replace(/\.js$/, '.d.ts')
} else if (dtsOutput.entryFileNames) {
dtsOutput.entryFileNames = dtsOutput.entryFileNames.replace(/\.js$/, '.d.ts')
}
return _.mergeWith({}, baseConfig, v, customizer)
}))
configs.push({
input: 'src/index.ts',
output: dtsOutput,
plugins: [dts()],
})
})
// 仅生成一次统一的声明文件
configs.push({
input: 'src/index.ts',
output: { file: 'dist/index.d.ts', format: 'es' },
plugins: [dts()],
})
🤖 Prompt for AI Agents
In packages/taro-runtime/rollup.config.ts around lines 51 to 66, the current DTS
configuration runs for each format, causing repeated parsing, multiple writes to
the same declaration files, and potential race conditions. To fix this, modify
the configuration to generate the declaration files only once instead of per
format. This can be done by creating a separate Rollup config dedicated to DTS
output that runs a single time, avoiding duplication and ensuring stable builds.

@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.90%. Comparing base (e9fb351) to head (08558b4).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17848    +/-   ##
========================================
  Coverage   55.90%   55.90%            
========================================
  Files         417      417            
  Lines       21693    21693            
  Branches     5375     5363    -12     
========================================
  Hits        12127    12127            
+ Misses       8055     7935   -120     
- Partials     1511     1631   +120     
Flag Coverage Δ
taro-cli 72.42% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.19% <ø> (ø)

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

see 42 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.

@Single-Dancer Single-Dancer force-pushed the fix/taro-runtime-compile branch from c885f46 to ab989d8 Compare June 16, 2025 06:15
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: 0

♻️ Duplicate comments (1)
packages/taro-runtime/rollup.config.ts (1)

32-66: ⚠️ Potential issue

重复生成 DTS ‑ 仍然存在并发写入与竞态风险

此前已指出(见旧评审)——在 formats.forEach 循环内为每种格式都 push 一份 DTS 配置,会:

  1. 多次解析同一依赖树,拖慢构建;
  2. 对相同路径(如 dist/*.d.ts)进行重复写入,存在竞态;
  3. preserveModules 场景下易触发 “文件已存在” 报错。

问题在本版依旧未解决,建议改为仅生成一次统一的声明输出,例如:

-// 为每种格式创建 JS 和 DTS 配置
-formats.forEach((format) => {
-  ...
-  // DTS 配置
-  configs.push({
-    input: 'src/index.ts',
-    output: dtsOutput,
-    plugins: [dts()],
-  })
-})
+// DTS 配置(只跑一次)
+configs.push({
+  input: 'src/index.ts',
+  output: { file: 'dist/index.d.ts', format: 'es' },
+  plugins: [dts()],
+})
+
+// JS 配置
+formats.forEach((format) => {
+  configs.push({
+    input: 'src/index.ts',
+    output: { ...format, sourcemap: true, exports: 'named' },
+    plugins: [externals(), ts({ declaration: false })],
+  })
+})

这样可避免重复写入并提升稳定性。

🧹 Nitpick comments (2)
packages/taro-runtime/rollup.config.ts (2)

55-59: entryFileNames 字符串替换方式不够稳健

简单的 .replace(/\.js$/, '.d.ts') 对包含 hash、子目录或非 .js 结尾的自定义模板(如 [name]-[hash].mjs)将失效。
可考虑使用 path.parse 进行解析后再拼接,更稳妥:

-import path from 'path'
-
-...
-  dtsOutput.entryFileNames = dtsOutput.entryFileNames.replace(/\.js$/, '.d.ts')
+import path from 'path'
+
+...
+  const parsed = path.parse(dtsOutput.entryFileNames)
+  dtsOutput.entryFileNames = path.join(parsed.dir, `${parsed.name}.d.ts`)

42-48: 未显式指定 tsconfigRootDir,Monorepo 下可能解析错误

@rollup/plugin-typescript 在 Monorepo 中可能向上级目录查找 tsconfig.json,导致编译选项混乱。
建议加上:

 ts({
   declaration: false,
+  tsconfigRootDir: __dirname,
 }),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c885f46 and ab989d8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • packages/taro-runtime/package.json (1 hunks)
  • packages/taro-runtime/rollup.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/taro-runtime/package.json
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin

@coderabbitai coderabbitai bot requested a review from luckyadam June 17, 2025 08:23
@Single-Dancer Single-Dancer force-pushed the fix/taro-runtime-compile branch 3 times, most recently from acc237c to b94ec2e Compare June 17, 2025 09:15
@Single-Dancer Single-Dancer force-pushed the fix/taro-runtime-compile branch from cc27f53 to 08558b4 Compare June 23, 2025 09:01
@Single-Dancer Single-Dancer merged commit 209f84f into main Jun 23, 2025
39 checks passed
@Single-Dancer Single-Dancer deleted the fix/taro-runtime-compile branch June 23, 2025 09:46
This was referenced Jun 28, 2025
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