Skip to content

Commit

Permalink
Rename "shared subset" to "server"
Browse files Browse the repository at this point in the history
The internal file ReactSharedSubset is what the `react` module resolves
to when imported from a Server Component environment. We gave it this
name because, originally, the idea was that Server Components can access
a subset of the APIs available on the client.

However, since then, we've also added APIs that can _only_ by accessed
on the server and not the client. In other words, it's no longer a
subset, it's a slightly different overlapping set.

So this commit renames ReactSharedSubet to ReactServer and updates all
the references. This does not affect the public API, only our
internal implementation.
  • Loading branch information
acdlite committed Jan 15, 2024
1 parent 60a927d commit 86a0e60
Show file tree
Hide file tree
Showing 34 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let assertLog;
describe('ReactFlight', () => {
beforeEach(() => {
jest.resetModules();
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
ReactServer = require('react');
ReactNoopFlightServer = require('react-noop-renderer/flight-server');
// This stores the state so we need to preserve it
Expand Down Expand Up @@ -1465,7 +1465,7 @@ describe('ReactFlight', () => {
// Reset all modules, except flight-modules which keeps the registry of Client Components
const flightModules = require('react-noop-renderer/flight-modules');
jest.resetModules();
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-noop-renderer/flight-modules', () => flightModules);

ReactServer = require('react');
Expand Down
7 changes: 7 additions & 0 deletions packages/react-dom/npm/react-dom.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom.server.production.min.js');
} else {
module.exports = require('./cjs/react-dom.server.development.js');
}
7 changes: 0 additions & 7 deletions packages/react-dom/npm/react-dom.shared-subset.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"test-utils.js",
"unstable_testing.js",
"unstable_server-external-runtime.js",
"react-dom.shared-subset.js",
"react-dom.server.js",
"cjs/",
"umd/"
],
"exports": {
".": {
"react-server": "./react-dom.shared-subset.js",
"react-server": "./react-dom.server.js",
"default": "./index.js"
},
"./client": "./client.js",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
describe('ReactDOMInReactServer', () => {
beforeEach(() => {
jest.resetModules();
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
});

it('can require react-dom', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('ReactFlightDOM for FB', () => {
// condition
jest.resetModules();

jest.mock('react', () => require('react/src/ReactSharedSubsetFB'));
jest.mock('react', () => require('react/src/ReactServerFB'));

jest.mock('shared/ReactFeatureFlags', () => {
jest.mock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('ReactFlightDOM', () => {
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.node.unbundled'),
);
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));

const TurbopackMock = require('./utils/TurbopackMock');
clientExports = TurbopackMock.clientExports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ReactFlightDOMBrowser', () => {
jest.resetModules();

// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.browser'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('ReactFlightDOMEdge', () => {
jest.resetModules();

// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.edge'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('ReactFlightDOMForm', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.edge'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('ReactFlightDOMNode', () => {
jest.resetModules();

// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.node'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ReactFlightDOMReply', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.browser'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ReactFlightDOMReply', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.edge'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('ReactFlightDOM', () => {
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.node.unbundled'),
);
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));

const WebpackMock = require('./utils/WebpackMock');
clientExports = WebpackMock.clientExports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('ReactFlightDOMBrowser', () => {
jest.resetModules();

// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.browser'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('ReactFlightDOMEdge', () => {
jest.resetModules();

// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.edge'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('ReactFlightDOMForm', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.edge'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('ReactFlightDOMNode', () => {
jest.resetModules();

// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.node'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ReactFlightDOMReply', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.browser'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ReactFlightDOMReplyEdge', () => {
beforeEach(() => {
jest.resetModules();
// Simulate the condition resolution
jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.edge'),
);
Expand Down
7 changes: 7 additions & 0 deletions packages/react/npm/react.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.server.production.min.js');
} else {
module.exports = require('./cjs/react.server.development.js');
}
7 changes: 0 additions & 7 deletions packages/react/npm/react.shared-subset.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"umd/",
"jsx-runtime.js",
"jsx-dev-runtime.js",
"react.shared-subset.js"
"react.server.js"
],
"main": "index.js",
"exports": {
".": {
"react-server": "./react.shared-subset.js",
"react-server": "./react.server.js",
"default": "./index.js"
},
"./package.json": "./package.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from './src/ReactSharedSubset';
export * from './src/ReactServer';
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
* @flow
*/

export * from './ReactSharedSubset';
export * from './ReactServer';
export {jsx, jsxs, jsxDEV} from './jsx/ReactJSX';
2 changes: 1 addition & 1 deletion packages/react/src/__tests__/ReactFetch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('ReactFetch', () => {
fetchCount = 0;
global.fetch = fetchMock;

jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.browser'),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/__tests__/ReactFetchEdge-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('ReactFetch', () => {
fetchCount = 0;
global.fetch = fetchMock;

jest.mock('react', () => require('react/react.shared-subset'));
jest.mock('react', () => require('react/react.server'));
jest.mock('react-server-dom-webpack/server', () =>
require('react-server-dom-webpack/server.edge'),
);
Expand Down
4 changes: 2 additions & 2 deletions scripts/jest/setupHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ global.__unmockReact = mockReact;

mockReact();

jest.mock('react/react.shared-subset', () => {
jest.mock('react/react.server', () => {
const resolvedEntryPoint = resolveEntryFork(
require.resolve('react/src/ReactSharedSubset'),
require.resolve('react/src/ReactServer'),
global.__WWW__
);
return jest.requireActual(resolvedEntryPoint);
Expand Down
12 changes: 6 additions & 6 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: ISOMORPHIC,
entry: 'react/src/ReactSharedSubset.js',
name: 'react.shared-subset',
entry: 'react/src/ReactServer.js',
name: 'react.server',
global: 'React',
minifyWithProdErrorCodes: true,
wrapWithModuleBoundaries: false,
Expand All @@ -108,8 +108,8 @@ const bundles = [
{
bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [],
moduleType: ISOMORPHIC,
entry: 'react/src/ReactSharedSubsetFB.js',
global: 'ReactSharedSubset',
entry: 'react/src/ReactServerFB.js',
global: 'ReactServer',
minifyWithProdErrorCodes: true,
wrapWithModuleBoundaries: false,
externals: [],
Expand Down Expand Up @@ -180,8 +180,8 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RENDERER,
entry: 'react-dom/src/ReactDOMSharedSubset.js',
name: 'react-dom.shared-subset',
entry: 'react-dom/src/ReactDOMServer.js',
name: 'react-dom.server',
global: 'ReactDOM',
minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false,
Expand Down
6 changes: 3 additions & 3 deletions scripts/rollup/forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const forks = Object.freeze({
return './packages/react/src/ReactSharedInternalsClient.js';
}
if (
entry === 'react/src/ReactSharedSubset.js' ||
entry === 'react/src/ReactSharedSubsetFB.js'
entry === 'react/src/ReactServer.js' ||
entry === 'react/src/ReactServerFB.js'
) {
return './packages/react/src/ReactSharedInternalsServer.js';
}
Expand Down Expand Up @@ -93,7 +93,7 @@ const forks = Object.freeze({
if (
entry === 'react-dom' ||
entry === 'react-dom/server-rendering-stub' ||
entry === 'react-dom/src/ReactDOMSharedSubset.js'
entry === 'react-dom/src/ReactDOMServer.js'
) {
return './packages/react-dom/src/ReactDOMSharedInternals.js';
}
Expand Down
Loading

0 comments on commit 86a0e60

Please sign in to comment.