2017-04-05 16:47:29 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
2020-05-27 19:43:08 -07:00
|
|
|
const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL;
|
|
|
|
|
|
|
|
|
|
const __EXPERIMENTAL__ =
|
|
|
|
|
typeof RELEASE_CHANNEL === 'string'
|
|
|
|
|
? RELEASE_CHANNEL === 'experimental'
|
|
|
|
|
: true;
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
const bundleTypes = {
|
2020-05-28 15:56:34 -07:00
|
|
|
NODE_ES2015: 'NODE_ES2015',
|
2023-02-21 13:18:24 -05:00
|
|
|
ESM_DEV: 'ESM_DEV',
|
|
|
|
|
ESM_PROD: 'ESM_PROD',
|
2017-04-05 16:47:29 +01:00
|
|
|
NODE_DEV: 'NODE_DEV',
|
|
|
|
|
NODE_PROD: 'NODE_PROD',
|
2018-06-11 13:16:27 -07:00
|
|
|
NODE_PROFILING: 'NODE_PROFILING',
|
2022-11-17 13:15:56 -08:00
|
|
|
BUN_DEV: 'BUN_DEV',
|
|
|
|
|
BUN_PROD: 'BUN_PROD',
|
2018-04-18 13:16:50 -07:00
|
|
|
FB_WWW_DEV: 'FB_WWW_DEV',
|
|
|
|
|
FB_WWW_PROD: 'FB_WWW_PROD',
|
2018-06-26 13:28:41 -07:00
|
|
|
FB_WWW_PROFILING: 'FB_WWW_PROFILING',
|
2018-04-18 13:16:50 -07:00
|
|
|
RN_OSS_DEV: 'RN_OSS_DEV',
|
|
|
|
|
RN_OSS_PROD: 'RN_OSS_PROD',
|
2018-06-11 13:16:27 -07:00
|
|
|
RN_OSS_PROFILING: 'RN_OSS_PROFILING',
|
2018-04-18 13:16:50 -07:00
|
|
|
RN_FB_DEV: 'RN_FB_DEV',
|
|
|
|
|
RN_FB_PROD: 'RN_FB_PROD',
|
2018-06-26 13:28:41 -07:00
|
|
|
RN_FB_PROFILING: 'RN_FB_PROFILING',
|
2022-10-14 23:29:17 -04:00
|
|
|
BROWSER_SCRIPT: 'BROWSER_SCRIPT',
|
2025-02-16 09:38:13 -06:00
|
|
|
CJS_DTS: 'CJS_DTS',
|
|
|
|
|
ESM_DTS: 'ESM_DTS',
|
2017-04-05 16:47:29 +01:00
|
|
|
};
|
|
|
|
|
|
2019-04-25 17:24:01 +02:00
|
|
|
const {
|
2020-05-28 15:56:34 -07:00
|
|
|
NODE_ES2015,
|
2023-02-21 13:18:24 -05:00
|
|
|
ESM_DEV,
|
|
|
|
|
ESM_PROD,
|
2019-04-25 17:24:01 +02:00
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
NODE_PROFILING,
|
2022-11-17 13:15:56 -08:00
|
|
|
BUN_DEV,
|
|
|
|
|
BUN_PROD,
|
2019-04-25 17:24:01 +02:00
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
|
|
|
|
FB_WWW_PROFILING,
|
|
|
|
|
RN_OSS_DEV,
|
|
|
|
|
RN_OSS_PROD,
|
|
|
|
|
RN_OSS_PROFILING,
|
|
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
2022-10-14 23:29:17 -04:00
|
|
|
BROWSER_SCRIPT,
|
2025-02-16 09:38:13 -06:00
|
|
|
CJS_DTS,
|
|
|
|
|
ESM_DTS,
|
2019-04-25 17:24:01 +02:00
|
|
|
} = bundleTypes;
|
2017-04-05 16:47:29 +01:00
|
|
|
|
2017-10-11 14:29:26 -04:00
|
|
|
const moduleTypes = {
|
2019-04-25 17:24:01 +02:00
|
|
|
// React
|
2017-10-11 14:29:26 -04:00
|
|
|
ISOMORPHIC: 'ISOMORPHIC',
|
2019-04-25 17:24:01 +02:00
|
|
|
// Individual renderers. They bundle the reconciler. (e.g. ReactDOM)
|
2017-10-11 14:29:26 -04:00
|
|
|
RENDERER: 'RENDERER',
|
2019-04-25 17:24:01 +02:00
|
|
|
// Helper packages that access specific renderer's internals. (e.g. TestUtils)
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-19 19:50:24 +01:00
|
|
|
RENDERER_UTILS: 'RENDERER_UTILS',
|
2019-04-25 17:24:01 +02:00
|
|
|
// Standalone reconciler for third-party renderers.
|
2017-10-11 14:29:26 -04:00
|
|
|
RECONCILER: 'RECONCILER',
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-14 15:54:30 -04:00
|
|
|
const {ISOMORPHIC, RENDERER, RENDERER_UTILS, RECONCILER} = moduleTypes;
|
2017-10-11 14:29:26 -04:00
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
const bundles = [
|
|
|
|
|
/******* Isomorphic *******/
|
|
|
|
|
{
|
2018-04-18 13:16:50 -07:00
|
|
|
bundleTypes: [
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
2018-09-01 12:00:00 -07:00
|
|
|
FB_WWW_PROFILING,
|
2020-05-29 15:32:38 -07:00
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
2018-04-18 13:16:50 -07:00
|
|
|
],
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleType: ISOMORPHIC,
|
2017-10-25 02:55:00 +03:00
|
|
|
entry: 'react',
|
|
|
|
|
global: 'React',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2021-08-03 22:30:20 -04:00
|
|
|
externals: ['ReactNativeInternalFeatureFlags'],
|
2017-04-05 16:47:29 +01:00
|
|
|
},
|
|
|
|
|
|
2020-12-10 02:14:50 +00:00
|
|
|
/******* Isomorphic Shared Subset *******/
|
2020-11-20 11:47:13 -05:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
2024-01-16 19:58:11 -05:00
|
|
|
entry: 'react/src/ReactServer.js',
|
|
|
|
|
name: 'react.react-server',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2020-11-20 11:47:13 -05:00
|
|
|
global: 'React',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2020-11-20 11:47:13 -05:00
|
|
|
externals: [],
|
|
|
|
|
},
|
|
|
|
|
|
2020-03-17 13:22:19 -07:00
|
|
|
/******* React JSX Runtime *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
NODE_PROFILING,
|
2020-05-01 16:07:36 +01:00
|
|
|
// TODO: use on WWW.
|
2020-05-29 15:32:38 -07:00
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
2020-03-17 13:22:19 -07:00
|
|
|
],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'react/jsx-runtime',
|
|
|
|
|
global: 'JSXRuntime',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2021-08-03 22:30:20 -04:00
|
|
|
externals: ['react', 'ReactNativeInternalFeatureFlags'],
|
2020-03-17 13:22:19 -07:00
|
|
|
},
|
|
|
|
|
|
2024-04-30 12:00:22 -04:00
|
|
|
/******* Compiler Runtime *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, NODE_PROFILING],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'react/compiler-runtime',
|
|
|
|
|
global: 'CompilerRuntime',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2024-02-02 13:37:48 -08:00
|
|
|
/******* React JSX Runtime React Server *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'react/src/jsx/ReactJSXServer.js',
|
|
|
|
|
name: 'react-jsx-runtime.react-server',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2024-02-02 13:37:48 -08:00
|
|
|
global: 'JSXRuntime',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'ReactNativeInternalFeatureFlags'],
|
|
|
|
|
},
|
|
|
|
|
|
2020-03-17 13:22:19 -07:00
|
|
|
/******* React JSX DEV Runtime *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
NODE_PROFILING,
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
|
|
|
|
FB_WWW_PROFILING,
|
2020-05-29 15:32:38 -07:00
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
2020-03-17 13:22:19 -07:00
|
|
|
],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'react/jsx-dev-runtime',
|
|
|
|
|
global: 'JSXDEVRuntime',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2021-08-03 22:30:20 -04:00
|
|
|
externals: ['react', 'ReactNativeInternalFeatureFlags'],
|
2020-03-17 13:22:19 -07:00
|
|
|
},
|
|
|
|
|
|
2024-04-27 14:45:52 -05:00
|
|
|
/******* React JSX DEV Runtime React Server *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'react/src/jsx/ReactJSXServer.js',
|
|
|
|
|
name: 'react-jsx-dev-runtime.react-server',
|
|
|
|
|
condition: 'react-server',
|
|
|
|
|
global: 'JSXDEVRuntime',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'ReactNativeInternalFeatureFlags'],
|
|
|
|
|
},
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
/******* React DOM *******/
|
|
|
|
|
{
|
2024-04-24 08:50:32 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleType: RENDERER,
|
2017-10-25 02:55:00 +03:00
|
|
|
entry: 'react-dom',
|
|
|
|
|
global: 'ReactDOM',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2018-09-01 12:00:00 -07:00
|
|
|
externals: ['react'],
|
2017-04-19 16:45:31 -07:00
|
|
|
},
|
2024-09-18 14:44:55 -07:00
|
|
|
|
2024-04-24 08:50:32 -07:00
|
|
|
/******* React DOM Client *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/client',
|
|
|
|
|
global: 'ReactDOM',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: true,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React DOM Profiling (Client) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROFILING],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/profiling',
|
|
|
|
|
global: 'ReactDOM',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: true,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
2024-09-18 14:44:55 -07:00
|
|
|
|
|
|
|
|
/******* React DOM (www) *******/
|
2024-04-24 08:50:32 -07:00
|
|
|
{
|
|
|
|
|
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD, FB_WWW_PROFILING],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/src/ReactDOMFB.js',
|
|
|
|
|
global: 'ReactDOM',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: true,
|
|
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
2017-10-25 02:55:00 +03:00
|
|
|
|
2024-09-18 14:44:55 -07:00
|
|
|
/******* React DOM (fbsource) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom',
|
|
|
|
|
global: 'ReactDOM',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'ReactNativeInternalFeatureFlags'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React DOM Client (fbsource) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/client',
|
|
|
|
|
global: 'ReactDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom', 'ReactNativeInternalFeatureFlags'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React DOM Profiling (fbsource) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/profiling',
|
|
|
|
|
global: 'ReactDOMProfiling',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: true,
|
|
|
|
|
externals: ['react', 'react-dom', 'ReactNativeInternalFeatureFlags'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React DOM Test Utils (fbsource) *******/
|
|
|
|
|
{
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
|
|
|
|
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
|
|
|
|
|
entry: 'react-dom/test-utils',
|
|
|
|
|
global: 'ReactDOMTestUtils',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom', 'ReactNativeInternalFeatureFlags'],
|
|
|
|
|
},
|
|
|
|
|
|
2024-02-02 13:37:48 -08:00
|
|
|
/******* React DOM React Server *******/
|
2023-09-15 14:53:19 -04:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2024-04-24 08:50:32 -07:00
|
|
|
entry: 'react-dom/src/ReactDOMReactServer.js',
|
2024-01-16 19:58:11 -05:00
|
|
|
name: 'react-dom.react-server',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2023-09-15 14:53:19 -04:00
|
|
|
global: 'ReactDOM',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2018-11-30 11:52:34 +00:00
|
|
|
/******* Test Utils *******/
|
2017-04-19 16:45:31 -07:00
|
|
|
{
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-19 19:50:24 +01:00
|
|
|
moduleType: RENDERER_UTILS,
|
2024-05-28 19:55:14 +01:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2017-10-25 02:55:00 +03:00
|
|
|
entry: 'react-dom/test-utils',
|
|
|
|
|
global: 'ReactTestUtils',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2017-10-25 02:55:00 +03:00
|
|
|
externals: ['react', 'react-dom'],
|
2017-04-05 16:47:29 +01:00
|
|
|
},
|
2017-10-25 02:55:00 +03:00
|
|
|
|
2024-04-24 08:50:32 -07:00
|
|
|
/******* React DOM - Testing *******/
|
2020-02-03 23:31:31 +00:00
|
|
|
{
|
|
|
|
|
moduleType: RENDERER,
|
2024-04-24 08:50:32 -07:00
|
|
|
bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
|
2022-02-08 23:12:31 -05:00
|
|
|
entry: 'react-dom/unstable_testing',
|
2020-02-03 23:31:31 +00:00
|
|
|
global: 'ReactDOMTesting',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2024-04-24 08:50:32 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React DOM - www - Testing *******/
|
|
|
|
|
{
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD],
|
|
|
|
|
entry: 'react-dom/src/ReactDOMTestingFB.js',
|
|
|
|
|
global: 'ReactDOMTesting',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2020-02-03 23:31:31 +00:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
/******* React DOM Server *******/
|
2017-05-17 17:19:11 -07:00
|
|
|
{
|
2024-04-17 11:15:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
|
2021-06-14 15:54:30 -04:00
|
|
|
moduleType: RENDERER,
|
2022-02-09 11:37:17 -08:00
|
|
|
entry: 'react-dom/src/server/ReactDOMLegacyServerBrowser.js',
|
2021-06-14 19:23:19 -04:00
|
|
|
name: 'react-dom-server-legacy.browser',
|
2017-10-25 02:55:00 +03:00
|
|
|
global: 'ReactDOMServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2022-09-30 16:14:04 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
2019-08-08 17:46:35 -07:00
|
|
|
babel: opts =>
|
|
|
|
|
Object.assign({}, opts, {
|
|
|
|
|
plugins: opts.plugins.concat([
|
|
|
|
|
[require.resolve('@babel/plugin-transform-classes'), {loose: true}],
|
|
|
|
|
]),
|
|
|
|
|
}),
|
2017-04-05 16:47:29 +01:00
|
|
|
},
|
2017-06-24 22:31:42 -07:00
|
|
|
{
|
2017-06-28 16:13:58 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2021-06-14 15:54:30 -04:00
|
|
|
moduleType: RENDERER,
|
2022-02-09 11:37:17 -08:00
|
|
|
entry: 'react-dom/src/server/ReactDOMLegacyServerNode.js',
|
2021-06-14 19:23:19 -04:00
|
|
|
name: 'react-dom-server-legacy.node',
|
2022-09-30 16:14:04 -07:00
|
|
|
externals: ['react', 'stream', 'react-dom'],
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-08-08 17:46:35 -07:00
|
|
|
babel: opts =>
|
|
|
|
|
Object.assign({}, opts, {
|
|
|
|
|
plugins: opts.plugins.concat([
|
|
|
|
|
[require.resolve('@babel/plugin-transform-classes'), {loose: true}],
|
|
|
|
|
]),
|
|
|
|
|
}),
|
2017-06-24 22:31:42 -07:00
|
|
|
},
|
|
|
|
|
|
2018-11-30 11:38:22 -08:00
|
|
|
/******* React DOM Fizz Server *******/
|
|
|
|
|
{
|
2024-04-17 11:15:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2018-11-30 11:38:22 -08:00
|
|
|
moduleType: RENDERER,
|
2023-08-22 15:21:36 -04:00
|
|
|
entry: 'react-dom/src/server/react-dom-server.browser.js',
|
2021-06-14 19:23:19 -04:00
|
|
|
name: 'react-dom-server.browser',
|
|
|
|
|
global: 'ReactDOMServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2022-09-30 16:14:04 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
2018-11-30 11:38:22 -08:00
|
|
|
},
|
|
|
|
|
{
|
2021-06-02 16:13:19 +01:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2018-11-30 11:38:22 -08:00
|
|
|
moduleType: RENDERER,
|
2023-08-22 15:21:36 -04:00
|
|
|
entry: 'react-dom/src/server/react-dom-server.node.js',
|
2021-06-14 19:23:19 -04:00
|
|
|
name: 'react-dom-server.node',
|
|
|
|
|
global: 'ReactDOMServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'async_hooks',
|
|
|
|
|
'crypto',
|
|
|
|
|
'stream',
|
|
|
|
|
'util',
|
|
|
|
|
],
|
2018-11-30 11:38:22 -08:00
|
|
|
},
|
2021-04-22 19:54:29 -04:00
|
|
|
{
|
|
|
|
|
bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [],
|
|
|
|
|
moduleType: RENDERER,
|
2023-05-17 20:33:25 -04:00
|
|
|
entry: 'react-server-dom-fb/src/ReactDOMServerFB.js',
|
2021-12-14 16:19:19 -08:00
|
|
|
global: 'ReactDOMServerStreaming',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2022-09-30 16:14:04 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
2021-04-22 19:54:29 -04:00
|
|
|
},
|
2018-11-30 11:38:22 -08:00
|
|
|
|
2023-02-07 15:10:01 -05:00
|
|
|
/******* React DOM Fizz Server Edge *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2023-08-22 15:21:36 -04:00
|
|
|
entry: 'react-dom/src/server/react-dom-server.edge.js',
|
2023-02-07 15:10:01 -05:00
|
|
|
name: 'react-dom-server.edge', // 'node_modules/react/*.js',
|
|
|
|
|
|
|
|
|
|
global: 'ReactDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
|
2022-11-17 13:15:56 -08:00
|
|
|
/******* React DOM Fizz Server Bun *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [BUN_DEV, BUN_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2023-08-22 15:21:36 -04:00
|
|
|
entry: 'react-dom/src/server/react-dom-server.bun.js',
|
2022-11-17 13:15:56 -08:00
|
|
|
name: 'react-dom-server.bun', // 'node_modules/react/*.js',
|
|
|
|
|
|
|
|
|
|
global: 'ReactDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-10-28 09:06:45 +11:00
|
|
|
externals: ['react', 'react-dom', 'crypto', 'stream', 'util'],
|
2022-11-17 13:15:56 -08:00
|
|
|
},
|
|
|
|
|
|
2022-10-14 23:29:17 -04:00
|
|
|
/******* React DOM Fizz Server External Runtime *******/
|
|
|
|
|
{
|
2024-04-09 11:57:58 -07:00
|
|
|
bundleTypes: __EXPERIMENTAL__ ? [BROWSER_SCRIPT] : [],
|
2022-10-14 23:29:17 -04:00
|
|
|
moduleType: RENDERER,
|
[ServerRenderer] Move fizz external runtime implementation to react-dom-bindings (#25617)
<!--
Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.
Before submitting a pull request, please make sure the following is
done:
1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn debug-test --watch TestName`, open
`chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
10. If you haven't already, complete the CLA.
Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->
Following
[comment](https://github.com/facebook/react/pull/25437#discussion_r1010944983)
in #25437 , the external runtime implementation should be moved from
`react-dom` to `react-dom-bindings`.
I did have a question here:
I set the entrypoint to `react-dom/unstable_server-external-runtime.js`,
since a.) I was following #25436 as an example and b.)
`react-dom-bindings` was missing a `README.md` and `npm/`. This also
involved adding the external runtime to `package.json`.
However, the external runtime isn't really a `react-dom` entrypoint. Is
this change alright, or should I change the bundling code instead?
## How did you test this change?
<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
If you leave this empty, your PR will very likely be closed.
-->
2022-11-03 11:15:29 -04:00
|
|
|
entry: 'react-dom/unstable_server-external-runtime',
|
2022-10-14 23:29:17 -04:00
|
|
|
outputPath: 'unstable_server-external-runtime.js',
|
|
|
|
|
global: 'ReactDOMServerExternalRuntime',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: [],
|
|
|
|
|
},
|
|
|
|
|
|
2024-06-28 15:25:10 +02:00
|
|
|
/******* React HTML RSC *******/
|
2024-06-27 18:09:40 +02:00
|
|
|
{
|
2024-06-28 16:19:20 +02:00
|
|
|
bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
|
2024-06-27 18:09:40 +02:00
|
|
|
moduleType: RENDERER,
|
2024-08-14 19:22:44 +02:00
|
|
|
entry: 'react-markup/src/ReactMarkupServer.js',
|
|
|
|
|
name: 'react-markup.react-server',
|
2024-06-27 18:09:40 +02:00
|
|
|
condition: 'react-server',
|
2024-08-14 19:22:44 +02:00
|
|
|
global: 'ReactMarkup',
|
2024-06-27 18:09:40 +02:00
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2024-06-28 15:25:10 +02:00
|
|
|
/******* React HTML Client *******/
|
|
|
|
|
{
|
2024-06-28 16:19:20 +02:00
|
|
|
bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
|
2024-06-28 15:25:10 +02:00
|
|
|
moduleType: RENDERER,
|
2024-08-14 19:22:44 +02:00
|
|
|
entry: 'react-markup/src/ReactMarkupClient.js',
|
|
|
|
|
name: 'react-markup',
|
|
|
|
|
global: 'ReactMarkup',
|
2024-06-28 15:25:10 +02:00
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2022-10-18 10:15:52 -04:00
|
|
|
/******* React Server DOM Webpack Server *******/
|
2019-10-29 14:45:47 -07:00
|
|
|
{
|
2024-04-17 11:15:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2019-10-29 14:45:47 -07:00
|
|
|
moduleType: RENDERER,
|
2024-08-14 18:10:40 -07:00
|
|
|
entry:
|
|
|
|
|
'react-server-dom-webpack/src/server/react-flight-dom-server.browser',
|
|
|
|
|
name: 'react-server-dom-webpack-server.browser',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2022-10-18 10:15:52 -04:00
|
|
|
global: 'ReactServerDOMServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2022-09-30 16:14:04 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
2019-10-29 14:45:47 -07:00
|
|
|
},
|
|
|
|
|
{
|
2020-02-19 17:59:42 +00:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2019-10-29 14:45:47 -07:00
|
|
|
moduleType: RENDERER,
|
2024-08-14 18:10:40 -07:00
|
|
|
entry: 'react-server-dom-webpack/src/server/react-flight-dom-server.node',
|
|
|
|
|
name: 'react-server-dom-webpack-server.node',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2022-10-18 10:15:52 -04:00
|
|
|
global: 'ReactServerDOMServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'async_hooks',
|
|
|
|
|
'crypto',
|
|
|
|
|
'stream',
|
|
|
|
|
'util',
|
|
|
|
|
],
|
2019-10-29 14:45:47 -07:00
|
|
|
},
|
2023-02-07 15:10:01 -05:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2024-08-14 18:10:40 -07:00
|
|
|
entry: 'react-server-dom-webpack/src/server/react-flight-dom-server.edge',
|
|
|
|
|
name: 'react-server-dom-webpack-server.edge',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2023-02-07 15:10:01 -05:00
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: ['react'],
|
2023-02-07 15:10:01 -05:00
|
|
|
},
|
2019-10-29 14:45:47 -07:00
|
|
|
|
2022-10-18 10:15:52 -04:00
|
|
|
/******* React Server DOM Webpack Client *******/
|
2019-10-29 14:45:47 -07:00
|
|
|
{
|
2024-04-17 11:15:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2019-10-29 14:45:47 -07:00
|
|
|
moduleType: RENDERER,
|
2025-06-05 14:29:02 -04:00
|
|
|
entry:
|
|
|
|
|
'react-server-dom-webpack/src/client/react-flight-dom-client.browser',
|
|
|
|
|
name: 'react-server-dom-webpack-client.browser',
|
2023-02-16 11:01:52 -05:00
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2023-04-21 20:45:51 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
2023-02-16 11:01:52 -05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2025-06-05 14:29:02 -04:00
|
|
|
entry: 'react-server-dom-webpack/src/client/react-flight-dom-client.node',
|
|
|
|
|
name: 'react-server-dom-webpack-client.node',
|
2023-02-16 11:01:52 -05:00
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2023-09-20 17:13:14 -04:00
|
|
|
externals: ['react', 'react-dom', 'util', 'crypto'],
|
2023-02-16 11:01:52 -05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2025-06-05 14:29:02 -04:00
|
|
|
entry: 'react-server-dom-webpack/src/client/react-flight-dom-client.edge',
|
|
|
|
|
name: 'react-server-dom-webpack-client.edge',
|
2022-10-18 10:15:52 -04:00
|
|
|
global: 'ReactServerDOMClient',
|
2021-10-31 18:37:32 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2023-04-21 20:45:51 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
2019-10-29 14:45:47 -07:00
|
|
|
},
|
|
|
|
|
|
2020-12-08 08:08:57 -05:00
|
|
|
/******* React Server DOM Webpack Plugin *******/
|
2020-04-03 14:04:56 -07:00
|
|
|
{
|
2020-05-28 15:56:34 -07:00
|
|
|
bundleTypes: [NODE_ES2015],
|
2020-04-03 14:04:56 -07:00
|
|
|
moduleType: RENDERER_UTILS,
|
2020-12-08 08:08:57 -05:00
|
|
|
entry: 'react-server-dom-webpack/plugin',
|
|
|
|
|
global: 'ReactServerWebpackPlugin',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2020-12-07 12:10:18 -05:00
|
|
|
externals: ['fs', 'path', 'url', 'neo-async'],
|
2020-04-03 14:04:56 -07:00
|
|
|
},
|
|
|
|
|
|
2020-12-08 08:08:57 -05:00
|
|
|
/******* React Server DOM Webpack Node.js Loader *******/
|
2020-11-16 23:46:27 -05:00
|
|
|
{
|
2023-02-21 13:18:24 -05:00
|
|
|
bundleTypes: [ESM_PROD],
|
2020-11-16 23:46:27 -05:00
|
|
|
moduleType: RENDERER_UTILS,
|
2020-12-08 08:08:57 -05:00
|
|
|
entry: 'react-server-dom-webpack/node-loader',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2020-12-08 08:08:57 -05:00
|
|
|
global: 'ReactServerWebpackNodeLoader',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2020-11-30 17:37:27 -05:00
|
|
|
externals: ['acorn'],
|
2020-11-16 23:46:27 -05:00
|
|
|
},
|
|
|
|
|
|
2020-12-08 08:08:57 -05:00
|
|
|
/******* React Server DOM Webpack Node.js CommonJS Loader *******/
|
2020-11-16 23:46:27 -05:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_ES2015],
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
Update Rollup to 3.x (#26442)
<!--
Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.
Before submitting a pull request, please make sure the following is
done:
1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
10. If you haven't already, complete the CLA.
Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->
## Summary
This PR:
- Updates Rollup from 2.x to latest 3.x, and updates associated plugins
- Updates deprecated / altered config settings in the Rollup plugin
pipeline
- Fixes some file extension and import issues related to use of ESM in
`react-dom-webpack-server`
- Removes a now-obsolete `strip-unused-imports` Rollup plugin
- <s>Fixes an _existing_ bug with the Rollup 2.x plugin pipeline on
`main` that was causing parts of `DOMProperty.js` to get left out of the
`react-dom-webpack-server` JS bundles, by adding a new plugin to tell
Rollup to treat that file as if it as side effects</s>
This PR should be functionally identical to the other existing "Rollup 3
upgrade" PR at #26078 . I'm filing this as a near-duplicate because I'm
ready to push this change through ASAP so that I can follow it up with a
PR that adds sourcemap support, that PR's artifact diffing seems like
it's possibly stuck and I want to compare the build results, and I've
got this set up against latest `main`.
<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->
This gets React's build setup updated to the latest Rollup version,
which is generally a good practice, but also ensures that any further
Rollup config tweaks can be done using the current Rollup docs as a
reference.
## How did you test this change?
<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
If you leave this empty, your PR will very likely be closed.
-->
- Made builds from the latest `main`
- Updated Rollup package versions and cross-compared the changes I
needed to make locally to get successful builds vs #26078
- Diffed the output folders between `main` and this PR, and confirmed
that the bundle contents are identical (with the exception of version
strings and the `react-dom-webpack-server` bundle fix re-adding missing
`DOMProperty.js` content)
2023-03-24 14:08:41 -04:00
|
|
|
entry: 'react-server-dom-webpack/src/ReactFlightWebpackNodeRegister',
|
2022-08-24 19:05:39 -04:00
|
|
|
name: 'react-server-dom-webpack-node-register',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2020-11-16 23:46:27 -05:00
|
|
|
global: 'ReactFlightWebpackNodeRegister',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2023-07-07 11:09:45 -04:00
|
|
|
externals: ['url', 'module', 'react-server-dom-webpack/server'],
|
2020-11-16 23:46:27 -05:00
|
|
|
},
|
|
|
|
|
|
2023-09-27 10:03:57 -07:00
|
|
|
/******* React Server DOM Turbopack Server *******/
|
|
|
|
|
{
|
2024-04-17 11:15:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2023-09-27 10:03:57 -07:00
|
|
|
moduleType: RENDERER,
|
2024-08-14 18:10:40 -07:00
|
|
|
entry:
|
|
|
|
|
'react-server-dom-turbopack/src/server/react-flight-dom-server.browser',
|
|
|
|
|
name: 'react-server-dom-turbopack-server.browser',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2023-09-27 10:03:57 -07:00
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2024-08-14 18:10:40 -07:00
|
|
|
entry: 'react-server-dom-turbopack/src/server/react-flight-dom-server.node',
|
|
|
|
|
name: 'react-server-dom-turbopack-server.node',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2023-09-27 10:03:57 -07:00
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'async_hooks',
|
|
|
|
|
'crypto',
|
|
|
|
|
'stream',
|
|
|
|
|
'util',
|
|
|
|
|
],
|
2023-09-27 10:03:57 -07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2024-08-14 18:10:40 -07:00
|
|
|
entry: 'react-server-dom-turbopack/src/server/react-flight-dom-server.edge',
|
|
|
|
|
name: 'react-server-dom-turbopack-server.edge',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2023-09-27 10:03:57 -07:00
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: ['react'],
|
2023-09-27 10:03:57 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM Turbopack Client *******/
|
|
|
|
|
{
|
2024-04-17 11:15:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2023-09-27 10:03:57 -07:00
|
|
|
moduleType: RENDERER,
|
2025-06-06 11:07:40 -04:00
|
|
|
entry:
|
|
|
|
|
'react-server-dom-turbopack/src/client/react-flight-dom-client.browser',
|
|
|
|
|
name: 'react-server-dom-turbopack-client.browser',
|
2023-09-27 10:03:57 -07:00
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2025-06-06 11:07:40 -04:00
|
|
|
entry: 'react-server-dom-turbopack/src/client/react-flight-dom-client.node',
|
|
|
|
|
name: 'react-server-dom-turbopack-client.node',
|
|
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom', 'util'],
|
|
|
|
|
},
|
2023-09-27 10:03:57 -07:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2025-06-06 11:07:40 -04:00
|
|
|
entry: 'react-server-dom-turbopack/src/client/react-flight-dom-client.edge',
|
|
|
|
|
name: 'react-server-dom-turbopack-client.edge',
|
2023-09-27 10:03:57 -07:00
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
Implement react-server-dom-parcel (#31725)
This adds a new `react-server-dom-parcel-package`, which is an RSC
integration for the Parcel bundler. It is mostly copied from the
existing webpack/turbopack integrations, with some changes to utilize
Parcel runtime APIs for loading and executing bundles/modules.
See https://github.com/parcel-bundler/parcel/pull/10043 for the Parcel
side of this, which includes the plugin needed to generate client and
server references. https://github.com/parcel-bundler/rsc-examples also
includes examples of various ways to use RSCs with Parcel.
Differences from other integrations:
* Client and server modules are all part of the same graph, and we use
Parcel's
[environments](https://parceljs.org/plugin-system/transformer/#the-environment)
to distinguish them. The server is the Parcel build entry point, and it
imports and renders server components in route handlers. When a `"use
client"` directive is seen, the environment changes and Parcel creates a
new client bundle for the page, combining all client modules together.
CSS from both client and server components are also combined
automatically.
* There is no separate manifest file that needs to be passed around by
the user. A [Runtime](https://parceljs.org/plugin-system/runtime/)
plugin injects client and server references as needed into the relevant
bundles, and registers server action ids using `react-server-dom-parcel`
automatically.
* A special `<Resources>` component is also generated by Parcel to
render the `<script>` and `<link rel="stylesheet">` elements needed for
a page, using the relevant info from the bundle graph.
Note: I've already published a 0.0.x version of this package to npm for
testing purposes but happy to add whoever needs access to it as well.
### Questions
* How to test this in the React repo. I'll have integration tests in
Parcel, but setting up all the different mocks and environments to
simulate that here seems challenging. I could try to copy how
Webpack/Turbopack do it but it's a bit different.
* Where to put TypeScript types. Right now I have some ambient types in
my [example
repo](https://github.com/parcel-bundler/rsc-examples/blob/main/types.d.ts)
but it would be nice for users not to copy and paste these. Can I
include them in the package or do they need to maintained separately in
definitelytyped? I would really prefer not to have to maintain code in
three different repos ideally.
---------
Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu>
2024-12-11 22:58:51 -05:00
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM Parcel Server *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-server-dom-parcel/src/server/react-flight-dom-server.browser',
|
|
|
|
|
name: 'react-server-dom-parcel-server.browser',
|
|
|
|
|
condition: 'react-server',
|
|
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-server-dom-parcel/src/server/react-flight-dom-server.node',
|
|
|
|
|
name: 'react-server-dom-parcel-server.node',
|
|
|
|
|
condition: 'react-server',
|
|
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'async_hooks',
|
|
|
|
|
'crypto',
|
|
|
|
|
'stream',
|
|
|
|
|
'util',
|
|
|
|
|
],
|
Implement react-server-dom-parcel (#31725)
This adds a new `react-server-dom-parcel-package`, which is an RSC
integration for the Parcel bundler. It is mostly copied from the
existing webpack/turbopack integrations, with some changes to utilize
Parcel runtime APIs for loading and executing bundles/modules.
See https://github.com/parcel-bundler/parcel/pull/10043 for the Parcel
side of this, which includes the plugin needed to generate client and
server references. https://github.com/parcel-bundler/rsc-examples also
includes examples of various ways to use RSCs with Parcel.
Differences from other integrations:
* Client and server modules are all part of the same graph, and we use
Parcel's
[environments](https://parceljs.org/plugin-system/transformer/#the-environment)
to distinguish them. The server is the Parcel build entry point, and it
imports and renders server components in route handlers. When a `"use
client"` directive is seen, the environment changes and Parcel creates a
new client bundle for the page, combining all client modules together.
CSS from both client and server components are also combined
automatically.
* There is no separate manifest file that needs to be passed around by
the user. A [Runtime](https://parceljs.org/plugin-system/runtime/)
plugin injects client and server references as needed into the relevant
bundles, and registers server action ids using `react-server-dom-parcel`
automatically.
* A special `<Resources>` component is also generated by Parcel to
render the `<script>` and `<link rel="stylesheet">` elements needed for
a page, using the relevant info from the bundle graph.
Note: I've already published a 0.0.x version of this package to npm for
testing purposes but happy to add whoever needs access to it as well.
### Questions
* How to test this in the React repo. I'll have integration tests in
Parcel, but setting up all the different mocks and environments to
simulate that here seems challenging. I could try to copy how
Webpack/Turbopack do it but it's a bit different.
* Where to put TypeScript types. Right now I have some ambient types in
my [example
repo](https://github.com/parcel-bundler/rsc-examples/blob/main/types.d.ts)
but it would be nice for users not to copy and paste these. Can I
include them in the package or do they need to maintained separately in
definitelytyped? I would really prefer not to have to maintain code in
three different repos ideally.
---------
Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu>
2024-12-11 22:58:51 -05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-server-dom-parcel/src/server/react-flight-dom-server.edge',
|
|
|
|
|
name: 'react-server-dom-parcel-server.edge',
|
|
|
|
|
condition: 'react-server',
|
|
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: ['react', 'react-dom'],
|
Implement react-server-dom-parcel (#31725)
This adds a new `react-server-dom-parcel-package`, which is an RSC
integration for the Parcel bundler. It is mostly copied from the
existing webpack/turbopack integrations, with some changes to utilize
Parcel runtime APIs for loading and executing bundles/modules.
See https://github.com/parcel-bundler/parcel/pull/10043 for the Parcel
side of this, which includes the plugin needed to generate client and
server references. https://github.com/parcel-bundler/rsc-examples also
includes examples of various ways to use RSCs with Parcel.
Differences from other integrations:
* Client and server modules are all part of the same graph, and we use
Parcel's
[environments](https://parceljs.org/plugin-system/transformer/#the-environment)
to distinguish them. The server is the Parcel build entry point, and it
imports and renders server components in route handlers. When a `"use
client"` directive is seen, the environment changes and Parcel creates a
new client bundle for the page, combining all client modules together.
CSS from both client and server components are also combined
automatically.
* There is no separate manifest file that needs to be passed around by
the user. A [Runtime](https://parceljs.org/plugin-system/runtime/)
plugin injects client and server references as needed into the relevant
bundles, and registers server action ids using `react-server-dom-parcel`
automatically.
* A special `<Resources>` component is also generated by Parcel to
render the `<script>` and `<link rel="stylesheet">` elements needed for
a page, using the relevant info from the bundle graph.
Note: I've already published a 0.0.x version of this package to npm for
testing purposes but happy to add whoever needs access to it as well.
### Questions
* How to test this in the React repo. I'll have integration tests in
Parcel, but setting up all the different mocks and environments to
simulate that here seems challenging. I could try to copy how
Webpack/Turbopack do it but it's a bit different.
* Where to put TypeScript types. Right now I have some ambient types in
my [example
repo](https://github.com/parcel-bundler/rsc-examples/blob/main/types.d.ts)
but it would be nice for users not to copy and paste these. Can I
include them in the package or do they need to maintained separately in
definitelytyped? I would really prefer not to have to maintain code in
three different repos ideally.
---------
Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu>
2024-12-11 22:58:51 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM Parcel Client *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2025-06-06 11:07:40 -04:00
|
|
|
entry: 'react-server-dom-parcel/src/client/react-flight-dom-client.browser',
|
|
|
|
|
name: 'react-server-dom-parcel-client.browser',
|
Implement react-server-dom-parcel (#31725)
This adds a new `react-server-dom-parcel-package`, which is an RSC
integration for the Parcel bundler. It is mostly copied from the
existing webpack/turbopack integrations, with some changes to utilize
Parcel runtime APIs for loading and executing bundles/modules.
See https://github.com/parcel-bundler/parcel/pull/10043 for the Parcel
side of this, which includes the plugin needed to generate client and
server references. https://github.com/parcel-bundler/rsc-examples also
includes examples of various ways to use RSCs with Parcel.
Differences from other integrations:
* Client and server modules are all part of the same graph, and we use
Parcel's
[environments](https://parceljs.org/plugin-system/transformer/#the-environment)
to distinguish them. The server is the Parcel build entry point, and it
imports and renders server components in route handlers. When a `"use
client"` directive is seen, the environment changes and Parcel creates a
new client bundle for the page, combining all client modules together.
CSS from both client and server components are also combined
automatically.
* There is no separate manifest file that needs to be passed around by
the user. A [Runtime](https://parceljs.org/plugin-system/runtime/)
plugin injects client and server references as needed into the relevant
bundles, and registers server action ids using `react-server-dom-parcel`
automatically.
* A special `<Resources>` component is also generated by Parcel to
render the `<script>` and `<link rel="stylesheet">` elements needed for
a page, using the relevant info from the bundle graph.
Note: I've already published a 0.0.x version of this package to npm for
testing purposes but happy to add whoever needs access to it as well.
### Questions
* How to test this in the React repo. I'll have integration tests in
Parcel, but setting up all the different mocks and environments to
simulate that here seems challenging. I could try to copy how
Webpack/Turbopack do it but it's a bit different.
* Where to put TypeScript types. Right now I have some ambient types in
my [example
repo](https://github.com/parcel-bundler/rsc-examples/blob/main/types.d.ts)
but it would be nice for users not to copy and paste these. Can I
include them in the package or do they need to maintained separately in
definitelytyped? I would really prefer not to have to maintain code in
three different repos ideally.
---------
Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu>
2024-12-11 22:58:51 -05:00
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2025-06-06 11:07:40 -04:00
|
|
|
entry: 'react-server-dom-parcel/src/client/react-flight-dom-client.node',
|
|
|
|
|
name: 'react-server-dom-parcel-client.node',
|
Implement react-server-dom-parcel (#31725)
This adds a new `react-server-dom-parcel-package`, which is an RSC
integration for the Parcel bundler. It is mostly copied from the
existing webpack/turbopack integrations, with some changes to utilize
Parcel runtime APIs for loading and executing bundles/modules.
See https://github.com/parcel-bundler/parcel/pull/10043 for the Parcel
side of this, which includes the plugin needed to generate client and
server references. https://github.com/parcel-bundler/rsc-examples also
includes examples of various ways to use RSCs with Parcel.
Differences from other integrations:
* Client and server modules are all part of the same graph, and we use
Parcel's
[environments](https://parceljs.org/plugin-system/transformer/#the-environment)
to distinguish them. The server is the Parcel build entry point, and it
imports and renders server components in route handlers. When a `"use
client"` directive is seen, the environment changes and Parcel creates a
new client bundle for the page, combining all client modules together.
CSS from both client and server components are also combined
automatically.
* There is no separate manifest file that needs to be passed around by
the user. A [Runtime](https://parceljs.org/plugin-system/runtime/)
plugin injects client and server references as needed into the relevant
bundles, and registers server action ids using `react-server-dom-parcel`
automatically.
* A special `<Resources>` component is also generated by Parcel to
render the `<script>` and `<link rel="stylesheet">` elements needed for
a page, using the relevant info from the bundle graph.
Note: I've already published a 0.0.x version of this package to npm for
testing purposes but happy to add whoever needs access to it as well.
### Questions
* How to test this in the React repo. I'll have integration tests in
Parcel, but setting up all the different mocks and environments to
simulate that here seems challenging. I could try to copy how
Webpack/Turbopack do it but it's a bit different.
* Where to put TypeScript types. Right now I have some ambient types in
my [example
repo](https://github.com/parcel-bundler/rsc-examples/blob/main/types.d.ts)
but it would be nice for users not to copy and paste these. Can I
include them in the package or do they need to maintained separately in
definitelytyped? I would really prefer not to have to maintain code in
three different repos ideally.
---------
Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu>
2024-12-11 22:58:51 -05:00
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom', 'util'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2025-06-06 11:07:40 -04:00
|
|
|
entry: 'react-server-dom-parcel/src/client/react-flight-dom-client.edge',
|
|
|
|
|
name: 'react-server-dom-parcel-client.edge',
|
Implement react-server-dom-parcel (#31725)
This adds a new `react-server-dom-parcel-package`, which is an RSC
integration for the Parcel bundler. It is mostly copied from the
existing webpack/turbopack integrations, with some changes to utilize
Parcel runtime APIs for loading and executing bundles/modules.
See https://github.com/parcel-bundler/parcel/pull/10043 for the Parcel
side of this, which includes the plugin needed to generate client and
server references. https://github.com/parcel-bundler/rsc-examples also
includes examples of various ways to use RSCs with Parcel.
Differences from other integrations:
* Client and server modules are all part of the same graph, and we use
Parcel's
[environments](https://parceljs.org/plugin-system/transformer/#the-environment)
to distinguish them. The server is the Parcel build entry point, and it
imports and renders server components in route handlers. When a `"use
client"` directive is seen, the environment changes and Parcel creates a
new client bundle for the page, combining all client modules together.
CSS from both client and server components are also combined
automatically.
* There is no separate manifest file that needs to be passed around by
the user. A [Runtime](https://parceljs.org/plugin-system/runtime/)
plugin injects client and server references as needed into the relevant
bundles, and registers server action ids using `react-server-dom-parcel`
automatically.
* A special `<Resources>` component is also generated by Parcel to
render the `<script>` and `<link rel="stylesheet">` elements needed for
a page, using the relevant info from the bundle graph.
Note: I've already published a 0.0.x version of this package to npm for
testing purposes but happy to add whoever needs access to it as well.
### Questions
* How to test this in the React repo. I'll have integration tests in
Parcel, but setting up all the different mocks and environments to
simulate that here seems challenging. I could try to copy how
Webpack/Turbopack do it but it's a bit different.
* Where to put TypeScript types. Right now I have some ambient types in
my [example
repo](https://github.com/parcel-bundler/rsc-examples/blob/main/types.d.ts)
but it would be nice for users not to copy and paste these. Can I
include them in the package or do they need to maintained separately in
definitelytyped? I would really prefer not to have to maintain code in
three different repos ideally.
---------
Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu>
2024-12-11 22:58:51 -05:00
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
2023-09-27 10:03:57 -07:00
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
|
2023-06-03 15:58:24 -04:00
|
|
|
/******* React Server DOM ESM Server *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2024-08-14 18:10:40 -07:00
|
|
|
entry: 'react-server-dom-esm/src/server/react-flight-dom-server.node',
|
|
|
|
|
name: 'react-server-dom-esm-server.node',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2023-06-03 15:58:24 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'async_hooks',
|
|
|
|
|
'crypto',
|
|
|
|
|
'stream',
|
|
|
|
|
'util',
|
|
|
|
|
],
|
2023-06-03 15:58:24 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM ESM Client *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, ESM_DEV, ESM_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-server-dom-esm/client.browser',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-server-dom-esm/client.node',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2025-08-25 09:39:56 +02:00
|
|
|
externals: ['react', 'react-dom', 'util'],
|
2023-06-03 15:58:24 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM ESM Node.js Loader *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [ESM_PROD],
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
|
|
|
|
entry: 'react-server-dom-esm/node-loader',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2023-06-03 15:58:24 -04:00
|
|
|
global: 'ReactServerESMNodeLoader',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['acorn'],
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-05 03:59:21 +01:00
|
|
|
/******* React Server DOM Unbundled Server *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-server-dom-unbundled/src/server/react-flight-dom-server.node',
|
|
|
|
|
name: 'react-server-dom-unbundled-server.node',
|
|
|
|
|
condition: 'react-server',
|
|
|
|
|
global: 'ReactServerDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'async_hooks',
|
|
|
|
|
'crypto',
|
|
|
|
|
'stream',
|
|
|
|
|
'util',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM Unbundled Client *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-server-dom-unbundled/src/client/react-flight-dom-client.node',
|
|
|
|
|
name: 'react-server-dom-unbundled-client.node',
|
|
|
|
|
global: 'ReactServerDOMClient',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom', 'util', 'crypto'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM Unbundled Node.js Loader *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [ESM_PROD],
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
|
|
|
|
entry: 'react-server-dom-unbundled/node-loader',
|
|
|
|
|
condition: 'react-server',
|
|
|
|
|
global: 'ReactServerUnbundledNodeLoader',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['acorn'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Server DOM Unbundled Node.js CommonJS Loader *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_ES2015],
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
|
|
|
|
entry: 'react-server-dom-unbundled/src/ReactFlightUnbundledNodeRegister',
|
|
|
|
|
name: 'react-server-dom-unbundled-node-register',
|
|
|
|
|
condition: 'react-server',
|
|
|
|
|
global: 'ReactFlightUnbundledNodeRegister',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['url', 'module', 'react-server-dom-unbundled/server'],
|
|
|
|
|
},
|
|
|
|
|
|
2020-12-03 03:44:56 +00:00
|
|
|
/******* React Suspense Test Utils *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_ES2015],
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
|
|
|
|
entry: 'react-suspense-test-utils',
|
|
|
|
|
global: 'ReactSuspenseTestUtils',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2020-12-03 03:44:56 +00:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
/******* React ART *******/
|
|
|
|
|
{
|
2024-04-17 11:15:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleType: RENDERER,
|
2017-10-25 02:55:00 +03:00
|
|
|
entry: 'react-art',
|
|
|
|
|
global: 'ReactART',
|
|
|
|
|
externals: ['react'],
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2017-10-25 02:55:00 +03:00
|
|
|
babel: opts =>
|
|
|
|
|
Object.assign({}, opts, {
|
|
|
|
|
// Include JSX
|
2019-08-08 17:46:35 -07:00
|
|
|
presets: opts.presets.concat([
|
|
|
|
|
require.resolve('@babel/preset-react'),
|
|
|
|
|
require.resolve('@babel/preset-flow'),
|
|
|
|
|
]),
|
|
|
|
|
plugins: opts.plugins.concat([
|
|
|
|
|
[require.resolve('@babel/plugin-transform-classes'), {loose: true}],
|
|
|
|
|
]),
|
2017-10-25 02:55:00 +03:00
|
|
|
}),
|
2017-04-05 16:47:29 +01:00
|
|
|
},
|
|
|
|
|
|
2018-01-22 09:58:35 -08:00
|
|
|
/******* React Native Fabric *******/
|
2018-04-18 13:16:50 -07:00
|
|
|
{
|
2020-05-28 15:04:25 -07:00
|
|
|
bundleTypes: __EXPERIMENTAL__
|
2020-07-20 17:15:06 -04:00
|
|
|
? []
|
|
|
|
|
: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
|
2018-04-18 13:16:50 -07:00
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-native-renderer/fabric',
|
|
|
|
|
global: 'ReactFabric',
|
2021-08-03 22:30:20 -04:00
|
|
|
externals: ['react-native', 'ReactNativeInternalFeatureFlags'],
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2019-08-08 17:46:35 -07:00
|
|
|
babel: opts =>
|
|
|
|
|
Object.assign({}, opts, {
|
|
|
|
|
plugins: opts.plugins.concat([
|
|
|
|
|
[require.resolve('@babel/plugin-transform-classes'), {loose: true}],
|
|
|
|
|
]),
|
|
|
|
|
}),
|
2018-04-18 13:16:50 -07:00
|
|
|
},
|
2018-01-22 09:58:35 -08:00
|
|
|
{
|
2018-06-11 13:16:27 -07:00
|
|
|
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
|
2018-01-22 09:58:35 -08:00
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-native-renderer/fabric',
|
|
|
|
|
global: 'ReactFabric',
|
2025-01-15 10:20:44 -06:00
|
|
|
// ReactNativeInternalFeatureFlags temporary until we land enableRemoveConsolePatches.
|
|
|
|
|
// Needs to be done before the next RN OSS release.
|
|
|
|
|
externals: ['react-native', 'ReactNativeInternalFeatureFlags'],
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2019-08-08 17:46:35 -07:00
|
|
|
babel: opts =>
|
|
|
|
|
Object.assign({}, opts, {
|
|
|
|
|
plugins: opts.plugins.concat([
|
|
|
|
|
[require.resolve('@babel/plugin-transform-classes'), {loose: true}],
|
|
|
|
|
]),
|
|
|
|
|
}),
|
2018-01-22 09:58:35 -08:00
|
|
|
},
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
/******* React Test Renderer *******/
|
|
|
|
|
{
|
2020-05-29 15:32:38 -07:00
|
|
|
bundleTypes: [
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
RN_FB_DEV,
|
2020-07-20 17:15:06 -04:00
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
2020-05-29 15:32:38 -07:00
|
|
|
],
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleType: RENDERER,
|
2017-10-25 02:55:00 +03:00
|
|
|
entry: 'react-test-renderer',
|
|
|
|
|
global: 'ReactTestRenderer',
|
2021-08-03 22:30:20 -04:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'scheduler',
|
|
|
|
|
'scheduler/unstable_mock',
|
|
|
|
|
'ReactNativeInternalFeatureFlags',
|
|
|
|
|
],
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-08-08 17:46:35 -07:00
|
|
|
babel: opts =>
|
|
|
|
|
Object.assign({}, opts, {
|
|
|
|
|
plugins: opts.plugins.concat([
|
|
|
|
|
[require.resolve('@babel/plugin-transform-classes'), {loose: true}],
|
|
|
|
|
]),
|
|
|
|
|
}),
|
2017-04-19 16:45:31 -07:00
|
|
|
},
|
2017-04-05 16:47:29 +01:00
|
|
|
|
2017-11-23 17:44:58 +00:00
|
|
|
/******* React Noop Renderer (used for tests) *******/
|
2017-04-05 16:47:29 +01:00
|
|
|
{
|
2017-11-23 17:44:58 +00:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleType: RENDERER,
|
2017-10-25 02:55:00 +03:00
|
|
|
entry: 'react-noop-renderer',
|
|
|
|
|
global: 'ReactNoopRenderer',
|
2021-10-31 18:37:32 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-02-28 12:54:47 -08:00
|
|
|
externals: ['react', 'scheduler', 'scheduler/unstable_mock', 'expect'],
|
2018-05-14 13:57:33 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Noop Persistent Renderer (used for tests) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-noop-renderer/persistent',
|
|
|
|
|
global: 'ReactNoopRendererPersistent',
|
2021-10-31 18:37:32 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-02-28 12:54:47 -08:00
|
|
|
externals: ['react', 'scheduler', 'expect'],
|
2017-04-05 16:47:29 +01:00
|
|
|
},
|
2017-10-11 14:29:26 -04:00
|
|
|
|
2018-11-30 11:38:22 -08:00
|
|
|
/******* React Noop Server Renderer (used for tests) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-noop-renderer/server',
|
|
|
|
|
global: 'ReactNoopRendererServer',
|
2021-10-31 18:37:32 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-02-28 12:54:47 -08:00
|
|
|
externals: ['react', 'scheduler', 'expect'],
|
2018-11-30 11:38:22 -08:00
|
|
|
},
|
|
|
|
|
|
2019-10-29 14:45:47 -07:00
|
|
|
/******* React Noop Flight Server (used for tests) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-noop-renderer/flight-server',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2019-10-29 14:45:47 -07:00
|
|
|
global: 'ReactNoopFlightServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2020-03-23 17:53:45 -07:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'scheduler',
|
|
|
|
|
'expect',
|
|
|
|
|
'react-noop-renderer/flight-modules',
|
|
|
|
|
],
|
2019-10-29 14:45:47 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Noop Flight Client (used for tests) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-noop-renderer/flight-client',
|
|
|
|
|
global: 'ReactNoopFlightClient',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2020-03-23 17:53:45 -07:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'scheduler',
|
|
|
|
|
'expect',
|
|
|
|
|
'react-noop-renderer/flight-modules',
|
|
|
|
|
],
|
2019-10-29 14:45:47 -07:00
|
|
|
},
|
|
|
|
|
|
2017-10-11 14:29:26 -04:00
|
|
|
/******* React Reconciler *******/
|
|
|
|
|
{
|
2024-04-19 18:06:01 -04:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, NODE_PROFILING, FB_WWW_DEV, FB_WWW_PROD],
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleType: RECONCILER,
|
2017-10-25 02:55:00 +03:00
|
|
|
entry: 'react-reconciler',
|
|
|
|
|
global: 'ReactReconciler',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2018-09-01 12:00:00 -07:00
|
|
|
externals: ['react'],
|
2018-02-05 16:56:21 +00:00
|
|
|
},
|
|
|
|
|
|
2019-10-29 14:45:47 -07:00
|
|
|
/******* React Server *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RECONCILER,
|
|
|
|
|
entry: 'react-server',
|
|
|
|
|
global: 'ReactServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-10-29 14:45:47 -07:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Flight Server *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RECONCILER,
|
|
|
|
|
entry: 'react-server/flight',
|
2024-04-08 22:34:59 -04:00
|
|
|
condition: 'react-server',
|
2019-10-29 14:45:47 -07:00
|
|
|
global: 'ReactFlightServer',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-10-29 14:45:47 -07:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Flight Client *******/
|
2018-11-30 11:38:22 -08:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: RECONCILER,
|
2020-03-07 11:23:30 -08:00
|
|
|
entry: 'react-client/flight',
|
2019-10-29 14:45:47 -07:00
|
|
|
global: 'ReactFlightClient',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2018-11-30 11:38:22 -08:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2021-03-24 02:13:43 +00:00
|
|
|
/******* Reconciler Reflection *******/
|
2017-11-29 00:57:22 +08:00
|
|
|
{
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
entry: 'react-reconciler/reflection',
|
|
|
|
|
global: 'ReactFiberTreeReflection',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2017-11-29 00:57:22 +08:00
|
|
|
externals: [],
|
|
|
|
|
},
|
|
|
|
|
|
2021-03-24 02:13:43 +00:00
|
|
|
/******* Reconciler Constants *******/
|
|
|
|
|
{
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
2024-05-06 11:32:43 -04:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
|
2021-03-24 02:13:43 +00:00
|
|
|
entry: 'react-reconciler/constants',
|
|
|
|
|
global: 'ReactReconcilerConstants',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2021-03-24 02:13:43 +00:00
|
|
|
externals: [],
|
|
|
|
|
},
|
|
|
|
|
|
2018-02-11 14:08:40 -08:00
|
|
|
/******* React Is *******/
|
|
|
|
|
{
|
2018-04-18 13:16:50 -07:00
|
|
|
bundleTypes: [
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
2022-01-12 21:53:50 +00:00
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
2018-04-18 13:16:50 -07:00
|
|
|
],
|
2018-02-11 14:08:40 -08:00
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'react-is',
|
|
|
|
|
global: 'ReactIs',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2022-01-12 21:53:50 +00:00
|
|
|
externals: ['ReactNativeInternalFeatureFlags'],
|
2018-02-11 14:08:40 -08:00
|
|
|
},
|
2018-02-15 16:38:15 -08:00
|
|
|
|
2018-11-05 10:02:59 -08:00
|
|
|
/******* React Debug Tools *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'react-debug-tools',
|
|
|
|
|
global: 'ReactDebugTools',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2018-11-05 10:02:59 -08:00
|
|
|
externals: [],
|
|
|
|
|
},
|
|
|
|
|
|
2020-04-29 19:14:15 +01:00
|
|
|
/******* React Cache (experimental, old) *******/
|
2018-02-15 16:38:15 -08:00
|
|
|
{
|
2024-04-18 17:26:03 -04:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
|
2018-02-15 16:38:15 -08:00
|
|
|
moduleType: ISOMORPHIC,
|
2018-10-01 09:07:40 -06:00
|
|
|
entry: 'react-cache',
|
2020-05-01 16:07:36 +01:00
|
|
|
global: 'ReactCacheOld',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2018-10-23 14:38:51 -07:00
|
|
|
externals: ['react', 'scheduler'],
|
2018-02-15 16:38:15 -08:00
|
|
|
},
|
2018-03-13 13:59:09 -07:00
|
|
|
|
2019-08-08 18:52:08 -07:00
|
|
|
/******* Hook for managing subscriptions safely *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'use-subscription',
|
|
|
|
|
global: 'useSubscription',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2019-08-08 18:52:08 -07:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2021-10-31 18:38:03 -04:00
|
|
|
/******* useSyncExternalStore *******/
|
2021-08-28 16:57:47 -04:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'use-sync-external-store',
|
|
|
|
|
global: 'useSyncExternalStore',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2021-08-28 16:57:47 -04:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
2021-10-31 18:38:03 -04:00
|
|
|
/******* useSyncExternalStore (shim) *******/
|
2021-09-01 20:52:38 -04:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
2021-10-31 18:38:03 -04:00
|
|
|
entry: 'use-sync-external-store/shim',
|
|
|
|
|
global: 'useSyncExternalStore',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2021-10-31 18:38:03 -04:00
|
|
|
externals: ['react'],
|
2021-09-01 20:52:38 -04:00
|
|
|
},
|
|
|
|
|
|
2021-10-31 18:38:03 -04:00
|
|
|
/******* useSyncExternalStore (shim, native) *******/
|
2021-09-21 11:07:56 -04:00
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
2021-10-31 18:38:03 -04:00
|
|
|
entry: 'use-sync-external-store/shim/index.native',
|
|
|
|
|
global: 'useSyncExternalStore',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2021-10-31 18:38:03 -04:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* useSyncExternalStoreWithSelector *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'use-sync-external-store/with-selector',
|
|
|
|
|
global: 'useSyncExternalStoreWithSelector',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: true,
|
|
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* useSyncExternalStoreWithSelector (shim) *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'use-sync-external-store/shim/with-selector',
|
|
|
|
|
global: 'useSyncExternalStoreWithSelector',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: true,
|
|
|
|
|
externals: ['react', 'use-sync-external-store/shim'],
|
2021-09-21 11:07:56 -04:00
|
|
|
},
|
|
|
|
|
|
2018-04-19 09:29:08 -07:00
|
|
|
/******* React Scheduler (experimental) *******/
|
|
|
|
|
{
|
2019-08-22 21:58:12 +01:00
|
|
|
bundleTypes: [
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
|
|
|
|
FB_WWW_PROFILING,
|
2020-05-29 15:32:38 -07:00
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
2019-08-22 21:58:12 +01:00
|
|
|
],
|
2018-04-19 09:29:08 -07:00
|
|
|
moduleType: ISOMORPHIC,
|
2018-09-19 01:26:28 +01:00
|
|
|
entry: 'scheduler',
|
|
|
|
|
global: 'Scheduler',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: true,
|
2021-08-03 22:30:20 -04:00
|
|
|
externals: ['ReactNativeInternalFeatureFlags'],
|
2018-04-19 09:29:08 -07:00
|
|
|
},
|
2018-08-17 10:16:05 -06:00
|
|
|
|
Add new mock build of Scheduler with flush, yield API (#14964)
* Add new mock build of Scheduler with flush, yield API
Test environments need a way to take control of the Scheduler queue and
incrementally flush work. Our current tests accomplish this either using
dynamic injection, or by using Jest's fake timers feature. Both of these
options are fragile and rely too much on implementation details.
In this new approach, we have a separate build of Scheduler that is
specifically designed for test environments. We mock the default
implementation like we would any other module; in our case, via Jest.
This special build has methods like `flushAll` and `yieldValue` that
control when work is flushed. These methods are based on equivalent
methods we've been using to write incremental React tests. Eventually
we may want to migrate the React tests to interact with the mock
Scheduler directly, instead of going through the host config like we
currently do.
For now, I'm using our custom static injection infrastructure to create
the two builds of Scheduler — a default build for DOM (which falls back
to a naive timer based implementation), and the new mock build. I did it
this way because it allows me to share most of the implementation, which
isn't specific to a host environment — e.g. everything related to the
priority queue. It may be better to duplicate the shared code instead,
especially considering that future environments (like React Native) may
have entirely forked implementations. I'd prefer to wait until the
implementation stabilizes before worrying about that, but I'm open to
changing this now if we decide it's important enough.
* Mock Scheduler in bundle tests, too
* Remove special case by making regex more restrictive
2019-02-26 20:51:17 -08:00
|
|
|
/******* React Scheduler Mock (experimental) *******/
|
2018-10-03 18:37:41 -06:00
|
|
|
{
|
2019-05-16 17:12:36 +01:00
|
|
|
bundleTypes: [
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
2020-05-29 15:32:38 -07:00
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
2019-05-16 17:12:36 +01:00
|
|
|
],
|
2018-10-03 18:37:41 -06:00
|
|
|
moduleType: ISOMORPHIC,
|
Add new mock build of Scheduler with flush, yield API (#14964)
* Add new mock build of Scheduler with flush, yield API
Test environments need a way to take control of the Scheduler queue and
incrementally flush work. Our current tests accomplish this either using
dynamic injection, or by using Jest's fake timers feature. Both of these
options are fragile and rely too much on implementation details.
In this new approach, we have a separate build of Scheduler that is
specifically designed for test environments. We mock the default
implementation like we would any other module; in our case, via Jest.
This special build has methods like `flushAll` and `yieldValue` that
control when work is flushed. These methods are based on equivalent
methods we've been using to write incremental React tests. Eventually
we may want to migrate the React tests to interact with the mock
Scheduler directly, instead of going through the host config like we
currently do.
For now, I'm using our custom static injection infrastructure to create
the two builds of Scheduler — a default build for DOM (which falls back
to a naive timer based implementation), and the new mock build. I did it
this way because it allows me to share most of the implementation, which
isn't specific to a host environment — e.g. everything related to the
priority queue. It may be better to duplicate the shared code instead,
especially considering that future environments (like React Native) may
have entirely forked implementations. I'd prefer to wait until the
implementation stabilizes before worrying about that, but I'm open to
changing this now if we decide it's important enough.
* Mock Scheduler in bundle tests, too
* Remove special case by making regex more restrictive
2019-02-26 20:51:17 -08:00
|
|
|
entry: 'scheduler/unstable_mock',
|
|
|
|
|
global: 'SchedulerMock',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2021-08-03 22:30:20 -04:00
|
|
|
externals: ['ReactNativeInternalFeatureFlags'],
|
2018-10-03 18:37:41 -06:00
|
|
|
},
|
|
|
|
|
|
2023-05-05 14:01:31 +01:00
|
|
|
/******* React Scheduler Native *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'scheduler/index.native',
|
|
|
|
|
global: 'SchedulerNative',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['ReactNativeInternalFeatureFlags'],
|
|
|
|
|
},
|
|
|
|
|
|
2020-07-29 15:27:59 -04:00
|
|
|
/******* React Scheduler Post Task (experimental) *******/
|
2020-07-28 11:11:31 -04:00
|
|
|
{
|
2020-07-29 15:27:59 -04:00
|
|
|
bundleTypes: [
|
|
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
|
|
|
|
FB_WWW_PROFILING,
|
|
|
|
|
],
|
2020-07-28 11:11:31 -04:00
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'scheduler/unstable_post_task',
|
|
|
|
|
global: 'SchedulerPostTask',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: true,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2020-07-28 11:11:31 -04:00
|
|
|
externals: [],
|
|
|
|
|
},
|
|
|
|
|
|
Add new mock build of Scheduler with flush, yield API (#14964)
* Add new mock build of Scheduler with flush, yield API
Test environments need a way to take control of the Scheduler queue and
incrementally flush work. Our current tests accomplish this either using
dynamic injection, or by using Jest's fake timers feature. Both of these
options are fragile and rely too much on implementation details.
In this new approach, we have a separate build of Scheduler that is
specifically designed for test environments. We mock the default
implementation like we would any other module; in our case, via Jest.
This special build has methods like `flushAll` and `yieldValue` that
control when work is flushed. These methods are based on equivalent
methods we've been using to write incremental React tests. Eventually
we may want to migrate the React tests to interact with the mock
Scheduler directly, instead of going through the host config like we
currently do.
For now, I'm using our custom static injection infrastructure to create
the two builds of Scheduler — a default build for DOM (which falls back
to a naive timer based implementation), and the new mock build. I did it
this way because it allows me to share most of the implementation, which
isn't specific to a host environment — e.g. everything related to the
priority queue. It may be better to duplicate the shared code instead,
especially considering that future environments (like React Native) may
have entirely forked implementations. I'd prefer to wait until the
implementation stabilizes before worrying about that, but I'm open to
changing this now if we decide it's important enough.
* Mock Scheduler in bundle tests, too
* Remove special case by making regex more restrictive
2019-02-26 20:51:17 -08:00
|
|
|
/******* Jest React (experimental) *******/
|
2018-12-01 13:03:19 -08:00
|
|
|
{
|
2020-02-19 17:59:42 +00:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2018-12-01 13:03:19 -08:00
|
|
|
moduleType: ISOMORPHIC,
|
Add new mock build of Scheduler with flush, yield API (#14964)
* Add new mock build of Scheduler with flush, yield API
Test environments need a way to take control of the Scheduler queue and
incrementally flush work. Our current tests accomplish this either using
dynamic injection, or by using Jest's fake timers feature. Both of these
options are fragile and rely too much on implementation details.
In this new approach, we have a separate build of Scheduler that is
specifically designed for test environments. We mock the default
implementation like we would any other module; in our case, via Jest.
This special build has methods like `flushAll` and `yieldValue` that
control when work is flushed. These methods are based on equivalent
methods we've been using to write incremental React tests. Eventually
we may want to migrate the React tests to interact with the mock
Scheduler directly, instead of going through the host config like we
currently do.
For now, I'm using our custom static injection infrastructure to create
the two builds of Scheduler — a default build for DOM (which falls back
to a naive timer based implementation), and the new mock build. I did it
this way because it allows me to share most of the implementation, which
isn't specific to a host environment — e.g. everything related to the
priority queue. It may be better to duplicate the shared code instead,
especially considering that future environments (like React Native) may
have entirely forked implementations. I'd prefer to wait until the
implementation stabilizes before worrying about that, but I'm open to
changing this now if we decide it's important enough.
* Mock Scheduler in bundle tests, too
* Remove special case by making regex more restrictive
2019-02-26 20:51:17 -08:00
|
|
|
entry: 'jest-react',
|
|
|
|
|
global: 'JestReact',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2021-06-22 17:29:35 -04:00
|
|
|
externals: ['react', 'scheduler', 'scheduler/unstable_mock'],
|
2018-12-01 13:03:19 -08:00
|
|
|
},
|
|
|
|
|
|
2020-02-03 23:31:31 +00:00
|
|
|
/******* ESLint Plugin for Hooks *******/
|
2018-10-23 12:35:56 -07:00
|
|
|
{
|
2025-02-16 13:10:54 -06:00
|
|
|
// TODO: we're building this from typescript source now, but there's really
|
|
|
|
|
// no reason to have both dev and prod for this package. It's
|
|
|
|
|
// currently required in order for the package to be copied over correctly.
|
|
|
|
|
// So, it would be worth improving that flow.
|
|
|
|
|
name: 'eslint-plugin-react-hooks',
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, CJS_DTS],
|
2018-10-23 12:35:56 -07:00
|
|
|
moduleType: ISOMORPHIC,
|
2025-02-16 13:10:54 -06:00
|
|
|
entry: 'eslint-plugin-react-hooks/src/index.ts',
|
2018-11-09 10:22:18 -08:00
|
|
|
global: 'ESLintPluginReactHooks',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
[compiler] Aggregate error reporting, separate eslint rules (#34176)
NOTE: this is a merged version of @mofeiZ's original PR along with my
edits per offline discussion. The description is updated to reflect the
latest approach.
The key problem we're trying to solve with this PR is to allow
developers more control over the compiler's various validations. The
idea is to have a number of rules targeting a specific category of
issues, such as enforcing immutability of props/state/etc or disallowing
access to refs during render. We don't want to have to run the compiler
again for every single rule, though, so @mofeiZ added an LRU cache that
caches the full compilation output of N most recent files. The first
rule to run on a given file will cause it to get cached, and then
subsequent rules can pull from the cache, with each rule filtering down
to its specific category of errors.
For the categories, I went through and assigned a category roughly 1:1
to existing validations, and then used my judgement on some places that
felt distinct enough to warrant a separate error. Every error in the
compiler now has to supply both a severity (for legacy reasons) and a
category (for ESLint). Each category corresponds 1:1 to a ESLint rule
definition, so that the set of rules is automatically populated based on
the defined categories.
Categories include a flag for whether they should be in the recommended
set or not.
Note that as with the original version of this PR, only
eslint-plugin-react-compiler is changed. We still have to update the
main lint rule.
## Test Plan
* Created a sample project using ESLint v9 and verified that the plugin
can be configured correctly and detects errors
* Edited `fixtures/eslint-v9` and introduced errors, verified that the w
latest config changes in that fixture it correctly detects the errors
* In the sample project, confirmed that the LRU caching is correctly
caching compiler output, ie compiling files just once.
Co-authored-by: Mofei Zhang <feifei0@meta.com>
2025-08-21 14:53:34 -07:00
|
|
|
preferBuiltins: true,
|
|
|
|
|
externals: [
|
|
|
|
|
'@babel/core',
|
|
|
|
|
'hermes-parser',
|
|
|
|
|
'zod',
|
2025-10-16 12:46:55 -04:00
|
|
|
'zod/v4',
|
[compiler] Aggregate error reporting, separate eslint rules (#34176)
NOTE: this is a merged version of @mofeiZ's original PR along with my
edits per offline discussion. The description is updated to reflect the
latest approach.
The key problem we're trying to solve with this PR is to allow
developers more control over the compiler's various validations. The
idea is to have a number of rules targeting a specific category of
issues, such as enforcing immutability of props/state/etc or disallowing
access to refs during render. We don't want to have to run the compiler
again for every single rule, though, so @mofeiZ added an LRU cache that
caches the full compilation output of N most recent files. The first
rule to run on a given file will cause it to get cached, and then
subsequent rules can pull from the cache, with each rule filtering down
to its specific category of errors.
For the categories, I went through and assigned a category roughly 1:1
to existing validations, and then used my judgement on some places that
felt distinct enough to warrant a separate error. Every error in the
compiler now has to supply both a severity (for legacy reasons) and a
category (for ESLint). Each category corresponds 1:1 to a ESLint rule
definition, so that the set of rules is automatically populated based on
the defined categories.
Categories include a flag for whether they should be in the recommended
set or not.
Note that as with the original version of this PR, only
eslint-plugin-react-compiler is changed. We still have to update the
main lint rule.
## Test Plan
* Created a sample project using ESLint v9 and verified that the plugin
can be configured correctly and detects errors
* Edited `fixtures/eslint-v9` and introduced errors, verified that the w
latest config changes in that fixture it correctly detects the errors
* In the sample project, confirmed that the LRU caching is correctly
caching compiler output, ie compiling files just once.
Co-authored-by: Mofei Zhang <feifei0@meta.com>
2025-08-21 14:53:34 -07:00
|
|
|
'zod-validation-error',
|
2025-10-16 12:46:55 -04:00
|
|
|
'zod-validation-error/v4',
|
2025-08-25 09:39:56 +02:00
|
|
|
'crypto',
|
|
|
|
|
'util',
|
[compiler] Aggregate error reporting, separate eslint rules (#34176)
NOTE: this is a merged version of @mofeiZ's original PR along with my
edits per offline discussion. The description is updated to reflect the
latest approach.
The key problem we're trying to solve with this PR is to allow
developers more control over the compiler's various validations. The
idea is to have a number of rules targeting a specific category of
issues, such as enforcing immutability of props/state/etc or disallowing
access to refs during render. We don't want to have to run the compiler
again for every single rule, though, so @mofeiZ added an LRU cache that
caches the full compilation output of N most recent files. The first
rule to run on a given file will cause it to get cached, and then
subsequent rules can pull from the cache, with each rule filtering down
to its specific category of errors.
For the categories, I went through and assigned a category roughly 1:1
to existing validations, and then used my judgement on some places that
felt distinct enough to warrant a separate error. Every error in the
compiler now has to supply both a severity (for legacy reasons) and a
category (for ESLint). Each category corresponds 1:1 to a ESLint rule
definition, so that the set of rules is automatically populated based on
the defined categories.
Categories include a flag for whether they should be in the recommended
set or not.
Note that as with the original version of this PR, only
eslint-plugin-react-compiler is changed. We still have to update the
main lint rule.
## Test Plan
* Created a sample project using ESLint v9 and verified that the plugin
can be configured correctly and detects errors
* Edited `fixtures/eslint-v9` and introduced errors, verified that the w
latest config changes in that fixture it correctly detects the errors
* In the sample project, confirmed that the LRU caching is correctly
caching compiler output, ie compiling files just once.
Co-authored-by: Mofei Zhang <feifei0@meta.com>
2025-08-21 14:53:34 -07:00
|
|
|
],
|
2025-02-16 13:10:54 -06:00
|
|
|
tsconfig: './packages/eslint-plugin-react-hooks/tsconfig.json',
|
2025-03-12 20:43:06 -05:00
|
|
|
prebuild: `mkdir -p ./compiler/packages/babel-plugin-react-compiler/dist && echo "module.exports = require('../src/index.ts');" > ./compiler/packages/babel-plugin-react-compiler/dist/index.js`,
|
2018-10-23 12:35:56 -07:00
|
|
|
},
|
2019-05-21 21:54:10 +01:00
|
|
|
|
|
|
|
|
/******* React Fresh *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
moduleType: ISOMORPHIC,
|
2019-06-15 19:36:46 +01:00
|
|
|
entry: 'react-refresh/babel',
|
2019-05-21 21:54:10 +01:00
|
|
|
global: 'ReactFreshBabelPlugin',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-05-21 21:54:10 +01:00
|
|
|
externals: [],
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-09-06 16:48:07 +01:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV],
|
2019-05-21 21:54:10 +01:00
|
|
|
moduleType: ISOMORPHIC,
|
2019-06-15 19:36:46 +01:00
|
|
|
entry: 'react-refresh/runtime',
|
2019-05-21 21:54:10 +01:00
|
|
|
global: 'ReactFreshRuntime',
|
[RFC] Codemod invariant -> throw new Error (#22435)
* Hoist error codes import to module scope
When this code was written, the error codes map (`codes.json`) was
created on-the-fly, so we had to lazily require from inside the visitor.
Because `codes.json` is now checked into source, we can import it a
single time in module scope.
* Minify error constructors in production
We use a script to minify our error messages in production. Each message
is assigned an error code, defined in `scripts/error-codes/codes.json`.
Then our build script replaces the messages with a link to our
error decoder page, e.g. https://reactjs.org/docs/error-decoder.html/?invariant=92
This enables us to write helpful error messages without increasing the
bundle size.
Right now, the script only works for `invariant` calls. It does not work
if you throw an Error object. This is an old Facebookism that we don't
really need, other than the fact that our error minification script
relies on it.
So, I've updated the script to minify error constructors, too:
Input:
Error(`A ${adj} message that contains ${noun}`);
Output:
Error(formatProdErrorMessage(ERR_CODE, adj, noun));
It only works for constructors that are literally named Error, though we
could add support for other names, too.
As a next step, I will add a lint rule to enforce that errors written
this way must have a corresponding error code.
* Minify "no fallback UI specified" error in prod
This error message wasn't being minified because it doesn't use
invariant. The reason it didn't use invariant is because this particular
error is created without begin thrown — it doesn't need to be thrown
because it's located inside the error handling part of the runtime.
Now that the error minification script supports Error constructors, we
can minify it by assigning it a production error code in
`scripts/error-codes/codes.json`.
To support the use of Error constructors more generally, I will add a
lint rule that enforces each message has a corresponding error code.
* Lint rule to detect unminified errors
Adds a lint rule that detects when an Error constructor is used without
a corresponding production error code.
We already have this for `invariant`, but not for regular errors, i.e.
`throw new Error(msg)`. There's also nothing that enforces the use of
`invariant` besides convention.
There are some packages where we don't care to minify errors. These are
packages that run in environments where bundle size is not a concern,
like react-pg. I added an override in the ESLint config to ignore these.
* Temporarily add invariant codemod script
I'm adding this codemod to the repo temporarily, but I'll revert it
in the same PR. That way we don't have to check it in but it's still
accessible (via the PR) if we need it later.
* [Automated] Codemod invariant -> Error
This commit contains only automated changes:
npx jscodeshift -t scripts/codemod-invariant.js packages --ignore-pattern="node_modules/**/*"
yarn linc --fix
yarn prettier
I will do any manual touch ups in separate commits so they're easier
to review.
* Remove temporary codemod script
This reverts the codemod script and ESLint config I added temporarily
in order to perform the invariant codemod.
* Manual touch ups
A few manual changes I made after the codemod ran.
* Enable error code transform per package
Currently we're not consistent about which packages should have their
errors minified in production and which ones should.
This adds a field to the bundle configuration to control whether to
apply the transform. We should decide what the criteria is going
forward. I think it's probably a good idea to minify any package that
gets sent over the network. So yes to modules that run in the browser,
and no to modules that run on the server and during development only.
2021-09-30 15:01:28 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-05-21 21:54:10 +01:00
|
|
|
externals: [],
|
|
|
|
|
},
|
2017-04-05 16:47:29 +01:00
|
|
|
];
|
|
|
|
|
|
2017-09-14 01:24:31 +01:00
|
|
|
// Based on deep-freeze by substack (public domain)
|
|
|
|
|
function deepFreeze(o) {
|
|
|
|
|
Object.freeze(o);
|
2023-01-31 08:25:05 -05:00
|
|
|
Object.getOwnPropertyNames(o).forEach(function (prop) {
|
2017-09-14 01:24:31 +01:00
|
|
|
if (
|
|
|
|
|
o[prop] !== null &&
|
|
|
|
|
(typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
|
|
|
|
|
!Object.isFrozen(o[prop])
|
|
|
|
|
) {
|
|
|
|
|
deepFreeze(o[prop]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Don't accidentally mutate config as part of the build
|
|
|
|
|
deepFreeze(bundles);
|
2019-04-25 17:24:01 +02:00
|
|
|
deepFreeze(bundleTypes);
|
|
|
|
|
deepFreeze(moduleTypes);
|
2017-09-14 01:24:31 +01:00
|
|
|
|
2023-02-07 12:09:29 -05:00
|
|
|
function getFilename(bundle, bundleType) {
|
2021-06-14 19:23:19 -04:00
|
|
|
let name = bundle.name || bundle.entry;
|
2020-05-28 15:04:25 -07:00
|
|
|
const globalName = bundle.global;
|
|
|
|
|
// we do this to replace / to -, for react-dom/server
|
|
|
|
|
name = name.replace('/index.', '.').replace('/', '-');
|
|
|
|
|
switch (bundleType) {
|
2020-05-28 15:56:34 -07:00
|
|
|
case NODE_ES2015:
|
|
|
|
|
return `${name}.js`;
|
2022-11-17 13:15:56 -08:00
|
|
|
case BUN_DEV:
|
|
|
|
|
return `${name}.development.js`;
|
|
|
|
|
case BUN_PROD:
|
2024-04-20 11:23:46 -04:00
|
|
|
return `${name}.production.js`;
|
2023-02-21 13:18:24 -05:00
|
|
|
case ESM_DEV:
|
|
|
|
|
return `${name}.development.js`;
|
|
|
|
|
case ESM_PROD:
|
2024-04-20 11:23:46 -04:00
|
|
|
return `${name}.production.js`;
|
2020-05-28 15:04:25 -07:00
|
|
|
case NODE_DEV:
|
|
|
|
|
return `${name}.development.js`;
|
|
|
|
|
case NODE_PROD:
|
2024-04-20 11:23:46 -04:00
|
|
|
return `${name}.production.js`;
|
2020-05-28 15:04:25 -07:00
|
|
|
case NODE_PROFILING:
|
2024-04-20 11:23:46 -04:00
|
|
|
return `${name}.profiling.js`;
|
2020-05-28 15:04:25 -07:00
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case RN_OSS_DEV:
|
|
|
|
|
case RN_FB_DEV:
|
|
|
|
|
return `${globalName}-dev.js`;
|
|
|
|
|
case FB_WWW_PROD:
|
|
|
|
|
case RN_OSS_PROD:
|
|
|
|
|
case RN_FB_PROD:
|
|
|
|
|
return `${globalName}-prod.js`;
|
|
|
|
|
case FB_WWW_PROFILING:
|
|
|
|
|
case RN_FB_PROFILING:
|
|
|
|
|
case RN_OSS_PROFILING:
|
|
|
|
|
return `${globalName}-profiling.js`;
|
2022-10-14 23:29:17 -04:00
|
|
|
case BROWSER_SCRIPT:
|
|
|
|
|
return `${name}.js`;
|
2025-02-16 09:38:13 -06:00
|
|
|
case CJS_DTS:
|
|
|
|
|
case ESM_DTS:
|
|
|
|
|
return `${name}.d.ts`;
|
2020-05-28 15:04:25 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
[compiler] Aggregate error reporting, separate eslint rules (#34176)
NOTE: this is a merged version of @mofeiZ's original PR along with my
edits per offline discussion. The description is updated to reflect the
latest approach.
The key problem we're trying to solve with this PR is to allow
developers more control over the compiler's various validations. The
idea is to have a number of rules targeting a specific category of
issues, such as enforcing immutability of props/state/etc or disallowing
access to refs during render. We don't want to have to run the compiler
again for every single rule, though, so @mofeiZ added an LRU cache that
caches the full compilation output of N most recent files. The first
rule to run on a given file will cause it to get cached, and then
subsequent rules can pull from the cache, with each rule filtering down
to its specific category of errors.
For the categories, I went through and assigned a category roughly 1:1
to existing validations, and then used my judgement on some places that
felt distinct enough to warrant a separate error. Every error in the
compiler now has to supply both a severity (for legacy reasons) and a
category (for ESLint). Each category corresponds 1:1 to a ESLint rule
definition, so that the set of rules is automatically populated based on
the defined categories.
Categories include a flag for whether they should be in the recommended
set or not.
Note that as with the original version of this PR, only
eslint-plugin-react-compiler is changed. We still have to update the
main lint rule.
## Test Plan
* Created a sample project using ESLint v9 and verified that the plugin
can be configured correctly and detects errors
* Edited `fixtures/eslint-v9` and introduced errors, verified that the w
latest config changes in that fixture it correctly detects the errors
* In the sample project, confirmed that the LRU caching is correctly
caching compiler output, ie compiling files just once.
Co-authored-by: Mofei Zhang <feifei0@meta.com>
2025-08-21 14:53:34 -07:00
|
|
|
let activeBundles = bundles;
|
|
|
|
|
if (process.env.BUNDLES_FILTER != null) {
|
|
|
|
|
activeBundles = activeBundles.filter(
|
|
|
|
|
bundle => bundle.name === process.env.BUNDLES_FILTER
|
|
|
|
|
);
|
|
|
|
|
if (activeBundles.length === 0) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`No bundles matched for BUNDLES_FILTER=${process.env.BUNDLES_FILTER}`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
module.exports = {
|
|
|
|
|
bundleTypes,
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleTypes,
|
[compiler] Aggregate error reporting, separate eslint rules (#34176)
NOTE: this is a merged version of @mofeiZ's original PR along with my
edits per offline discussion. The description is updated to reflect the
latest approach.
The key problem we're trying to solve with this PR is to allow
developers more control over the compiler's various validations. The
idea is to have a number of rules targeting a specific category of
issues, such as enforcing immutability of props/state/etc or disallowing
access to refs during render. We don't want to have to run the compiler
again for every single rule, though, so @mofeiZ added an LRU cache that
caches the full compilation output of N most recent files. The first
rule to run on a given file will cause it to get cached, and then
subsequent rules can pull from the cache, with each rule filtering down
to its specific category of errors.
For the categories, I went through and assigned a category roughly 1:1
to existing validations, and then used my judgement on some places that
felt distinct enough to warrant a separate error. Every error in the
compiler now has to supply both a severity (for legacy reasons) and a
category (for ESLint). Each category corresponds 1:1 to a ESLint rule
definition, so that the set of rules is automatically populated based on
the defined categories.
Categories include a flag for whether they should be in the recommended
set or not.
Note that as with the original version of this PR, only
eslint-plugin-react-compiler is changed. We still have to update the
main lint rule.
## Test Plan
* Created a sample project using ESLint v9 and verified that the plugin
can be configured correctly and detects errors
* Edited `fixtures/eslint-v9` and introduced errors, verified that the w
latest config changes in that fixture it correctly detects the errors
* In the sample project, confirmed that the LRU caching is correctly
caching compiler output, ie compiling files just once.
Co-authored-by: Mofei Zhang <feifei0@meta.com>
2025-08-21 14:53:34 -07:00
|
|
|
bundles: activeBundles,
|
2020-05-28 15:04:25 -07:00
|
|
|
getFilename,
|
2017-04-05 16:47:29 +01:00
|
|
|
};
|