Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial flag does not take into account lazy loading #400

Open
skovhus opened this issue Dec 17, 2024 · 3 comments · May be fixed by #403
Open

Initial flag does not take into account lazy loading #400

skovhus opened this issue Dec 17, 2024 · 3 comments · May be fixed by #403
Assignees
Labels
bug Something isn't working

Comments

@skovhus
Copy link

skovhus commented Dec 17, 2024

Currently the plugin detects if a chunk is initial based on the [isDynamicEntry information from rollup](https://github.com/relative-ci/rollup-plugin-webpack-stats/blob/master/src/transform.ts#L140). This is a pretty broken heuristic as a chunk might be synchronously imported by a chunk that is dynamic.

Example

A (initial) lazy loads B that synchronously loads C.

Expected: C should not be marked initial
Currently: C is marked as initial

@vio vio added the bug Something isn't working label Dec 18, 2024
@vio vio self-assigned this Dec 18, 2024
@vio
Copy link
Member

vio commented Dec 18, 2024

@skovhus thanks for checking and for opening the issue!

rollup doesn't provide the initial field and atm we are only using the chunk isDynamicEntry property. We will need to build the chunks dependency tree to detect the async status for a 2nd level chunk. Rollup provides data that can allow us to build the tree, we will have a look in the following days.

In the meantime, if you need to fix the data for specific chunks, you can use the transform option: https://github.com/relative-ci/rollup-plugin-webpack-stats?tab=readme-ov-file#vitejs---update-initial-flag-for-chunks-where-the-inital-flag-is-incorrectly-set-to-false

@skovhus
Copy link
Author

skovhus commented Dec 18, 2024

Yeah we are already using the transform to traverse our tree of dependencies and correct all initial flags. Great that you added lower level Rollup sources to that function.

@vio vio linked a pull request Dec 23, 2024 that will close this issue
@vio
Copy link
Member

vio commented Dec 23, 2024

@skovhus, we are testing a fix on rollup-plugin-bundle-stats@1.2.4-beta.6. The initial flag is now looked up based on the issuer chunks, so if a chunk is synchronously loaded by an async chunk, it is flagged as not initial.

Let me know how it goes if you get the chance to try it. If you notice any issues, it would be very helpful if you could share the rollup stats JSON file(rollup-plugin-stats - no sources by default, you can send it as an attachment to the email address listed on my profile).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants