Skip to content

Commit 0388d2e

Browse files
committed
Refactor '__FIZZ_FUNCTION__' -> __FIZZ_FUNCTION_STR__
1 parent 033b0bc commit 0388d2e

File tree

5 files changed

+38
-19
lines changed

5 files changed

+38
-19
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,13 +2022,14 @@ export function writeEndSegment(
20222022
}
20232023

20242024
// These are injected by the build system. See ReactDOMFizzClientInstructionSet.js.
2025-
const completeSegmentFunction =
2026-
'__FIZZ_INSTRUCTION_SET_COMPLETE_SEGMENT_FUNCTION__';
2027-
const completeBoundaryFunction =
2028-
'__FIZZ_INSTRUCTION_SET_COMPLETE_BOUNDARY_FUNCTION__';
2029-
const styleInsertionFunction =
2030-
'__FIZZ_INSTRUCTION_SET_STYLE_INSERTION_FUNCTION__';
2031-
const clientRenderFunction = '__FIZZ_INSTRUCTION_SET_CLIENT_RENDER_FUNCTION__';
2025+
// eslint-disable-next-line no-undef
2026+
const completeSegmentFunction = __FIZZ_INSTRUCTION_SET_COMPLETE_SEGMENT_FUNCTION_STR__;
2027+
// eslint-disable-next-line no-undef
2028+
const completeBoundaryFunction = __FIZZ_INSTRUCTION_SET_COMPLETE_BOUNDARY_FUNCTION_STR__;
2029+
// eslint-disable-next-line no-undef
2030+
const styleInsertionFunction = __FIZZ_INSTRUCTION_SET_STYLE_INSERTION_FUNCTION_STR__;
2031+
// eslint-disable-next-line no-undef
2032+
const clientRenderFunction = __FIZZ_INSTRUCTION_SET_CLIENT_RENDER_FUNCTION_STR__;
20322033

20332034
const completeSegmentScript1Full = stringToPrecomputedChunk(
20342035
completeSegmentFunction + ';$RS("',

packages/react-dom/src/server/ReactDOMFizzClientInstructionSet.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,10 @@ exports.styleInsertionFunction =
215215
'$RM=new Map;function $RR(p,q,t){function r(l){this.s=l}for(var m=new Map,n=document,g,e,f=n.querySelectorAll("link[data-rprec]"),d=0;e=f[d++];)m.set(e.dataset.rprec,g=e);e=0;f=[];for(var c,h,b,a;c=t[e++];){var k=0;h=c[k++];if(b=$RM.get(h))"l"!==b.s&&f.push(b);else{a=n.createElement("link");a.href=h;a.rel="stylesheet";for(a.dataset.rprec=d=c[k++];b=c[k++];)a.setAttribute(b,c[k++]);b=a._p=new Promise(function(l,u){a.onload=l;a.onerror=u});b.then(r.bind(b,"l"),r.bind(b,"e"));$RM.set(h,b);f.push(b);c=m.get(d)||g;c===g&&(g=a);m.set(d,a);c?c.parentNode.insertBefore(a,c.nextSibling):(d=n.head,d.insertBefore(a,d.firstChild))}}Promise.all(f).then($RC.bind(null,p,q,""),$RC.bind(null,p,q,"Resource failed to load"))}';
216216
exports.clientRenderFunction =
217217
'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())}';
218+
219+
exports.completeSegmentFunctionStr =
220+
"'" + exports.completeSegmentFunction + "'";
221+
exports.completeBoundaryFunctionStr =
222+
"'" + exports.completeBoundaryFunction + "'";
223+
exports.styleInsertionFunctionStr = "'" + exports.styleInsertionFunction + "'";
224+
exports.clientRenderFunctionStr = "'" + exports.clientRenderFunction + "'";

scripts/flow/environment.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ declare var __UMD__: boolean;
1414
declare var __EXPERIMENTAL__: boolean;
1515
declare var __VARIANT__: boolean;
1616

17-
declare var __FIZZ_INSTRUCTION_SET_COMPLETE_SEGMENT_FUNCTION__: string;
18-
declare var __FIZZ_INSTRUCTION_SET_COMPLETE_BOUNDARY_FUNCTION__: string;
19-
declare var __FIZZ_INSTRUCTION_SET_STYLE_INSERTION_FUNCTION__: string;
20-
declare var __FIZZ_INSTRUCTION_SET_CLIENT_RENDER_FUNCTION__: string;
17+
declare var __FIZZ_INSTRUCTION_SET_COMPLETE_SEGMENT_FUNCTION_STR__: string;
18+
declare var __FIZZ_INSTRUCTION_SET_COMPLETE_BOUNDARY_FUNCTION_STR__: string;
19+
declare var __FIZZ_INSTRUCTION_SET_STYLE_INSERTION_FUNCTION_STR__: string;
20+
declare var __FIZZ_INSTRUCTION_SET_CLIENT_RENDER_FUNCTION_STR__: string;
2121

2222
declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
2323
inject: ?((stuff: Object) => void)

scripts/jest/setupEnvironment.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
/* eslint-disable */
22

3+
const {
4+
completeSegmentFunction,
5+
completeBoundaryFunction,
6+
styleInsertionFunction,
7+
clientRenderFunction,
8+
} = require('../../packages/react-dom/src/server/ReactDOMFizzClientInstructionSet.js');
9+
310
const NODE_ENV = process.env.NODE_ENV;
411
if (NODE_ENV !== 'development' && NODE_ENV !== 'production') {
512
throw new Error('NODE_ENV must either be set to development or production.');
@@ -9,6 +16,10 @@ global.__EXTENSION__ = false;
916
global.__TEST__ = NODE_ENV === 'test';
1017
global.__PROFILE__ = NODE_ENV === 'development';
1118
global.__UMD__ = false;
19+
global.__FIZZ_INSTRUCTION_SET_COMPLETE_SEGMENT_FUNCTION_STR__ = completeSegmentFunction;
20+
global.__FIZZ_INSTRUCTION_SET_COMPLETE_BOUNDARY_FUNCTION_STR__ = completeBoundaryFunction;
21+
global.__FIZZ_INSTRUCTION_SET_STYLE_INSERTION_FUNCTION_STR__ = styleInsertionFunction;
22+
global.__FIZZ_INSTRUCTION_SET_CLIENT_RENDER_FUNCTION_STR__ = clientRenderFunction;
1223

1324
const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL;
1425

scripts/rollup/build.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ const Wrappers = require('./wrappers');
2525

2626
// TODO: Ideally these would be built as part of the regular build step.
2727
const {
28-
completeSegmentFunction,
29-
completeBoundaryFunction,
30-
styleInsertionFunction,
31-
clientRenderFunction,
28+
completeSegmentFunctionStr,
29+
completeBoundaryFunctionStr,
30+
styleInsertionFunctionStr,
31+
clientRenderFunctionStr,
3232
} = require('../../packages/react-dom/src/server/ReactDOMFizzClientInstructionSet');
3333

3434
const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL;
@@ -373,10 +373,10 @@ function getPlugins(
373373
// NOTE: I did not put much thought into how to configure this.
374374
__VARIANT__: bundle.enableNewReconciler === true,
375375

376-
__FIZZ_INSTRUCTION_SET_COMPLETE_SEGMENT_FUNCTION__: completeSegmentFunction,
377-
__FIZZ_INSTRUCTION_SET_COMPLETE_BOUNDARY_FUNCTION__: completeBoundaryFunction,
378-
__FIZZ_INSTRUCTION_SET_STYLE_INSERTION_FUNCTION__: styleInsertionFunction,
379-
__FIZZ_INSTRUCTION_SET_CLIENT_RENDER_FUNCTION__: clientRenderFunction,
376+
__FIZZ_INSTRUCTION_SET_COMPLETE_SEGMENT_FUNCTION_STR__: completeSegmentFunctionStr,
377+
__FIZZ_INSTRUCTION_SET_COMPLETE_BOUNDARY_FUNCTION_STR__: completeBoundaryFunctionStr,
378+
__FIZZ_INSTRUCTION_SET_STYLE_INSERTION_FUNCTION_STR__: styleInsertionFunctionStr,
379+
__FIZZ_INSTRUCTION_SET_CLIENT_RENDER_FUNCTION_STR__: clientRenderFunctionStr,
380380
}),
381381
// The CommonJS plugin *only* exists to pull "art" into "react-art".
382382
// I'm going to port "art" to ES modules to avoid this problem.

0 commit comments

Comments
 (0)