Skip to content

feat: 添加broswer-vendors配置和相关依赖导出#352

Merged
YufJi merged 4 commits into
testfrom
feature/broswer-vendors
May 13, 2026
Merged

feat: 添加broswer-vendors配置和相关依赖导出#352
YufJi merged 4 commits into
testfrom
feature/broswer-vendors

Conversation

@YufJi
Copy link
Copy Markdown
Collaborator

@YufJi YufJi commented Mar 27, 2026

Summary by CodeRabbit

  • 新功能

    • 新增共享库供应商构建,支持 PC 与移动两个独立输出
    • 将核心依赖(Vue、路由、状态管理、国际化、SFC 编译器、Lodash)暴露为浏览器全局对象
  • 优化

    • 构建配置整合以同时产出基础包与供应商包
    • 调整了库比较/导入方式以简化内部逻辑

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 028b5292-6cc7-41e6-825b-8a782568a7d8

📥 Commits

Reviewing files that changed from the base of the PR and between 5661031 and 9a746bf.

📒 Files selected for processing (2)
  • packages/vue3/build/broswer-vendors.js
  • packages/vue3/src/broswer-vendors.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/vue3/src/broswer-vendors.ts
  • packages/vue3/build/broswer-vendors.js

Walkthrough

新增浏览器供应商构建配置与对应源文件,将核心依赖(Vue、Vue Router、Pinia、Vue I18n、SFC 编译器、Lodash)挂载为 window 全局变量,并在主 Rspack 配置中新增 pc 与 mobile 的 vendor 构建;同时调整 lodash 的导入为具名导入。

Changes

Cohort / File(s) Summary
浏览器供应商构建脚本
packages/vue3/build/broswer-vendors.js
新增 vendorConfig(type),返回用于生产构建的 @rspack/cli 配置(entry 指向 ../src/broswer-vendors.ts,UMD 输出 LcapBrowserVendors,输出到 dist/${type}/broswer-vendors.js,启用 SWC loader 与 browser targets)。
浏览器供应商源文件
packages/vue3/src/broswer-vendors.ts
新增模块:导入 Vue、Vue Router、Pinia、Vue I18n、SFC 编译器与 Lodash,扩展 Window 类型并将这些库赋给 window.* 全局变量。
主构建配置
packages/vue3/build/rspack.config.js
导入并加入 vendorConfig('pc')vendorConfig('mobile') 到导出的配置数组,扩展构建目标列表。
导入方式调整
packages/vue3/source/src/hooks/datasource-utils.js
将 lodash 的默认导入改为具名导入 isEqual,比较逻辑保持不变。

Sequence Diagram(s)

sequenceDiagram
    participant RspackConfig as RspackConfig
    participant VendorBuild as vendorConfig()
    participant EntryFile as broswer-vendors.ts
    participant SWCLoader as SWC Loader
    participant FS as Filesystem (dist/${type})

    RspackConfig->>VendorBuild: import vendorConfig(type)
    VendorBuild->>EntryFile: set entry -> ../src/broswer-vendors.ts
    VendorBuild->>SWCLoader: apply SWC rules for .ts/.js
    EntryFile->>SWCLoader: transpile imports (Vue, Pinia, ...)
    SWCLoader->>VendorBuild: bundled UMD module (LcapBrowserVendors)
    VendorBuild->>FS: write broswer-vendors.js to dist/${type}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • buke-dev

兔子之诗

🐰 我在仓库里轻轻跳,
打包依赖成环球桥,
Vue 与 Pinia 手牵手,
pc 与 mobile 一起笑,
全局变量亮起新灯苗 ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更内容,即添加browser-vendors配置模块和相关依赖的全局导出。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/broswer-vendors

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@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: 3

🧹 Nitpick comments (2)
packages/vue3/src/broswer-vendors.ts (1)

1-1: 文件名拼写错误:"broswer" 应为 "browser"

所有相关文件名中 "broswer" 都拼写错误,建议统一修正为 "browser-vendors"。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue3/src/broswer-vendors.ts` at line 1, The file name
packages/vue3/src/broswer-vendors.ts is misspelled; rename it to
browser-vendors.ts and update every import/export that references
"broswer-vendors" to the corrected "browser-vendors" (search for that exact
identifier in imports, barrel/index files, build configs, and tests). Ensure any
module aliases or tsconfig/webpack/rollup entries that reference the old
filename are updated, and run the type checker/build to catch remaining path
errors.
packages/vue3/build/broswer-vendors.js (1)

29-44: JS loader 缺少 env.targets 配置

TypeScript loader(Lines 45-60)配置了 env: { targets } 以确保正确的浏览器兼容性转译,但 JavaScript loader 缺少相同配置。这可能导致依赖包中的 ES6+ 代码在目标浏览器中出现兼容性问题。

♻️ 建议为 JS loader 添加 env.targets
         {
           test: /\.[mc]?js$/,
           type: 'javascript/auto',
           use: [
             {
               loader: 'builtin:swc-loader',
               options: {
                 jsc: {
                   parser: {
                     syntax: 'ecmascript',
                   },
                 },
+                env: { targets },
               },
             },
           ],
         },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue3/build/broswer-vendors.js` around lines 29 - 44, The JS loader
block (the rule with test: /\.[mc]?js$/ using loader 'builtin:swc-loader' and
options.jsc.parser.syntax = 'ecmascript') is missing the same env.targets
compatibility configuration used by the TypeScript loader; add an env: { targets
} entry inside the swc-loader options (alongside options.jsc) mirroring the
targets used in the TypeScript loader so that dependency JS is transpiled to the
same browser targets and avoids ES6+ compatibility issues.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/vue3/build/broswer-vendors.js`:
- Around line 20-25: 配置中的 library.export: 'default' 与源文件 broswer-vendors.ts
不匹配(源文件无默认导出),导致全局变量 LcapBrowserVendors 为 undefined;修复可选两种方式:如果该包只依赖副作用(只需设置
window.* 全局变量),则在打包配置的 library 对象中移除 export 属性;如果需要暴露模块 API,则在源码
broswer-vendors.ts 中添加默认导出(export default ...)以匹配 library.export:
'default',并确保导出的值赋给期望的全局标识 LcapBrowserVendors。

In `@packages/vue3/source/src/hooks/datasource-utils.js`:
- Line 1: 当前在 packages/vue3/source/src/hooks/datasource-utils.js 中用的是主入口导入
import { isEqual } from 'lodash',这会导致 rspack 打包时无法 tree-shake
且增大产物体积;请将导入改为子路径导入以减小打包体积,例如把对 isEqual 的引用改为从 'lodash/isEqual' 导入(定位到使用 isEqual
的模块或函数并替换导入语句),确保其他地方没有再用主入口方式引用 lodash。

In `@packages/vue3/src/broswer-vendors.ts`:
- Around line 1-13: The module currently attaches libs to window (window.Vue,
window.VueRouter, window.Pinia, window.VueI18n, window.VueCompilerSFC,
window.Lodash) but does not provide a default export required by the UMD build;
add a default export (e.g. export default { Vue, VueRouter, Pinia, VueI18n,
VueCompilerSFC, Lodash } or export default LcapBrowserVendors) so the bundle can
expose the global correctly, and add TypeScript declarations for the window
properties (declare global { interface Window { Vue: typeof Vue; VueRouter:
typeof VueRouter; Pinia: typeof Pinia; VueI18n: typeof VueI18n; VueCompilerSFC:
typeof VueCompilerSFC; Lodash: typeof lodash } }) to avoid compile errors.

---

Nitpick comments:
In `@packages/vue3/build/broswer-vendors.js`:
- Around line 29-44: The JS loader block (the rule with test: /\.[mc]?js$/ using
loader 'builtin:swc-loader' and options.jsc.parser.syntax = 'ecmascript') is
missing the same env.targets compatibility configuration used by the TypeScript
loader; add an env: { targets } entry inside the swc-loader options (alongside
options.jsc) mirroring the targets used in the TypeScript loader so that
dependency JS is transpiled to the same browser targets and avoids ES6+
compatibility issues.

In `@packages/vue3/src/broswer-vendors.ts`:
- Line 1: The file name packages/vue3/src/broswer-vendors.ts is misspelled;
rename it to browser-vendors.ts and update every import/export that references
"broswer-vendors" to the corrected "browser-vendors" (search for that exact
identifier in imports, barrel/index files, build configs, and tests). Ensure any
module aliases or tsconfig/webpack/rollup entries that reference the old
filename are updated, and run the type checker/build to catch remaining path
errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e33712a7-283a-43e9-8641-28e8f8d18d78

📥 Commits

Reviewing files that changed from the base of the PR and between 89f62fd and 5661031.

📒 Files selected for processing (4)
  • packages/vue3/build/broswer-vendors.js
  • packages/vue3/build/rspack.config.js
  • packages/vue3/source/src/hooks/datasource-utils.js
  • packages/vue3/src/broswer-vendors.ts

Comment thread packages/vue3/build/broswer-vendors.js
Comment thread packages/vue3/source/src/hooks/datasource-utils.js
Comment thread packages/vue3/src/broswer-vendors.ts
@YufJi YufJi merged commit 5e30138 into test May 13, 2026
2 checks passed
@YufJi YufJi deleted the feature/broswer-vendors branch May 13, 2026 12:09
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.

1 participant