mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Split out Edge and Node implementations of the Flight Client (#26187)
This splits out the Edge and Node implementations of Flight Client into their own implementations. The Node implementation now takes a Node Stream as input. I removed the bundler config from the Browser variant because you're never supposed to use that in the browser since it's only for SSR. Similarly, it's required on the server. This also enables generating a SSR manifest from the Webpack plugin. This is necessary for SSR so that you can reverse look up what a client module is called on the server. I also removed the option to pass a callServer from the server. We might want to add it back in the future but basically, we don't recommend calling Server Functions from render for initial render because if that happened client-side it would be a client-side waterfall. If it's never called in initial render, then it also shouldn't ever happen during SSR. This might be considered too restrictive. ~This also compiles the unbundled packages as ESM. This isn't strictly necessary because we only need access to dynamic import to load the modules but we don't have any other build options that leave `import(...)` intact, and seems appropriate that this would also be an ESM module.~ Went with `import(...)` in CJS instead.
This commit is contained in:
committed by
GitHub
parent
70b0bbda76
commit
60144a04da
@@ -19,6 +19,7 @@ const Sync = require('./sync');
|
||||
const sizes = require('./plugins/sizes-plugin');
|
||||
const useForks = require('./plugins/use-forks-plugin');
|
||||
const stripUnusedImports = require('./plugins/strip-unused-imports');
|
||||
const dynamicImports = require('./plugins/dynamic-imports');
|
||||
const Packaging = require('./packaging');
|
||||
const {asyncRimRaf} = require('./utils');
|
||||
const codeFrame = require('@babel/code-frame');
|
||||
@@ -45,7 +46,8 @@ process.on('unhandledRejection', err => {
|
||||
|
||||
const {
|
||||
NODE_ES2015,
|
||||
NODE_ESM,
|
||||
ESM_DEV,
|
||||
ESM_PROD,
|
||||
UMD_DEV,
|
||||
UMD_PROD,
|
||||
UMD_PROFILING,
|
||||
@@ -216,7 +218,8 @@ function getFormat(bundleType) {
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
return `cjs`;
|
||||
case NODE_ESM:
|
||||
case ESM_DEV:
|
||||
case ESM_PROD:
|
||||
return `es`;
|
||||
case BROWSER_SCRIPT:
|
||||
return `iife`;
|
||||
@@ -226,8 +229,8 @@ function getFormat(bundleType) {
|
||||
function isProductionBundleType(bundleType) {
|
||||
switch (bundleType) {
|
||||
case NODE_ES2015:
|
||||
case NODE_ESM:
|
||||
return true;
|
||||
case ESM_DEV:
|
||||
case UMD_DEV:
|
||||
case NODE_DEV:
|
||||
case BUN_DEV:
|
||||
@@ -235,6 +238,7 @@ function isProductionBundleType(bundleType) {
|
||||
case RN_OSS_DEV:
|
||||
case RN_FB_DEV:
|
||||
return false;
|
||||
case ESM_PROD:
|
||||
case UMD_PROD:
|
||||
case NODE_PROD:
|
||||
case BUN_PROD:
|
||||
@@ -256,7 +260,6 @@ function isProductionBundleType(bundleType) {
|
||||
function isProfilingBundleType(bundleType) {
|
||||
switch (bundleType) {
|
||||
case NODE_ES2015:
|
||||
case NODE_ESM:
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case NODE_DEV:
|
||||
@@ -267,6 +270,8 @@ function isProfilingBundleType(bundleType) {
|
||||
case RN_FB_PROD:
|
||||
case RN_OSS_DEV:
|
||||
case RN_OSS_PROD:
|
||||
case ESM_DEV:
|
||||
case ESM_PROD:
|
||||
case UMD_DEV:
|
||||
case UMD_PROD:
|
||||
case BROWSER_SCRIPT:
|
||||
@@ -328,6 +333,8 @@ function getPlugins(
|
||||
bundleType === RN_FB_PROFILING;
|
||||
const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput;
|
||||
return [
|
||||
// Keep dynamic imports as externals
|
||||
dynamicImports(),
|
||||
{
|
||||
name: 'rollup-plugin-flow-remove-types',
|
||||
transform(code) {
|
||||
@@ -385,7 +392,7 @@ function getPlugins(
|
||||
// Apply dead code elimination and/or minification.
|
||||
// closure doesn't yet support leaving ESM imports intact
|
||||
isProduction &&
|
||||
bundleType !== NODE_ESM &&
|
||||
bundleType !== ESM_PROD &&
|
||||
closure({
|
||||
compilation_level: 'SIMPLE',
|
||||
language_in: 'ECMASCRIPT_2020',
|
||||
@@ -396,7 +403,9 @@ function getPlugins(
|
||||
? 'ECMASCRIPT5'
|
||||
: 'ECMASCRIPT5_STRICT',
|
||||
emit_use_strict:
|
||||
bundleType !== BROWSER_SCRIPT && bundleType !== NODE_ESM,
|
||||
bundleType !== BROWSER_SCRIPT &&
|
||||
bundleType !== ESM_PROD &&
|
||||
bundleType !== ESM_DEV,
|
||||
env: 'CUSTOM',
|
||||
warning_level: 'QUIET',
|
||||
apply_input_source_maps: false,
|
||||
@@ -404,6 +413,7 @@ function getPlugins(
|
||||
process_common_js_modules: false,
|
||||
rewrite_polyfills: false,
|
||||
inject_libraries: false,
|
||||
allow_dynamic_import: true,
|
||||
|
||||
// Don't let it create global variables in the browser.
|
||||
// https://github.com/facebook/react/issues/10909
|
||||
@@ -740,7 +750,8 @@ async function buildEverything() {
|
||||
for (const bundle of Bundles.bundles) {
|
||||
bundles.push(
|
||||
[bundle, NODE_ES2015],
|
||||
[bundle, NODE_ESM],
|
||||
[bundle, ESM_DEV],
|
||||
[bundle, ESM_PROD],
|
||||
[bundle, UMD_DEV],
|
||||
[bundle, UMD_PROD],
|
||||
[bundle, UMD_PROFILING],
|
||||
|
||||
Reference in New Issue
Block a user