feat: support compile main-thread script to bytecode in external bundle#2459
feat: support compile main-thread script to bytecode in external bundle#2459
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
🦋 Changeset detectedLatest commit: 5ce3b26 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdded support for compiling main-thread scripts to bytecode in external bundles: introduced a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
❌ 10 Tests Failed:
View the full list of 10 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.ts`:
- Around line 138-142: The check in ExternalBundleWebpackPlugin that uses
this.options.mainThreadChunks?.includes(cur.name) compares against the emitted
asset filename (cur.name) which can include hashes/dirs; change it to compare
normalized chunk/section identity: derive a stable name (e.g., use
cur.chunk?.name or extract a basename/normalized section name from cur.name) and
compare that against a normalized version of this.options.mainThreadChunks (map
the configured names through the same normalization). Update the condition to
use the normalizedChunkName (instead of cur.name) so the JsBytecode branch is
chosen by chunk identity, not the raw emitted filename.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4c307d79-ebf4-4bb5-932b-8792c7227ca4
📒 Files selected for processing (5)
.changeset/flat-bikes-boil.mdpackages/rspeedy/lynx-bundle-rslib-config/etc/lynx-bundle-rslib-config.api.mdpackages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.tspackages/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.tspackages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts
| ...(this.options.mainThreadChunks?.includes(cur.name) | ||
| ? { | ||
| 'encoding': 'JsBytecode', | ||
| } | ||
| : {}), |
There was a problem hiding this comment.
Match main-thread assets by chunk identity, not exact emitted filename.
mainThreadChunks?.includes(cur.name) only works when the emitted asset name is exactly the stored value. As soon as a caller uses a subdirectory or hash in the JS filename template, this branch stops tagging the main-thread section as JsBytecode and silently falls back to plain JS. Compare against a normalized section/chunk name instead of the raw emitted filename.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@packages/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.ts`
around lines 138 - 142, The check in ExternalBundleWebpackPlugin that uses
this.options.mainThreadChunks?.includes(cur.name) compares against the emitted
asset filename (cur.name) which can include hashes/dirs; change it to compare
normalized chunk/section identity: derive a stable name (e.g., use
cur.chunk?.name or extract a basename/normalized section name from cur.name) and
compare that against a normalized version of this.options.mainThreadChunks (map
the configured names through the same normalization). Update the condition to
use the normalizedChunkName (instead of cur.name) so the JsBytecode branch is
chosen by chunk identity, not the raw emitted filename.
Merging this PR will improve performance by 11.24%
Performance Changes
Comparing Footnotes
|
React Example#7383 Bundle Size — 223.33KiB (0%).5ce3b26(current) vs 95c2dc3 main#7382(baseline) Bundle metrics
|
| Current #7383 |
Baseline #7382 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
179 |
179 |
|
69 |
69 |
|
44.48% |
44.48% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #7383 |
Baseline #7382 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
77.58KiB |
77.58KiB |
Bundle analysis report Branch feat/external-bundle-mts-bytecod... Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#8957 Bundle Size — 749.55KiB (0%).5ce3b26(current) vs 95c2dc3 main#8956(baseline) Bundle metrics
Bundle size by type
|
| Current #8957 |
Baseline #8956 |
|
|---|---|---|
401.63KiB |
401.63KiB |
|
345.76KiB |
345.76KiB |
|
2.16KiB |
2.16KiB |
Bundle analysis report Branch feat/external-bundle-mts-bytecod... Project dashboard
Generated by RelativeCI Documentation Report issue
React External#500 Bundle Size — 670.93KiB (+15.61%).5ce3b26(current) vs 95c2dc3 main#499(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch feat/external-bundle-mts-bytecod... Project dashboard Generated by RelativeCI Documentation Report issue |
React MTF Example#516 Bundle Size — 193.94KiB (0%).5ce3b26(current) vs 95c2dc3 main#515(baseline) Bundle metrics
|
| Current #516 |
Baseline #515 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
173 |
173 |
|
66 |
66 |
|
43.94% |
43.94% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #516 |
Baseline #515 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
82.71KiB |
82.71KiB |
Bundle analysis report Branch feat/external-bundle-mts-bytecod... Project dashboard
Generated by RelativeCI Documentation Report issue
Summary by CodeRabbit
New Features
Tests
Checklist