Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup react-server-dom-parcel package #28138

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
8 changes: 8 additions & 0 deletions .eslintrc.js
Expand Up @@ -327,6 +327,7 @@ module.exports = {
'packages/react-server-dom-esm/**/*.js',
'packages/react-server-dom-webpack/**/*.js',
'packages/react-server-dom-turbopack/**/*.js',
'packages/react-server-dom-parcel/**/*.js',
'packages/react-server-dom-fb/**/*.js',
'packages/react-test-renderer/**/*.js',
'packages/react-debug-tools/**/*.js',
Expand Down Expand Up @@ -436,6 +437,13 @@ module.exports = {
__turbopack_require__: 'readonly',
},
},
{
files: ['packages/react-server-dom-parcel/**/*.js'],
globals: {
parcelRequire: 'readonly',
__parcel__import__: 'readonly',
},
},
{
files: ['packages/scheduler/**/*.js'],
globals: {
Expand Down
1 change: 1 addition & 0 deletions ReactVersions.js
Expand Up @@ -36,6 +36,7 @@ const stablePackages = {
'react-dom': ReactVersion,
'react-server-dom-webpack': ReactVersion,
'react-server-dom-turbopack': ReactVersion,
'react-server-dom-parcel': ReactVersion,
'react-is': ReactVersion,
'react-reconciler': '0.30.0',
'react-refresh': '0.15.0',
Expand Down
@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from 'react-client/src/ReactFlightClientConfigBrowser';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigBundlerParcel';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigBundlerParcelBrowser';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigTargetParcelBrowser';
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
export const usedWithSSR = false;
@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from 'react-client/src/ReactFlightClientConfigBrowser';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigBundlerParcel';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigBundlerParcelServer';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigTargetParcelServer';
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
export const usedWithSSR = true;
@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from 'react-client/src/ReactFlightClientConfigNode';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigBundlerParcel';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigBundlerParcelServer';
export * from 'react-server-dom-parcel/src/ReactFlightClientConfigTargetParcelServer';
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';
export const usedWithSSR = true;
Expand Up @@ -11,6 +11,11 @@
// It is the configuration of the FlightClient behavior which can run in either environment.

import type {HintCode, HintModel} from '../server/ReactFlightServerConfigDOM';
import type {
PreinitStyleOptions,
PreloadImplOptions,
PreloadModuleImplOptions,
} from 'react-dom/src/shared/ReactDOMTypes';

import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
const ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
Expand Down Expand Up @@ -140,3 +145,35 @@ export function preinitScriptForSSR(
});
}
}

export function preloadForSSR(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the moment, yes. I need to add more metadata to the manifest so I can determine if a chunk is an ES module or not. Right now I'm just assuming it is.

href: string,
as: string,
options: ?PreloadImplOptions,
) {
const dispatcher = ReactDOMCurrentDispatcher.current;
if (dispatcher) {
dispatcher.preload(href, as, options);
}
}

export function preloadModuleForSSR(
href: string,
options: ?PreloadModuleImplOptions,
) {
const dispatcher = ReactDOMCurrentDispatcher.current;
if (dispatcher) {
dispatcher.preloadModule(href, options);
}
}

export function preinitStyleForSSR(
href: string,
precedence: ?string,
options?: ?PreinitStyleOptions,
) {
const dispatcher = ReactDOMCurrentDispatcher.current;
if (dispatcher) {
dispatcher.preinitStyle(href, precedence, options);
}
}
5 changes: 5 additions & 0 deletions packages/react-server-dom-parcel/README.md
@@ -0,0 +1,5 @@
# react-server-dom-parcel

Experimental React Flight bindings for DOM using Parcel.

**Use it at your own risk.**
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/client.browser.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './src/ReactFlightDOMClientBrowser';
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/client.edge.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './src/ReactFlightDOMClientEdge';
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/client.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './client.browser';
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/client.node.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './src/ReactFlightDOMClientNode';
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/index.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

throw new Error('Use react-server-dom-parcel/client instead.');
7 changes: 7 additions & 0 deletions packages/react-server-dom-parcel/npm/client.browser.js
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-parcel-client.browser.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-parcel-client.browser.development.js');
}
7 changes: 7 additions & 0 deletions packages/react-server-dom-parcel/npm/client.edge.js
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-parcel-client.edge.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-parcel-client.edge.development.js');
}
3 changes: 3 additions & 0 deletions packages/react-server-dom-parcel/npm/client.js
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('./client.browser');
7 changes: 7 additions & 0 deletions packages/react-server-dom-parcel/npm/client.node.js
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-parcel-client.node.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-parcel-client.node.development.js');
}
12 changes: 12 additions & 0 deletions packages/react-server-dom-parcel/npm/index.js
@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

'use strict';

throw new Error('Use react-server-dom-parcel/client instead.');
7 changes: 7 additions & 0 deletions packages/react-server-dom-parcel/npm/server.browser.js
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-parcel-server.browser.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-parcel-server.browser.development.js');
}
7 changes: 7 additions & 0 deletions packages/react-server-dom-parcel/npm/server.edge.js
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-parcel-server.edge.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-parcel-server.edge.development.js');
}
6 changes: 6 additions & 0 deletions packages/react-server-dom-parcel/npm/server.js
@@ -0,0 +1,6 @@
'use strict';

throw new Error(
'The React Server Writer cannot be used outside a react-server environment. ' +
'You must configure Node.js using the `--conditions react-server` flag.'
);
7 changes: 7 additions & 0 deletions packages/react-server-dom-parcel/npm/server.node.js
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-parcel-server.node.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-parcel-server.node.development.js');
}
69 changes: 69 additions & 0 deletions packages/react-server-dom-parcel/package.json
@@ -0,0 +1,69 @@
{
"name": "react-server-dom-parcel",
"description": "React Server Components bindings for DOM using Parcel. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
"version": "18.2.0",
"keywords": [
"react"
],
"homepage": "https://reactjs.org/",
"bugs": "https://github.com/facebook/react/issues",
"license": "MIT",
"files": [
"LICENSE",
"README.md",
"index.js",
"client.js",
"client.browser.js",
"client.edge.js",
"client.node.js",
"server.js",
"server.browser.js",
"server.edge.js",
"server.node.js",
"cjs/",
"umd/"
],
"exports": {
".": "./index.js",
"./client": {
"workerd": "./client.edge.js",
"deno": "./client.edge.js",
"worker": "./client.edge.js",
"node": "./client.node.js",
"edge-light": "./client.edge.js",
"browser": "./client.browser.js",
"default": "./client.browser.js"
},
"./client.browser": "./client.browser.js",
"./client.edge": "./client.edge.js",
"./client.node": "./client.node.js",
"./server": {
"react-server": {
"workerd": "./server.edge.js",
"deno": "./server.browser.js",
"node": "./server.node.js",
"edge-light": "./server.edge.js",
"browser": "./server.browser.js"
},
"default": "./server.js"
},
"./server.browser": "./server.browser.js",
"./server.edge": "./server.edge.js",
"./server.node": "./server.node.js",
"./src/*": "./src/*.js",
"./package.json": "./package.json"
},
"main": "index.js",
"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-server-dom-parcel"
},
"engines": {
"node": ">=0.10.0"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/server.browser.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './src/ReactFlightDOMServerBrowser';
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/server.edge.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './src/ReactFlightDOMServerEdge';
13 changes: 13 additions & 0 deletions packages/react-server-dom-parcel/server.js
@@ -0,0 +1,13 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

throw new Error(
'The React Server cannot be used outside a react-server environment. ' +
'You must configure Node.js using the `--conditions react-server` flag.',
);
10 changes: 10 additions & 0 deletions packages/react-server-dom-parcel/server.node.js
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './src/ReactFlightDOMServerNode';