fix(galacean): remove browser field from package.json#3058
Conversation
WalkthroughPackage manifests now use conditional exports or explicit CDN mappings instead of selected top-level ChangesPackage Entry Contract Updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev/2.0 #3058 +/- ##
===========================================
+ Coverage 79.37% 79.99% +0.61%
===========================================
Files 903 906 +3
Lines 100632 101370 +738
Branches 11260 11600 +340
===========================================
+ Hits 79879 81090 +1211
+ Misses 20569 20097 -472
+ Partials 184 183 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/galacean/package.json (1)
17-24: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winMissing
"./package.json"subpath export.Once
"exports"is defined, only listed subpaths remain accessible — tools that read the dependency's ownpackage.json(bundlers, React Native/Metro,require.resolve('galacean/package.json'), etc.) will fail withERR_PACKAGE_PATH_NOT_EXPORTED. This is a well-known gotcha (see nodejs/node#33460, react-native-community/cli#1168) that has broken several popular packages after adoptingexports.🔧 Suggested addition
"exports": { ".": { "types": "./types/index.d.ts", "import": "./dist/module.js", "browser": "./dist/browser.js", "default": "./dist/main.js" - } + }, + "./package.json": "./package.json" },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/galacean/package.json` around lines 17 - 24, The package exports map in the package.json currently omits the package’s own package.json subpath, which breaks consumers that resolve it directly. Update the exports block in the package manifest to include the "./package.json" subpath alongside the existing "." entry so tools like bundlers, Metro, and require.resolve can access it. Keep the fix localized to the package.json exports definition and preserve the current main/browser/module/type entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/galacean/package.json`:
- Around line 17-24: The package exports map in the galacean package is ordered
incorrectly, causing resolvers that match both conditions to select the import
target before the browser build. Update the object in the exports entry so the
browser condition is listed before import, keeping the types entry unchanged and
preserving the existing default fallback.
---
Nitpick comments:
In `@packages/galacean/package.json`:
- Around line 17-24: The package exports map in the package.json currently omits
the package’s own package.json subpath, which breaks consumers that resolve it
directly. Update the exports block in the package manifest to include the
"./package.json" subpath alongside the existing "." entry so tools like
bundlers, Metro, and require.resolve can access it. Keep the fix localized to
the package.json exports definition and preserve the current
main/browser/module/type entries.
🪄 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: f2285e36-c5e1-4739-9a7c-dfcab3783759
📒 Files selected for processing (3)
packages/galacean/package.jsonpackages/galacean/src/ShaderPool.tspackages/galacean/src/index.ts
|
改好了,不会是还没睡吧 |
|
@cptbtptpbcptdtptp 这个改动我觉得对于使用体验提升很有帮助 |
|
我看看。 |
Hi,麻烦描述一下你具体的使用场景,最好带上一个最简 Demo ,我们可以更快将这个 PR 审核掉。 |
|
https://github.com/luo2430/galacean-project.git @cptbtptpbcptdtptp 我做好了一个示例项目,但目前 |
cptbtptpbcptdtptp
left a comment
There was a problem hiding this comment.
已复核最终 HEAD e4cfc2d9e,无阻塞问题。使用作者提供的 demo 独立复现:发布版 2.0.0-alpha.38 因顶层 browser 入口解析到 UMD,export * 后浏览器报 named export 缺失;临时应用本 PR 的 types / import / default exports map 后,Vite dev 正常加载,Engine 初始化并创建 WebGL canvas。import 指向 ESM module.js,default 保留 CJS fallback,顶层 UMD/CDN 字段未受影响。
|
重新对比了 Three.js、Babylon.js、PlayCanvas、PixiJS、CesiumJS 的发布方式,并用你提供的 Demo 做了进一步验证。结论是:针对当前问题,不需要增加 我在
原因是 Vite 在没有 相比之下,给已有包新增 建议本 PR 收敛为: - "browser": "dist/browser.js",如果后续确实需要引入 |
|
@cptbtptpbcptdtptp 还有需要改的地方吗? |
|
明天会合掉的,需要再讨论一下,合并了会再发个版本。 |
😄 |
GuoLei1990
left a comment
There was a problem hiding this comment.
🫧 尘小沫
总结
这是相对上一份 2026-07-23T13:33:59Z 目标-HEAD review 的 steady-state 增量复核。PR HEAD 仍为 ea3d2687cef7675d50c7ebbbaa2731a9ca3f42e0;期间没有新增 commit、代码 diff、inline comment 或会话更新。最终改动仍是单文件、单 commit,净删 packages/galacean/package.json 顶层 "browser": "dist/browser.js"。无新问题,维持可合入结论。
已关闭问题清单
- [P1]
exports.browser指向 UMD:整套exports方案已撤销;最终 commitea3d2687c只删除顶层browser字段,问题不再适用。 - [P2]
feat与refactor混装:最终标题、commit 与 diff 已收敛为纯fix,已修复。 Object.entries/@ts-expect-error重构:已退出最终 diff,不适用。- CodeRabbit 的
./package.jsonsubpath 与条件调序建议:均依赖已撤销的exports方案;旧 inline thread 已 outdated,不重复提出。
增量与架构治理复核
- 增量事实:GitHub 三点 compare 仍以
721b42a8c为 merge base,PR 相对当前dev/2.0为 ahead 1 / behind 6,唯一 PR 文件变化仍是删除该行;PR 为MERGEABLE / CLEAN。 - 上游生产 owner:
packages/galacean/src/index.ts是入口源;Rollup 的module()读取pkgJson.module/main分别生成 ESMdist/module.js与 CJSdist/main.js;getUMD()只按保留的pkgJson.umd选择包并生成dist/browser(.min).js。构建链不读取被删字段,因此 UMD 产物与发布文件集合不受影响。 - 下游消费 owner:browser bundler 不再被冲突的
browser → UMD映射截流,会机械落到真正的 ESMmodule.js;Node/CJS 仍由main.js负责。unpkg/jsdelivr继续指向dist/bundled.module.min.js。Editor preload 只读取独立browserPath配置,且 first-party 列表不含顶层@galacean/engine。 - 同根因冗余扫描:历史
57515aac build: set galacean global name已把 UMD 构建选择权从pkgJson.browser迁到pkgJson.umd;遗留的顶层browser字段因此成为消费入口上的第二 owner。当前删除方向正确:保留module/main作为模块消费权威、保留umd作为 UMD 生产权威,不新增 wrapper 或同步层。直接链路内没有剩余的平行状态机、可推导持久状态、重复转换/校验或 compat 分支需要随本 PR 继续删除。 - 当前 base 与验证:base 后续 6 个 commit 包含 alpha.38 / alpha.39 发版及其他功能演进;
packages/galacean/package.json只发生版本号更新,没有改变入口协议。目标 HEAD 的 12 项 checks 全部 success,包括三平台 build、4 组 e2e、lint 与 codecov。
问题
无 P0/P1/P2/P3 新问题。当前单行删除仍是必要充分的最小根修。本次按 AutoCR 边界提交 COMMENTED review,等待人工 Reviewer 完成合入门禁。
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/check-package-entry-contracts.js (1)
45-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winValidate the new CDN entrypoints too.
Lines 48-55 only inspect
packageJson.browser, so every newunpkg/jsdelivrvalue bypasses the build-time contract check. Validate that each CDN target matches the allowed browser UMD naming and resolves to an artifact afterb:module; otherwise a typo can ship broken CDN imports while this command passes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/check-package-entry-contracts.js` around lines 45 - 59, Update validateBrowserEntries to also inspect each package’s unpkg and jsdelivr targets alongside packageJson.browser. Apply the allowed UMD naming validation and verify each CDN target resolves to an artifact after b:module, reporting violations through the existing violations collection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@scripts/check-package-entry-contracts.js`:
- Around line 45-59: Update validateBrowserEntries to also inspect each
package’s unpkg and jsdelivr targets alongside packageJson.browser. Apply the
allowed UMD naming validation and verify each CDN target resolves to an artifact
after b:module, reporting violations through the existing violations collection.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fb634406-1bbb-49e9-82e0-0bcfad3daf84
📒 Files selected for processing (10)
package.jsonpackages/math/package.jsonpackages/physics-physx/package.jsonpackages/shader-compiler/package.jsonpackages/shader-compiler/verbose/package.jsonpackages/shader/package.jsonpackages/ui/package.jsonpackages/xr-webxr/package.jsonpackages/xr/package.jsonscripts/check-package-entry-contracts.js
💤 Files with no reviewable changes (1)
- packages/math/package.json
|
已合并,并随 v2.0.0-alpha.41 发布了,感谢贡献!🎉 |
🤭 |
主要用于适配在一个utils包中包装部分功能并且
export * from "@galacean/engine";以方便其它库使用的情况。Summary by CodeRabbit
New Features
Bug Fixes
Tests