-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add constants inlining optimization #9241
Conversation
Co-authored-by: gorakong <[email protected]> Co-authored-by: celinanperalta <[email protected]>
@@ -101,6 +101,9 @@ const CONFIG_SCHEMA: SchemaEntity = { | |||
}, | |||
], | |||
}, | |||
unstable_inlineConstants: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need the unstable
prefix here. Should I remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on how confident we are in the implementation, or do we want to test it in Jira first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already tested Jira locally. I think let's keep it as unstable for now as it gives us the most flexibility.
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached Bundles
React HackerNews ✅
Timings
Cold Bundles
Cached Bundles
AtlasKit Editor ✅
Timings
Cold Bundles
Cached Bundles
Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached Bundles
|
↪️ Pull Request
This PR adds a new optimization that inlines modules that only expose constant literals.
e..g.
The idea here is that in almost all cases it's better to inline (not wrap) these modules in all their uses and allow the optimizer to decide how to best handle their usage. This allows skipping the parcel requires and named symbols when accessing constants in most cases. Duplicating constants in a single bundle is not a big issue as compression will optimize for the repeat usage.
Using this feature, very large strings can possibly be duplicated across multiple bundles which may be unideal, potentially we could add a limit in future if a constant was too large to optimize in this way.
We've added a feature switch to the js transformer to enable this feature, currently named
unstable_inlineConstants
. Not sure we need theunstable
prefix here as it's disabled by default, if we agree I can remove it.🚨 Test instructions
✔️ PR Todo