fix(build): externalize @galacean peers in miniprogram build instead of bundling#351
Conversation
…of bundling The miniprogram bundle of @galacean/engine-toolkit-xr shipped a ~2.5MB dist/miniprogram.js (vs ~80KB) because @galacean/engine-xr and its @galacean/engine-math dependency were bundled inline instead of kept external. Two issues caused it: - The external list only contained the `<pkg>/dist/miniprogram` variants, so any peer import that was not redirected there fell through to bundling. - The redirect regex hard-coded mismatched quotes (`"@galacean/engine"` vs `'@galacean/engine-xr'`). The transpiled source uses double quotes, so the `@galacean/engine-xr` import was never redirected and got bundled, dragging @galacean/engine-math along with it. Externalize every peer/dep at both its package name and `/dist/miniprogram`, and redirect only @galacean/engine (the sole package that actually ships a miniprogram build). @galacean/engine-xr now stays external at `@galacean/engine-xr`, which is a path that exists, rather than being bundled or redirected to a missing entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit 095ea5b)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughTwo Rollup build files are updated to fix miniprogram CJS output. ChangesMiniprogram CJS externalization and specifier redirect fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Fixes #349 on the
dev/2.0(2.0) line. Counterpart of #350 (which targetsmain/1.x).dev/2.0carries the identical miniprogram build defect, so the same fix is cherry-picked here: externalize each peer/dep at both its package name and/dist/miniprogram, and redirect only@galacean/engine(quote-agnostic).@galacean/engine-xrthen stays external asrequire('@galacean/engine-xr')instead of being bundled (which inlined ~2MB of engine-xr + engine-math intodist/miniprogram.js).See #349 / #350 for the full root-cause analysis and the rollup + rollup-plugin-modify verification.
🤖 Generated with Claude Code
Summary by CodeRabbit