Skip to content

fix: expose clearAssetsCache on framework wrappers - #1113

Merged
yiludege merged 2 commits into
Tencent:masterfrom
dvd233:codex/wrapper-clear-assets-cache
Nov 13, 2026
Merged

yiludege merged 2 commits into
Tencent:masterfrom
dvd233:codex/wrapper-clear-assets-cache

Conversation

@dvd233

@dvd233 dvd233 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor
Checklist
  • 提交符合 commit 规范
  • 添加真实封装与 core 缓存的回归测试
  • 单元、集成测试与四包构建通过(Windows 执行方式见下文)
详细描述

文档要求从 wujie-vue2 / wujie-vue3 / wujie-react 默认导出上解构 clearAssetsCache,但三个封装目前都没有暴露该方法,调用会报 clearAssetsCache is not a function。

此改动直接透传已有 core API,并用 typeof clearAssetsCache 补齐三个封装的声明。保持无参数、单 URL 前缀及多个 URL 前缀的原有行为,不修改缓存实现。

Related to #1107:仅处理其中的 clearAssetsCache 问题,不声称解决 refreshApp 部分。

新增 12 项回归使用真实封装和真实 core,验证导出函数、三类缓存清理及无关缓存保留。Jest 配置增加 JS/Babel 接入,显式声明 babel-jest 开发依赖;锁文件由 pnpm 10.33.0 生成,无包版本升级,含现有 peer 上下文去重及元数据更新。

验证
  • 新增回归修复前 12 项失败;修复后完整 unit:21 suites / 106 tests passed。
  • 完整 Puppeteer integration:14 suites / 97 tests passed,8 个真实示例服务,使用 Puppeteer 14.4.1 对应 Chromium r1002410。
  • pnpm exec lerna run prepack --concurrency 1:四包通过;重建后的 lib/ESM API 调用通过,ESM 实际缓存行为通过。
  • TypeScript 4.9.5 消费者检查:三封装正例通过,非法 number 和混合数组参数得到与 core 一致的诊断。

Windows 验证使用原 Jest 配置及完整测试集合,以 --testMatch '**/unit/*.test.ts' / --testMatch '**/integration/*.test.ts' 适配本地路径,并逐一比对测试文件清单。集成使用 checkout 外的 Puppeteer 配置指定 D 盘浏览器,将端口冲突设为报错并将服务启动等待改为 180 秒;测试断言和 30 秒用例超时均未修改。未声称直接执行原 POSIX npm run test 命令。

@yiludege yiludege left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

三个框架封装补上 clearAssetsCache 导出,与文档用法一致。最终结论见后续 review。

@yiludege yiludege mentioned this pull request Nov 13, 2026
@yiludege
yiludege dismissed their stale review November 13, 2026 09:08

PR 已收窄为仅封装导出改动,改为通过。

@yiludege yiludege left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

docs/pack/index.md、docs/pack/react.md 写的是从封装组件上解构 clearAssetsCache,但 wujie-vue2 / wujie-vue3 / wujie-react 没有导出它,照文档调用会得到 undefined。三个封装补上透传即可修复。

为保持改动最小,维护者追加了一个提交,移除了回归测试、babel-jest 依赖和 Jest preset 的调整。PR 现在只改三个封装的 index.js / index.d.ts,共 6 个文件。

在最新 master 上验证:

  • 用仓库原有锁文件 --frozen-lockfile 安装,core 与三个封装的 lib / esm 构建通过。
  • 把三个封装的 esm 产物与 core 一起打包后运行:封装上的 clearAssetsCache 与 core 导出是同一个函数;按单个前缀、前缀数组清理时只清掉匹配条目,不传参时三类缓存全部清空;bus、setupApp、preloadApp、destroyApp、refreshApp 不受影响。
  • 类型:按文档写法解构调用,三个封装均通过 tsc --strict,传入非法参数会报错。

感谢 @dvd233 的修复和完整的验证说明。

@yiludege
yiludege merged commit 395f364 into Tencent:master Nov 13, 2026
3 checks passed
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