Skip to content

Commit 2931c47

Browse files
committed
[Float][Fizz][Static] add importMap option to Fizz and Static server renderers (#27260)
Import maps need to be emitted before any scripts or preloads so the browser can properly locate these resources. Unlike most scripts, importmaps are singletons meaning you can only have one per document and they must appear before any modules are loaded or preloaded. In the future there may be a way to dynamically add more mappings however the proposed API for this seems likely to be a javascript API and not an html tag. Given the unique constraints here this PR implements React's support of importMaps as the following 1. an `importMap` option accepting a plain object mapping module specifier to path is accepted in any API that renders a preamble (head content). Notably this precludes resume rendering because in resume cases the preamble should have already been produced as part of the prerender step. 2. the importMap is stringified and emitted as a `<script type="importmap">...</script>` in the preamble. 3. the importMap is escaped identically to how bootstrapScriptContent is escaped, notably, isntances of `</script>` are escaped to avoid breaking out of the script context Users can still render importmap tags however with Float enabled this is rather pointless as most modules will be hoisted above the importmap that is rendered. In practice this means the only functional way to use import maps with React is to use this config API. DiffTrain build for commit 9d4582d.
1 parent 5a71bfb commit 2931c47

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23977,7 +23977,7 @@ function createFiberRoot(
2397723977
return root;
2397823978
}
2397923979

23980-
var ReactVersion = "18.3.0-canary-b4cdd3e89-20230823";
23980+
var ReactVersion = "18.3.0-canary-9d4582dff-20230824";
2398123981

2398223982
// Might add PROFILE later.
2398323983

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8612,7 +8612,7 @@ var devToolsConfig$jscomp$inline_1029 = {
86128612
throw Error("TestRenderer does not support findFiberByHostInstance()");
86138613
},
86148614
bundleType: 0,
8615-
version: "18.3.0-canary-b4cdd3e89-20230823",
8615+
version: "18.3.0-canary-9d4582dff-20230824",
86168616
rendererPackageName: "react-test-renderer"
86178617
};
86188618
var internals$jscomp$inline_1228 = {
@@ -8643,7 +8643,7 @@ var internals$jscomp$inline_1228 = {
86438643
scheduleRoot: null,
86448644
setRefreshHandler: null,
86458645
getCurrentFiber: null,
8646-
reconcilerVersion: "18.3.0-canary-b4cdd3e89-20230823"
8646+
reconcilerVersion: "18.3.0-canary-9d4582dff-20230824"
86478647
};
86488648
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
86498649
var hook$jscomp$inline_1229 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9038,7 +9038,7 @@ var devToolsConfig$jscomp$inline_1071 = {
90389038
throw Error("TestRenderer does not support findFiberByHostInstance()");
90399039
},
90409040
bundleType: 0,
9041-
version: "18.3.0-canary-b4cdd3e89-20230823",
9041+
version: "18.3.0-canary-9d4582dff-20230824",
90429042
rendererPackageName: "react-test-renderer"
90439043
};
90449044
var internals$jscomp$inline_1269 = {
@@ -9069,7 +9069,7 @@ var internals$jscomp$inline_1269 = {
90699069
scheduleRoot: null,
90709070
setRefreshHandler: null,
90719071
getCurrentFiber: null,
9072-
reconcilerVersion: "18.3.0-canary-b4cdd3e89-20230823"
9072+
reconcilerVersion: "18.3.0-canary-9d4582dff-20230824"
90739073
};
90749074
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
90759075
var hook$jscomp$inline_1270 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-canary-b4cdd3e89-20230823";
30+
var ReactVersion = "18.3.0-canary-9d4582dff-20230824";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,4 +616,4 @@ exports.useSyncExternalStore = function (
616616
exports.useTransition = function () {
617617
return ReactCurrentDispatcher.current.useTransition();
618618
};
619-
exports.version = "18.3.0-canary-b4cdd3e89-20230823";
619+
exports.version = "18.3.0-canary-9d4582dff-20230824";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ exports.useSyncExternalStore = function (
619619
exports.useTransition = function () {
620620
return ReactCurrentDispatcher.current.useTransition();
621621
};
622-
exports.version = "18.3.0-canary-b4cdd3e89-20230823";
622+
exports.version = "18.3.0-canary-9d4582dff-20230824";
623623

624624
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
625625
if (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b4cdd3e8922713f8c9817b004a0dc51be47bc5df
1+
9d4582dffdea5b4dcb6a6093ea848d15423c7701

0 commit comments

Comments
 (0)