Skip to content

fix(rspeedy): duplicate chunks in chunkSplit with multiple entries#502

Closed
gaoachao wants to merge 11 commits intomainfrom
fix/chunk-split-multiple-entries
Closed

fix(rspeedy): duplicate chunks in chunkSplit with multiple entries#502
gaoachao wants to merge 11 commits intomainfrom
fix/chunk-split-multiple-entries

Conversation

@gaoachao
Copy link
Copy Markdown
Collaborator

@gaoachao gaoachao commented Apr 7, 2025

Summary

Fixed an issue in rspeedy where chunks weren't being properly shared between multiple entries during chunk splitting. This resulted in duplicate chunks being generated, increasing bundle size and reducing performance.

Caution

BREAKING CHANGE: encodeData.manifest now only contains the /app-service.js entry.

TODO

Add support for synchronous chunk loading.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2025

🦋 Changeset detected

Latest commit: 0ba51a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@lynx-js/template-webpack-plugin Minor
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/react-alias-rsbuild-plugin Patch

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

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 61.53846% with 5 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ck/template-webpack-plugin/src/LynxEncodePlugin.ts 61.53% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 7, 2025

CodSpeed Performance Report

Merging #502 will not alter performance

Comparing fix/chunk-split-multiple-entries (0ba51a1) with main (2f1871b)

Summary

✅ 9 untouched benchmarks

@gaoachao gaoachao marked this pull request as ready for review April 12, 2025 06:26
@gaoachao gaoachao requested a review from colinaaa as a code owner April 12, 2025 06:26
@gaoachao gaoachao requested review from Yradex, hzy and upupming April 12, 2025 06:26
@gaoachao gaoachao requested a review from upupming April 14, 2025 07:47
@gaoachao gaoachao requested a review from colinaaa April 16, 2025 08:58
.join(','),
this.#appServiceFooter(),
].join(''),
...(Object.fromEntries(
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.

directly removing all the manifest would be a huge breaking change (and I don't think we are ready for that).

So maybe add an option like output.inlineScripts?

this.#appServiceBanner(),
Object.keys(manifest)
.map((name) =>
`module.exports=lynx.requireModule('${
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.

Consider using lynx.requireModuleAsync when dealing with multiple chunks, as it allows scripts to load in parallel.

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.

Maybe this could be done in future PRs. Using a new option like scriptLoading

this.#appServiceBanner(),
Object.keys(manifest)
.map((name) =>
`module.exports=lynx.requireModule('${
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.

nitpick: can we avoid the multiple module.exports?

@gaoachao gaoachao force-pushed the fix/chunk-split-multiple-entries branch 2 times, most recently from 85c9dcd to 0494a43 Compare April 27, 2025 08:58
@gaoachao gaoachao force-pushed the fix/chunk-split-multiple-entries branch from 6a23eba to 0ba51a1 Compare May 20, 2025 10:30
@gaoachao
Copy link
Copy Markdown
Collaborator Author

see #874

@gaoachao gaoachao closed this May 21, 2025
github-merge-queue bot pushed a commit that referenced this pull request May 21, 2025
<!--
  Thank you for submitting a pull request!

We appreciate the time and effort you have invested in making these
changes. Please ensure that you provide enough information to allow
others to review your pull request.

Upon submission, your pull request will be automatically assigned with
reviewers.

If you want to learn more about contributing to this project, please
visit:
https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md.
-->

## Summary

<!-- Can you explain the reasoning behind implementing this change? What
problem or issue does this pull request resolve? -->

<!-- It would be helpful if you could provide any relevant context, such
as GitHub issues or related discussions. -->

#870  

follow up #502

Support `output.inlineScripts`, which controls whether to inline scripts
files when LynxEncodePlugin generates the manifest file.

## Checklist

<!--- Check and mark with an "x" -->

- [x] Tests updated (or not required).
- [x] Documentation updated (or not required).

---------

Signed-off-by: BitterGourd <91231822+gaoachao@users.noreply.github.com>
Co-authored-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
@colinaaa colinaaa deleted the fix/chunk-split-multiple-entries branch June 5, 2025 17:26
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.

3 participants