2016-06-08 08:11:04 +08:00
|
|
|
/**
|
2018-09-08 06:11:23 +08:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-06-08 08:11:04 +08:00
|
|
|
*
|
2017-09-25 04:48:13 +08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-06-08 08:11:04 +08:00
|
|
|
*
|
2016-06-24 00:16:37 +08:00
|
|
|
* @flow
|
2016-06-08 08:11:04 +08:00
|
|
|
*/
|
|
|
|
|
|
2018-04-10 06:58:34 +08:00
|
|
|
// Relying on the `invariant()` implementation lets us
|
2018-08-15 03:58:35 +08:00
|
|
|
// preserve the format and params in the www builds.
|
2018-06-19 23:03:45 +08:00
|
|
|
import invariant from 'shared/invariant';
|
2018-04-10 06:58:34 +08:00
|
|
|
|
2016-06-08 08:11:04 +08:00
|
|
|
/**
|
|
|
|
|
* WARNING: DO NOT manually require this module.
|
|
|
|
|
* This is a replacement for `invariant(...)` used by the error code system
|
|
|
|
|
* and will _only_ be required by the corresponding babel pass.
|
|
|
|
|
* It always throws.
|
|
|
|
|
*/
|
2016-06-24 00:16:37 +08:00
|
|
|
function reactProdInvariant(code: string): void {
|
2017-12-01 08:03:27 +08:00
|
|
|
const argCount = arguments.length - 1;
|
2018-05-20 08:29:41 +08:00
|
|
|
let url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code;
|
2017-12-01 08:03:27 +08:00
|
|
|
for (let argIdx = 0; argIdx < argCount; argIdx++) {
|
2018-04-10 06:58:34 +08:00
|
|
|
url += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
|
2016-06-08 08:11:04 +08:00
|
|
|
}
|
2018-10-28 00:59:00 +08:00
|
|
|
// Rename it so that our build transform doesn't attempt
|
2018-04-10 06:58:34 +08:00
|
|
|
// to replace this invariant() call with reactProdInvariant().
|
|
|
|
|
const i = invariant;
|
|
|
|
|
i(
|
|
|
|
|
false,
|
|
|
|
|
// The error code is intentionally part of the message (and
|
|
|
|
|
// not the format argument) so that we could deduplicate
|
|
|
|
|
// different errors in logs based on the code.
|
|
|
|
|
'Minified React error #' +
|
|
|
|
|
code +
|
|
|
|
|
'; visit %s ' +
|
|
|
|
|
'for the full message or use the non-minified dev environment ' +
|
|
|
|
|
'for full errors and additional helpful warnings. ',
|
|
|
|
|
url,
|
|
|
|
|
);
|
2016-06-08 08:11:04 +08:00
|
|
|
}
|
|
|
|
|
|
2017-11-03 03:50:03 +08:00
|
|
|
export default reactProdInvariant;
|