Skip to content

feat(rspack-runner): add @tarojs/rspack-runner for H5 and mini-program builds - #1

Closed
Amour1688 wants to merge 4 commits into
refactor/runner-shared-bundlerfrom
feat/rspack-runner
Closed

Amour1688 wants to merge 4 commits into
refactor/runner-shared-bundlerfrom
feat/rspack-runner

Conversation

@Amour1688

@Amour1688 Amour1688 commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

本 PR 仅用于在 fork 仓中查看相对 refactor/runner-shared-bundler(NervJS#19696)的纯增量 diff,对应上游 PR:NervJS#19694。

增量统计(基于 @rspack/core@2.3.4)

  • 总计 65 个文件(+6,350 / -921 行);不含 pnpm-lock.yaml 为 64 个文件(+5,533 / -692 行)
  • packages/taro-rspack-runner/src/:10 个核心文件、1,070 行源码(较初版 1,741 行精简 -38.5%,仅保留 Rspack 2.3.4 底层不兼容的薄适配)
  • packages/taro-rspack-runner/tests/:4 个测试文件、2,884 行测试(34/34 Vitest 全绿),覆盖:
    • React / Vue 3 SFC 零 mock 全链路 CLI + 模拟 wx VM、多端小程序(Weapp / TT / Alipay / Swan / QQ / JD)、TabBar / 混合原生、多端文件解析、independent: true 独立分包、SubPackageIndiePlugin(newBlended: true)
    • BuildNativePlugin(isBuildNativeComp: true)、小程序原生插件(isBuildPlugin: true)、Prerender、Skyline 模式、modifyBuildAssets/addChunkPages 钩子与 StaticMiniSplitChunksPlugin 重建隔离
    • 编译宏(defineAppConfig / definePageConfig)、CustomWrapper 与第三方原生组件 props、按需 moduleGraph.getUsedExports(兼容 Rspack inlineExports)、TS 仅类型重导出(reexportExportsPresence: false)、copy/字符串与 RegExp alias/defineConstants/Less/Stylus/CSS Modules global 模式、SWC + css-minimizer-webpack-plugin .wxss 压缩
  • packages/taro-runner-utils/:24 个文件(+1,274 / -73 行)— 沉淀共享组件 AST 收集器、真实小程序模板、StaticMiniSplitChunksPlugin、独立分包与 BuildNativePlugin 基类、Chunk/Prerender 兼容修复与配置/Runner 默认值
  • packages/taro-webpack5-runner/:8 个文件(+101 / -608 行,净删 -507 行,根仓库 22/22 Jest 套件、153/153 用例、97/97 快照全绿)
  • 核心包与 CI 接入改动:11 个文件(+48 / -11 行)
  • 已知边界:AsyncSubPackagePlugin 当前仍仅支持 webpack5(Rspack 2.3.4 暂不支持 optimizeChunks、可变 chunk.name、run 阶段动态修改 splitChunks 及 afterResolve createData.loaders)。

@Single-Dancer
Single-Dancer force-pushed the refactor/runner-shared-bundler branch from 7a54de6 to 24804f5 Compare November 28, 2026 13:50
@Amour1688
Amour1688 force-pushed the feat/rspack-runner branch 2 times, most recently from caef36f to 7225680 Compare November 28, 2026 14:39
Amour1688 and others added 4 commits November 28, 2026 22:58
…ils (NervJS#19696)

* refactor(runner): extract shared bundler layer into @tarojs/runner-utils

* refactor(runner): preserve MiniSplitChunksPlugin hooks and declare tapable in tests
* fix(components): report elapsed audio playback time

* test(components): provide audio event source in Stencil mock
* feat(h5): support hideHomeButton on H5

Taro.hideHomeButton was a temporarilyNotSupport stub on H5, although the
H5 navigation bar rendered by @tarojs/router shows a "back to home" button
when a page other than the home page is opened as the only page, just
like mini programs do. Pages could therefore not hide that button.

- @tarojs/router: add hideNavigationBarHomeButton, which triggers the
  __taroH5HideHomeButton event like the other navigation bar helpers.
  NavigationBarHandler records the hidden state in its per-page cache and
  setFnBtnState shows no button instead of the home button for that page.
  The cache entry is created on demand, because pages usually call the
  API in onShow, which runs before the navigation bar is loaded for the
  page, so the following load() does not show the button again. The back
  button and other pages are not affected.
- @tarojs/taro-h5: implement hideHomeButton on top of the router helper.
- types: mark hideHomeButton as supported on h5.

Add router unit tests for hiding the button, hiding it before the page
is loaded, keeping the back button and scoping the state to the page,
and an H5 test for the API callbacks and the triggered event.

* test(router): cover hidden home button after navigating away and back

Also document that the hidden state is cached per route.

* fix(router): scope hideHomeButton to the page instance on H5

* fix(router): ignore hideHomeButton calls made while a page is unloading

A page is popped from the stack before its onUnload runs, so a
hideHomeButton call from onUnload landed on the destination page.
Skip the call while unloading, and make the navigate-back test only
hide the button on the first onShow.

* fix(router): ignore deferred hideHomeButton calls from a popped page

Keep ignoring hideHomeButton until the macrotask after onUnload, so calls
deferred through a microtask can no longer hide the destination page's
home button. onShow of the page shown right after an unload is exempt.

Co-authored-by: dhananjay6561 <133662894+dhananjay6561@users.noreply.github.com>
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>

* fix(router): attribute hideHomeButton calls to the page that made them

Compare Current.page with the stack top instead of ignoring every call
for a macrotask after onUnload. A popped page's call deferred by a
microtask now runs while Current.page still points at it, and the
shown page's own onShow call is no longer rejected. Tests use the real
createPageConfig, with and without animation.

* docs(types): note onShow usage and delayed-call scope for H5 hideHomeButton

---------

Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Co-authored-by: dhananjay6561 <133662894+dhananjay6561@users.noreply.github.com>
@Amour1688

Copy link
Copy Markdown
Owner Author

Closing preview PR: prerequisite NervJS#19696 is merged and NervJS#19694 is now rebased directly onto upstream/main.

@Amour1688 Amour1688 closed this Nov 29, 2026
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.

3 participants