-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Avoid dynamic dispatch for scheduler calls #14968
Conversation
479f8fb
to
eee88e3
Compare
ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1% Details of bundled changes.Comparing: 00748c5...eee88e3 react-dom
react-art
react-native-renderer
react-test-renderer
react-reconciler
Generated by 🚫 dangerJS |
Why did the size go up? |
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.
Nice catch
We should track this for when we switch to ES modules though. This is a semantic bug since it passes the |
Looks like it only did for UMDs — because they already didn't suffer from this indirection. (They didn't do So in UMD the change ended up adding a few lines of junk: diff --git a/a.js b/a.js
index b714163..e4dda72 100644
--- a/a.js
+++ b/a.js
@@ -1009,7 +1009,7 @@
c = c.focusOffset;
try {
b.nodeType, e.nodeType;
- } catch (aj) {
+ } catch (lj) {
b = null;
break a;
}
@@ -5891,7 +5891,19 @@
SelectEventPlugin: Zi,
BeforeInputEventPlugin: Ki
});
- var Xc = void 0,
+ var R = da.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler,
+ $i = R.unstable_cancelCallback,
+ aj = R.unstable_now,
+ bj = R.unstable_scheduleCallback,
+ cj = R.unstable_shouldYield,
+ dj = R.unstable_runWithPriority,
+ ej = R.unstable_getCurrentPriorityLevel,
+ fj = R.unstable_ImmediatePriority,
+ gj = R.unstable_UserBlockingPriority,
+ hj = R.unstable_NormalPriority,
+ ij = R.unstable_LowPriority,
+ jj = R.unstable_IdlePriority,
+ Xc = void 0,
Nf = (function(a) {
return "undefined" !== typeof MSApp && MSApp.execUnsafeLocalFunction
? function(b, c, d, e) {
@@ -5964,9 +5976,9 @@
strokeOpacity: !0,
strokeWidth: !0
},
- $i = ["Webkit", "ms", "Moz", "O"];
+ kj = ["Webkit", "ms", "Moz", "O"];
Object.keys(yb).forEach(function(a) {
- $i.forEach(function(b) {
+ kj.forEach(function(b) {
b = b + a.charAt(0).toUpperCase() + a.substring(1);
yb[b] = yb[a];
});
@@ -5991,18 +6003,10 @@
wbr: !0
}
),
- R = da.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler,
- Ug = R.unstable_cancelCallback,
- te = R.unstable_now,
- Vg = R.unstable_scheduleCallback,
- Oc = R.unstable_shouldYield,
- Nc = R.unstable_runWithPriority,
- yi = R.unstable_getCurrentPriorityLevel,
- re = R.unstable_ImmediatePriority,
- se = R.unstable_UserBlockingPriority,
- Kg = R.unstable_NormalPriority,
- zi = R.unstable_LowPriority,
- Ai = R.unstable_IdlePriority,
+ te = aj,
+ Vg = bj,
+ Oc = cj,
+ Ug = $i,
me = null,
ne = null,
Di = "function" === typeof setTimeout ? setTimeout : void 0,
@@ -6324,6 +6328,13 @@
};
var ji = "function" === typeof WeakSet ? WeakSet : Set,
wi = "function" === typeof WeakMap ? WeakMap : Map,
+ yi = ej,
+ Nc = dj,
+ re = fj,
+ se = gj,
+ Kg = hj,
+ zi = ij,
+ Ai = jj,
pe = Ma.ReactCurrentDispatcher,
Jg = Ma.ReactCurrentOwner,
ye = 1073741822, The Node and WWW builds got smaller, however, as expected. |
I noticed our prod bundles have code like:
This is because
scheduler
is a CommonJS external module. Rollup calls named exports on these with dot notation. This seems very non-ideal in hot paths.I'm not sure if there's an easy way to fix it on the build level. But scheduler is the only external module we use and it's easy to fix at callsites. So I just did that. Star imports for everything else stay an anti-pattern.
This also removes some re-export junk in the UMD bundle.
Fixed version: