@samitouri / QOS-React-2 / commits / 7f93cb41c8

[DOM] Infer react-server entries bundles if not explicitly configured (#28795)

When packaging we want to infer that a bundle exists for a `react-server` file even if it isn't explicitly configured. This is useful in particular for the react-server entrypoints that error on import that were recently added to `react-dom` This change also cleans up a wayward comment left behind in a prior PR

Josh Story committed Apr 9, 2024 at 10:39 UTC 7f93cb41c8e1352eec158e508bc612025425266d
2 files changed +12 -4
packages/react-dom/src/ReactDOMSharedInternals.js
-4
@@ -47,8 +47,4 @@ const Internals: ReactDOMInternals = {
47 usingClientEntryPoint: false,
48 };
49
50 -// if (__DEV__) {
51 -// (Internals: any).usingClientEntryPoint = false;
52 -// }
53 -
50 export default Internals;
scripts/rollup/packaging.js
+12
@@ -213,6 +213,18 @@ function filterOutEntrypoints(name) {
213 hasBundle =
214 entryPointsToHasBundle.get(entry + '.node') ||
215 entryPointsToHasBundle.get(entry + '.browser');
216 +
217 + // The .react-server and .rsc suffixes may not have a bundle representation but
218 + // should infer their bundle status from the non-suffixed entry point.
219 + if (entry.endsWith('.react-server')) {
220 + hasBundle = entryPointsToHasBundle.get(
221 + entry.slice(0, '.react-server'.length * -1)
222 + );
223 + } else if (entry.endsWith('.rsc')) {
224 + hasBundle = entryPointsToHasBundle.get(
225 + entry.slice(0, '.rsc'.length * -1)
226 + );
227 + }
228 }
229 if (hasBundle === undefined) {
230 // This doesn't exist in the bundles. It's an extra file.