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',
|
2020-11-13 08:57:45 -05:00
|
|
|
NODE_ESM: 'NODE_ESM',
|
2017-04-05 16:47:29 +01:00
|
|
|
UMD_DEV: 'UMD_DEV',
|
|
|
|
|
UMD_PROD: 'UMD_PROD',
|
2018-09-13 17:44:08 -07:00
|
|
|
UMD_PROFILING: 'UMD_PROFILING',
|
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',
|
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,
|
2020-11-13 08:57:45 -05:00
|
|
|
NODE_ESM,
|
2019-04-25 17:24:01 +02:00
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_PROD,
|
|
|
|
|
UMD_PROFILING,
|
|
|
|
|
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,
|
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: [
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_PROD,
|
2018-09-13 17:44:08 -07:00
|
|
|
UMD_PROFILING,
|
2018-04-18 13:16:50 -07:00
|
|
|
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,
|
2022-02-22 20:03:51 -05:00
|
|
|
entry: 'react/src/ReactSharedSubset.js',
|
|
|
|
|
name: 'react.shared-subset',
|
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
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* 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
|
|
|
},
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
/******* React DOM *******/
|
|
|
|
|
{
|
2018-04-18 13:16:50 -07:00
|
|
|
bundleTypes: [
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_PROD,
|
2018-09-13 17:44:08 -07:00
|
|
|
UMD_PROFILING,
|
2018-04-18 13:16:50 -07:00
|
|
|
NODE_DEV,
|
|
|
|
|
NODE_PROD,
|
2018-06-11 13:16:27 -07:00
|
|
|
NODE_PROFILING,
|
2018-04-18 13:16:50 -07:00
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
2018-06-26 13:28:41 -07:00
|
|
|
FB_WWW_PROFILING,
|
2018-04-18 13:16:50 -07:00
|
|
|
],
|
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
|
|
|
},
|
2017-10-25 02:55:00 +03:00
|
|
|
|
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,
|
2018-04-18 13:16:50 -07:00
|
|
|
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_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
|
|
|
|
2020-02-03 23:31:31 +00:00
|
|
|
/******* React DOM - www - Testing *******/
|
|
|
|
|
{
|
|
|
|
|
moduleType: RENDERER,
|
2022-02-08 23:12:31 -05:00
|
|
|
bundleTypes: __EXPERIMENTAL__
|
|
|
|
|
? [FB_WWW_DEV, FB_WWW_PROD, NODE_DEV, NODE_PROD]
|
|
|
|
|
: [FB_WWW_DEV, FB_WWW_PROD],
|
|
|
|
|
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,
|
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
|
|
|
{
|
2021-12-14 16:19:19 -08:00
|
|
|
bundleTypes: [
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_PROD,
|
|
|
|
|
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 *******/
|
|
|
|
|
{
|
2021-06-02 16:13:19 +01:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
|
2018-11-30 11:38:22 -08:00
|
|
|
moduleType: RENDERER,
|
2022-02-09 11:37:17 -08:00
|
|
|
entry: 'react-dom/src/server/ReactDOMFizzServerBrowser.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,
|
2022-02-09 11:37:17 -08:00
|
|
|
entry: 'react-dom/src/server/ReactDOMFizzServerNode.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,
|
2022-10-23 01:06:58 -04:00
|
|
|
externals: ['react', 'util', 'async_hooks', 'react-dom'],
|
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,
|
2022-02-09 11:37:17 -08:00
|
|
|
entry: 'react-server-dom-relay/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
|
|
|
|
2022-11-17 13:15:56 -08:00
|
|
|
/******* React DOM Fizz Server Bun *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [BUN_DEV, BUN_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/src/server/ReactDOMFizzServerBun.js',
|
|
|
|
|
name: 'react-dom-server.bun', // 'node_modules/react/*.js',
|
|
|
|
|
|
|
|
|
|
global: 'ReactDOMServer',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
|
|
|
|
externals: ['react', 'react-dom'],
|
|
|
|
|
},
|
|
|
|
|
|
2022-06-18 22:34:31 -04:00
|
|
|
/******* React DOM Fizz Static *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/static.browser',
|
|
|
|
|
global: 'ReactDOMStatic',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2022-09-30 16:14:04 -07:00
|
|
|
externals: ['react', 'react-dom'],
|
2022-06-18 22:34:31 -04:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/static.node',
|
|
|
|
|
name: 'react-dom-static.node',
|
|
|
|
|
global: 'ReactDOMStatic',
|
|
|
|
|
minifyWithProdErrorCodes: false,
|
|
|
|
|
wrapWithModuleBoundaries: false,
|
2022-10-23 01:06:58 -04:00
|
|
|
externals: ['react', 'util', 'async_hooks', 'stream', 'react-dom'],
|
2022-06-18 22:34:31 -04:00
|
|
|
},
|
|
|
|
|
|
2022-10-14 23:29:17 -04:00
|
|
|
/******* React DOM Fizz Server External Runtime *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [BROWSER_SCRIPT],
|
|
|
|
|
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: [],
|
|
|
|
|
},
|
|
|
|
|
|
2022-10-10 11:06:22 -07:00
|
|
|
/******* React DOM Server Render Stub *******/
|
|
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-dom/server-rendering-stub',
|
|
|
|
|
name: 'react-dom-server-rendering-stub',
|
|
|
|
|
global: 'ReactDOMServerRenderingStub',
|
|
|
|
|
minifyWithProdErrorCodes: true,
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2022-10-18 10:15:52 -04:00
|
|
|
entry: 'react-server-dom-webpack/server.browser',
|
|
|
|
|
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,
|
2022-10-18 10:15:52 -04:00
|
|
|
entry: 'react-server-dom-webpack/server.node',
|
|
|
|
|
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-10-23 01:06:58 -04:00
|
|
|
externals: ['react', 'util', 'async_hooks', 'react-dom'],
|
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
|
|
|
{
|
2020-02-19 17:59:42 +00:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
|
2019-10-29 14:45:47 -07:00
|
|
|
moduleType: RENDERER,
|
2022-10-18 10:15:52 -04:00
|
|
|
entry: 'react-server-dom-webpack/client',
|
|
|
|
|
global: 'ReactServerDOMClient',
|
2021-10-31 18:37:32 -04:00
|
|
|
minifyWithProdErrorCodes: false,
|
2021-10-21 14:40:41 -04:00
|
|
|
wrapWithModuleBoundaries: false,
|
2019-10-29 14:45:47 -07:00
|
|
|
externals: ['react'],
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
bundleTypes: [NODE_ESM],
|
|
|
|
|
moduleType: RENDERER_UTILS,
|
2020-12-08 08:08:57 -05:00
|
|
|
entry: 'react-server-dom-webpack/node-loader',
|
|
|
|
|
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,
|
2022-08-24 19:05:39 -04:00
|
|
|
entry: 'react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js',
|
|
|
|
|
name: 'react-server-dom-webpack-node-register',
|
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,
|
2020-11-30 17:25:56 -05:00
|
|
|
externals: ['url', 'module'],
|
2020-11-16 23:46:27 -05:00
|
|
|
},
|
|
|
|
|
|
2020-12-08 08:08:57 -05:00
|
|
|
/******* React Server DOM Relay Writer *******/
|
2020-03-07 11:23:30 -08:00
|
|
|
{
|
|
|
|
|
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2020-12-08 08:08:57 -05:00
|
|
|
entry: 'react-server-dom-relay/server',
|
|
|
|
|
global: 'ReactFlightDOMRelayServer', // TODO: Rename to Writer
|
[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-10 14:55:04 -07:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'ReactFlightDOMRelayServerIntegration',
|
2022-05-06 11:24:04 -07:00
|
|
|
'JSResourceReferenceImpl',
|
2020-03-10 14:55:04 -07:00
|
|
|
],
|
2020-03-07 11:23:30 -08:00
|
|
|
},
|
|
|
|
|
|
2020-12-08 08:08:57 -05:00
|
|
|
/******* React Server DOM Relay Reader *******/
|
2020-03-07 11:23:30 -08:00
|
|
|
{
|
|
|
|
|
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2020-12-08 08:08:57 -05:00
|
|
|
entry: 'react-server-dom-relay',
|
2022-10-23 01:06:58 -04:00
|
|
|
global: 'ReactFlightDOMRelayClient',
|
[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-10-29 20:57:31 -04:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'ReactFlightDOMRelayClientIntegration',
|
2022-05-06 11:24:04 -07:00
|
|
|
'JSResourceReferenceImpl',
|
2020-10-29 20:57:31 -04:00
|
|
|
],
|
2020-03-07 11:23:30 -08:00
|
|
|
},
|
|
|
|
|
|
2020-12-08 08:08:57 -05:00
|
|
|
/******* React Server Native Relay Writer *******/
|
2020-11-02 21:49:48 -05:00
|
|
|
{
|
|
|
|
|
bundleTypes: [RN_FB_DEV, RN_FB_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2020-12-08 08:08:57 -05:00
|
|
|
entry: 'react-server-native-relay/server',
|
2022-10-23 01:06:58 -04:00
|
|
|
global: 'ReactFlightNativeRelayServer',
|
[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-02 21:49:48 -05:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'ReactFlightNativeRelayServerIntegration',
|
|
|
|
|
'JSResourceReferenceImpl',
|
2021-08-03 22:30:20 -04:00
|
|
|
'ReactNativeInternalFeatureFlags',
|
2022-04-11 09:13:44 -07:00
|
|
|
'util',
|
2022-10-23 01:06:58 -04:00
|
|
|
'async_hooks',
|
2020-11-02 21:49:48 -05:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
2020-12-08 08:08:57 -05:00
|
|
|
/******* React Server Native Relay Reader *******/
|
2020-11-02 21:49:48 -05:00
|
|
|
{
|
|
|
|
|
bundleTypes: [RN_FB_DEV, RN_FB_PROD],
|
|
|
|
|
moduleType: RENDERER,
|
2020-12-08 08:08:57 -05:00
|
|
|
entry: 'react-server-native-relay',
|
|
|
|
|
global: 'ReactFlightNativeRelayClient', // TODO: Rename to Reader
|
[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-02 21:49:48 -05:00
|
|
|
externals: [
|
|
|
|
|
'react',
|
|
|
|
|
'ReactFlightNativeRelayClientIntegration',
|
|
|
|
|
'JSResourceReferenceImpl',
|
2021-08-03 22:30:20 -04:00
|
|
|
'ReactNativeInternalFeatureFlags',
|
2020-11-02 21:49:48 -05:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
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 *******/
|
|
|
|
|
{
|
2018-04-18 13:16:50 -07:00
|
|
|
bundleTypes: [
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_PROD,
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/******* React Native *******/
|
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',
|
|
|
|
|
global: 'ReactNativeRenderer',
|
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
|
|
|
},
|
2017-04-05 16:47:29 +01:00
|
|
|
{
|
2018-06-11 13:16:27 -07:00
|
|
|
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
|
2017-10-25 02:55:00 +03:00
|
|
|
moduleType: RENDERER,
|
|
|
|
|
entry: 'react-native-renderer',
|
|
|
|
|
global: 'ReactNativeRenderer',
|
2019-05-23 00:23:54 -07:00
|
|
|
externals: ['react-native'],
|
[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}],
|
|
|
|
|
]),
|
|
|
|
|
}),
|
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',
|
2019-05-23 00:23:54 -07:00
|
|
|
externals: ['react-native'],
|
[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,
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_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',
|
|
|
|
|
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 *******/
|
|
|
|
|
{
|
2020-08-19 06:11:27 -07:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD, NODE_PROFILING],
|
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',
|
|
|
|
|
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,
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
|
|
|
|
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,
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_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
|
|
|
{
|
2020-05-01 16:07:36 +01:00
|
|
|
// This is only used by our own tests.
|
|
|
|
|
// We can delete it later.
|
|
|
|
|
bundleTypes: [NODE_DEV, NODE_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: [
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_PROD,
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
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
|
|
|
{
|
2019-04-25 17:24:01 +02:00
|
|
|
// TODO: it's awkward to create a bundle for this but if we don't, the package
|
|
|
|
|
// won't get copied. We also can't create just DEV bundle because it contains a
|
|
|
|
|
// NODE_ENV check inside. We should probably tweak our build process to allow
|
|
|
|
|
// "raw" packages that don't get bundled.
|
2019-09-06 16:48:07 +01:00
|
|
|
bundleTypes: [NODE_DEV, NODE_PROD],
|
2018-10-23 12:35:56 -07:00
|
|
|
moduleType: ISOMORPHIC,
|
|
|
|
|
entry: 'eslint-plugin-react-hooks',
|
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,
|
2018-10-23 12:35:56 -07:00
|
|
|
externals: [],
|
|
|
|
|
},
|
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
|
|
|
|
2020-12-09 22:47:17 +00:00
|
|
|
function getOriginalFilename(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`;
|
2020-11-13 08:57:45 -05:00
|
|
|
case NODE_ESM:
|
|
|
|
|
return `${name}.js`;
|
2022-11-17 13:15:56 -08:00
|
|
|
case BUN_DEV:
|
|
|
|
|
return `${name}.development.js`;
|
|
|
|
|
case BUN_PROD:
|
|
|
|
|
return `${name}.production.min.js`;
|
2020-05-28 15:04:25 -07:00
|
|
|
case UMD_DEV:
|
|
|
|
|
return `${name}.development.js`;
|
|
|
|
|
case UMD_PROD:
|
|
|
|
|
return `${name}.production.min.js`;
|
|
|
|
|
case UMD_PROFILING:
|
|
|
|
|
return `${name}.profiling.min.js`;
|
|
|
|
|
case NODE_DEV:
|
|
|
|
|
return `${name}.development.js`;
|
|
|
|
|
case NODE_PROD:
|
|
|
|
|
return `${name}.production.min.js`;
|
|
|
|
|
case NODE_PROFILING:
|
|
|
|
|
return `${name}.profiling.min.js`;
|
|
|
|
|
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`;
|
2020-05-28 15:04:25 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-09 22:47:17 +00:00
|
|
|
function getFilename(bundle, bundleType) {
|
|
|
|
|
const originalFilename = getOriginalFilename(bundle, bundleType);
|
|
|
|
|
// Ensure .server.js or .client.js is the final suffix.
|
|
|
|
|
// This is important for the Server tooling convention.
|
|
|
|
|
if (originalFilename.indexOf('.server.') !== -1) {
|
|
|
|
|
return originalFilename
|
|
|
|
|
.replace('.server.', '.')
|
|
|
|
|
.replace('.js', '.server.js');
|
|
|
|
|
}
|
|
|
|
|
if (originalFilename.indexOf('.client.') !== -1) {
|
|
|
|
|
return originalFilename
|
|
|
|
|
.replace('.client.', '.')
|
|
|
|
|
.replace('.js', '.client.js');
|
|
|
|
|
}
|
|
|
|
|
return originalFilename;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 16:47:29 +01:00
|
|
|
module.exports = {
|
|
|
|
|
bundleTypes,
|
2017-10-11 14:29:26 -04:00
|
|
|
moduleTypes,
|
2017-04-05 16:47:29 +01:00
|
|
|
bundles,
|
2020-05-28 15:04:25 -07:00
|
|
|
getFilename,
|
2017-04-05 16:47:29 +01:00
|
|
|
};
|