Skip to content

Commit 4bc925d

Browse files
committed
Shortens the names of host dispatcher methods to save bytes
1 parent bd85e05 commit 4bc925d

File tree

7 files changed

+93
-85
lines changed

7 files changed

+93
-85
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,13 +1923,13 @@ function getDocumentFromRoot(root: HoistableRoot): Document {
19231923
const previousDispatcher =
19241924
ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */
19251925
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = {
1926-
prefetchDNS,
1927-
preconnect,
1928-
preload,
1929-
preloadModule,
1930-
preinitStyle,
1931-
preinitScript,
1932-
preinitModuleScript,
1926+
D /* prefetchDNS */: prefetchDNS,
1927+
C /* preconnect */: preconnect,
1928+
L /* preload */: preload,
1929+
m /* preloadModule */: preloadModule,
1930+
X /* preinitScript */: preinitScript,
1931+
S /* preinitStyle */: preinitStyle,
1932+
M /* preinitModuleScript */: preinitModuleScript,
19331933
};
19341934

19351935
// We expect this to get inlined. It is a function mostly to communicate the special nature of
@@ -1971,17 +1971,17 @@ function preconnectAs(
19711971
}
19721972

19731973
function prefetchDNS(href: string) {
1974-
previousDispatcher.prefetchDNS(href);
1974+
previousDispatcher.D(/* prefetchDNS */ href);
19751975
preconnectAs('dns-prefetch', href, null);
19761976
}
19771977

19781978
function preconnect(href: string, crossOrigin?: ?CrossOriginEnum) {
1979-
previousDispatcher.preconnect(href, crossOrigin);
1979+
previousDispatcher.C(/* preconnect */ href, crossOrigin);
19801980
preconnectAs('preconnect', href, crossOrigin);
19811981
}
19821982

19831983
function preload(href: string, as: string, options?: ?PreloadImplOptions) {
1984-
previousDispatcher.preload(href, as, options);
1984+
previousDispatcher.L(/* preload */ href, as, options);
19851985
const ownerDocument = getGlobalDocument();
19861986
if (ownerDocument && href && as) {
19871987
let preloadSelector = `link[rel="preload"][as="${escapeSelectorAttributeValueInsideDoubleQuotes(
@@ -2059,7 +2059,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
20592059
}
20602060

20612061
function preloadModule(href: string, options?: ?PreloadModuleImplOptions) {
2062-
previousDispatcher.preloadModule(href, options);
2062+
previousDispatcher.m(/* preloadModule */ href, options);
20632063
const ownerDocument = getGlobalDocument();
20642064
if (ownerDocument && href) {
20652065
const as =
@@ -2120,7 +2120,7 @@ function preinitStyle(
21202120
precedence: ?string,
21212121
options?: ?PreinitStyleOptions,
21222122
) {
2123-
previousDispatcher.preinitStyle(href, precedence, options);
2123+
previousDispatcher.S(/* preinitStyle */ href, precedence, options);
21242124

21252125
const ownerDocument = getGlobalDocument();
21262126
if (ownerDocument && href) {
@@ -2194,7 +2194,7 @@ function preinitStyle(
21942194
}
21952195

21962196
function preinitScript(src: string, options?: ?PreinitScriptOptions) {
2197-
previousDispatcher.preinitScript(src, options);
2197+
previousDispatcher.X(/* preinitScript */ src, options);
21982198

21992199
const ownerDocument = getGlobalDocument();
22002200
if (ownerDocument && src) {
@@ -2250,7 +2250,7 @@ function preinitModuleScript(
22502250
src: string,
22512251
options?: ?PreinitModuleScriptOptions,
22522252
) {
2253-
previousDispatcher.preinitModuleScript(src, options);
2253+
previousDispatcher.M(/* preinitModuleScript */ src, options);
22542254

22552255
const ownerDocument = getGlobalDocument();
22562256
if (ownerDocument && src) {

packages/react-dom-bindings/src/server/ReactDOMFlightServerHostDispatcher.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
2727
const previousDispatcher =
2828
ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */
2929
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = {
30-
prefetchDNS,
31-
preconnect,
32-
preload,
33-
preloadModule,
34-
preinitStyle,
35-
preinitScript,
36-
preinitModuleScript,
30+
D /* prefetchDNS */: prefetchDNS,
31+
C /* preconnect */: preconnect,
32+
L /* preload */: preload,
33+
m /* preloadModule */: preloadModule,
34+
X /* preinitScript */: preinitScript,
35+
S /* preinitStyle */: preinitStyle,
36+
M /* preinitModuleScript */: preinitModuleScript,
3737
};
3838

3939
function prefetchDNS(href: string) {
@@ -49,7 +49,7 @@ function prefetchDNS(href: string) {
4949
hints.add(key);
5050
emitHint(request, 'D', href);
5151
} else {
52-
previousDispatcher.prefetchDNS(href);
52+
previousDispatcher.D(/* prefetchDNS */ href);
5353
}
5454
}
5555
}
@@ -72,7 +72,7 @@ function preconnect(href: string, crossOrigin?: ?CrossOriginEnum) {
7272
emitHint(request, 'C', href);
7373
}
7474
} else {
75-
previousDispatcher.preconnect(href, crossOrigin);
75+
previousDispatcher.C(/* preconnect */ href, crossOrigin);
7676
}
7777
}
7878
}
@@ -105,7 +105,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
105105
emitHint(request, 'L', [href, as]);
106106
}
107107
} else {
108-
previousDispatcher.preload(href, as, options);
108+
previousDispatcher.L(/* preload */ href, as, options);
109109
}
110110
}
111111
}
@@ -129,7 +129,7 @@ function preloadModule(href: string, options?: ?PreloadModuleImplOptions) {
129129
return emitHint(request, 'm', href);
130130
}
131131
} else {
132-
previousDispatcher.preloadModule(href, options);
132+
previousDispatcher.m(/* preloadModule */ href, options);
133133
}
134134
}
135135
}
@@ -163,7 +163,7 @@ function preinitStyle(
163163
return emitHint(request, 'S', href);
164164
}
165165
} else {
166-
previousDispatcher.preinitStyle(href, precedence, options);
166+
previousDispatcher.S(/* preinitStyle */ href, precedence, options);
167167
}
168168
}
169169
}
@@ -187,7 +187,7 @@ function preinitScript(src: string, options?: ?PreinitScriptOptions) {
187187
return emitHint(request, 'X', src);
188188
}
189189
} else {
190-
previousDispatcher.preinitScript(src, options);
190+
previousDispatcher.X(/* preinitScript */ src, options);
191191
}
192192
}
193193
}
@@ -214,7 +214,7 @@ function preinitModuleScript(
214214
return emitHint(request, 'M', src);
215215
}
216216
} else {
217-
previousDispatcher.preinitModuleScript(src, options);
217+
previousDispatcher.M(/* preinitModuleScript */ src, options);
218218
}
219219
}
220220
}

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
8787
const previousDispatcher =
8888
ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */
8989
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = {
90-
prefetchDNS,
91-
preconnect,
92-
preload,
93-
preloadModule,
94-
preinitScript,
95-
preinitStyle,
96-
preinitModuleScript,
90+
D /* prefetchDNS */: prefetchDNS,
91+
C /* preconnect */: preconnect,
92+
L /* preload */: preload,
93+
m /* preloadModule */: preloadModule,
94+
X /* preinitScript */: preinitScript,
95+
S /* preinitStyle */: preinitStyle,
96+
M /* preinitModuleScript */: preinitModuleScript,
9797
};
9898

9999
// We make every property of the descriptor optional because it is not a contract that
@@ -5265,7 +5265,7 @@ function prefetchDNS(href: string) {
52655265
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
52665266
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
52675267
// fetching) and we don't want to warn in those cases.
5268-
previousDispatcher.prefetchDNS(href);
5268+
previousDispatcher.D(/* prefetchDNS */ href);
52695269
return;
52705270
}
52715271
const resumableState = getResumableState(request);
@@ -5318,7 +5318,7 @@ function preconnect(href: string, crossOrigin: ?CrossOriginEnum) {
53185318
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
53195319
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
53205320
// fetching) and we don't want to warn in those cases.
5321-
previousDispatcher.preconnect(href, crossOrigin);
5321+
previousDispatcher.C(/* preconnect */ href, crossOrigin);
53225322
return;
53235323
}
53245324
const resumableState = getResumableState(request);
@@ -5379,7 +5379,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
53795379
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
53805380
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
53815381
// fetching) and we don't want to warn in those cases.
5382-
previousDispatcher.preload(href, as, options);
5382+
previousDispatcher.L(/* preload */ href, as, options);
53835383
return;
53845384
}
53855385
const resumableState = getResumableState(request);
@@ -5580,7 +5580,7 @@ function preloadModule(
55805580
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
55815581
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
55825582
// fetching) and we don't want to warn in those cases.
5583-
previousDispatcher.preloadModule(href, options);
5583+
previousDispatcher.m(/* preloadModule */ href, options);
55845584
return;
55855585
}
55865586
const resumableState = getResumableState(request);
@@ -5654,7 +5654,7 @@ function preinitStyle(
56545654
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
56555655
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
56565656
// fetching) and we don't want to warn in those cases.
5657-
previousDispatcher.preinitStyle(href, precedence, options);
5657+
previousDispatcher.S(/* preinitStyle */ href, precedence, options);
56585658
return;
56595659
}
56605660
const resumableState = getResumableState(request);
@@ -5739,7 +5739,7 @@ function preinitScript(src: string, options?: ?PreinitScriptOptions): void {
57395739
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
57405740
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
57415741
// fetching) and we don't want to warn in those cases.
5742-
previousDispatcher.preinitScript(src, options);
5742+
previousDispatcher.X(/* preinitScript */ src, options);
57435743
return;
57445744
}
57455745
const resumableState = getResumableState(request);
@@ -5802,7 +5802,7 @@ function preinitModuleScript(
58025802
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
58035803
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
58045804
// fetching) and we don't want to warn in those cases.
5805-
previousDispatcher.preinitModuleScript(src, options);
5805+
previousDispatcher.M(/* preinitModuleScript */ src, options);
58065806
return;
58075807
}
58085808
const resumableState = getResumableState(request);

packages/react-dom-bindings/src/shared/ReactFlightClientConfigDOM.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ export function dispatchHint<Code: HintCode>(
2525
case 'D': {
2626
const refined = refineModel(code, model);
2727
const href = refined;
28-
dispatcher.prefetchDNS(href);
28+
dispatcher.D(/* prefetchDNS */ href);
2929
return;
3030
}
3131
case 'C': {
3232
const refined = refineModel(code, model);
3333
if (typeof refined === 'string') {
3434
const href = refined;
35-
dispatcher.preconnect(href);
35+
dispatcher.C(/* preconnect */ href);
3636
} else {
3737
const href = refined[0];
3838
const crossOrigin = refined[1];
39-
dispatcher.preconnect(href, crossOrigin);
39+
dispatcher.C(/* preconnect */ href, crossOrigin);
4040
}
4141
return;
4242
}
@@ -46,58 +46,58 @@ export function dispatchHint<Code: HintCode>(
4646
const as = refined[1];
4747
if (refined.length === 3) {
4848
const options = refined[2];
49-
dispatcher.preload(href, as, options);
49+
dispatcher.L(/* preload */ href, as, options);
5050
} else {
51-
dispatcher.preload(href, as);
51+
dispatcher.L(/* preload */ href, as);
5252
}
5353
return;
5454
}
5555
case 'm': {
5656
const refined = refineModel(code, model);
5757
if (typeof refined === 'string') {
5858
const href = refined;
59-
dispatcher.preloadModule(href);
59+
dispatcher.m(/* preloadModule */ href);
6060
} else {
6161
const href = refined[0];
6262
const options = refined[1];
63-
dispatcher.preloadModule(href, options);
63+
dispatcher.m(/* preloadModule */ href, options);
6464
}
6565
return;
6666
}
67-
case 'S': {
67+
case 'X': {
6868
const refined = refineModel(code, model);
6969
if (typeof refined === 'string') {
7070
const href = refined;
71-
dispatcher.preinitStyle(href);
71+
dispatcher.X(/* preinitScript */ href);
7272
} else {
7373
const href = refined[0];
74-
const precedence = refined[1] === 0 ? undefined : refined[1];
75-
const options = refined.length === 3 ? refined[2] : undefined;
76-
dispatcher.preinitStyle(href, precedence, options);
74+
const options = refined[1];
75+
dispatcher.X(/* preinitScript */ href, options);
7776
}
7877
return;
7978
}
80-
case 'X': {
79+
case 'S': {
8180
const refined = refineModel(code, model);
8281
if (typeof refined === 'string') {
8382
const href = refined;
84-
dispatcher.preinitScript(href);
83+
dispatcher.S(/* preinitStyle */ href);
8584
} else {
8685
const href = refined[0];
87-
const options = refined[1];
88-
dispatcher.preinitScript(href, options);
86+
const precedence = refined[1] === 0 ? undefined : refined[1];
87+
const options = refined.length === 3 ? refined[2] : undefined;
88+
dispatcher.S(/* preinitStyle */ href, precedence, options);
8989
}
9090
return;
9191
}
9292
case 'M': {
9393
const refined = refineModel(code, model);
9494
if (typeof refined === 'string') {
9595
const href = refined;
96-
dispatcher.preinitModuleScript(href);
96+
dispatcher.M(/* preinitModuleScript */ href);
9797
} else {
9898
const href = refined[0];
9999
const options = refined[1];
100-
dispatcher.preinitModuleScript(href, options);
100+
dispatcher.M(/* preinitModuleScript */ href, options);
101101
}
102102
return;
103103
}
@@ -116,7 +116,7 @@ export function preinitModuleForSSR(
116116
crossOrigin: ?string,
117117
) {
118118
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */
119-
.preinitModuleScript(href, {
119+
.M(/* preinitModuleScript */ href, {
120120
crossOrigin: getCrossOriginString(crossOrigin),
121121
nonce,
122122
});
@@ -128,7 +128,7 @@ export function preinitScriptForSSR(
128128
crossOrigin: ?string,
129129
) {
130130
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */
131-
.preinitScript(href, {
131+
.X(/* preinitScript */ href, {
132132
crossOrigin: getCrossOriginString(crossOrigin),
133133
nonce,
134134
});

packages/react-dom/src/ReactDOMSharedInternals.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ type InternalsType = {
2727
function noop() {}
2828

2929
const DefaultDispatcher: HostDispatcher = {
30-
prefetchDNS: noop,
31-
preconnect: noop,
32-
preload: noop,
33-
preloadModule: noop,
34-
preinitScript: noop,
35-
preinitStyle: noop,
36-
preinitModuleScript: noop,
30+
D /* prefetchDNS */: noop,
31+
C /* preconnect */: noop,
32+
L /* preload */: noop,
33+
m /* preloadModule */: noop,
34+
X /* preinitScript */: noop,
35+
S /* preinitStyle */: noop,
36+
M /* preinitModuleScript */: noop,
3737
};
3838

3939
const Internals: InternalsType = {

0 commit comments

Comments
 (0)