Repository navigation
Conversation
Production bundles are built from a virtual project without the packages' package.json files, so Rolldown could not see sideEffects and kept every module that runs code at the top level, such as icons wrapped in forwardRef. Write a minimal package.json carrying sideEffects at each bundled package's root.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Production bundles are built from a virtual project (
OXC.bundle/2writes the compiled modules into a temp directory) in which a package's files sit under the package name, but the package's ownpackage.jsonis not written. Rolldown readssideEffectsfrom the nearestpackage.json, so it could not see it and kept every unused module that runs code at the top level.The effect is large for icon libraries: each icon in
iconoir-reactandlucide-reactis a module likeexport default forwardRef(Icon), so importing ~100 icons kept all ~3,500 of them. In our app that was ~2.7 MB of a 6.9 MB minified bundle.This writes a minimal
package.jsonholding onlysideEffectsat the root of each bundled package that declares it, for every bundling path (single entry, shared entries, code-split chunks). Packages that don't declaresideEffectsare unchanged.Test:
drops unused modules of packages declaring no side effectsinresolution_test.exsbuilds two packages whose modules call an imported function at the top level; the unused module of thesideEffects: falsepackage is dropped, while thesideEffects: truepackage keeps it. It fails without the change.Locally
mix testpasses exceptCaseBrowserTest(no Playwright here) and oneBundleTestcase that fails with{:not_found, "lit-html"}only in the full run and passes on its own.