Skip to content

Commit

Permalink
[DOM] Infer react-server entries bundles if not explicitly configured (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
gnoff committed Apr 9, 2024
1 parent f613165 commit 7f93cb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/react-dom/src/ReactDOMSharedInternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,4 @@ const Internals: ReactDOMInternals = {
usingClientEntryPoint: false,
};

// if (__DEV__) {
// (Internals: any).usingClientEntryPoint = false;
// }

export default Internals;
12 changes: 12 additions & 0 deletions scripts/rollup/packaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ function filterOutEntrypoints(name) {
hasBundle =
entryPointsToHasBundle.get(entry + '.node') ||
entryPointsToHasBundle.get(entry + '.browser');

// The .react-server and .rsc suffixes may not have a bundle representation but
// should infer their bundle status from the non-suffixed entry point.
if (entry.endsWith('.react-server')) {
hasBundle = entryPointsToHasBundle.get(
entry.slice(0, '.react-server'.length * -1)
);
} else if (entry.endsWith('.rsc')) {
hasBundle = entryPointsToHasBundle.get(
entry.slice(0, '.rsc'.length * -1)
);
}
}
if (hasBundle === undefined) {
// This doesn't exist in the bundles. It's an extra file.
Expand Down

0 comments on commit 7f93cb4

Please sign in to comment.