-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve error codes for invariants on www (#12539)
* Preserve error codes for invariants on www * Remove unintentional change
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
const invariant = require('invariant'); | ||
|
||
function reactProdInvariant(code: string): void { | ||
const argCount = arguments.length - 1; | ||
|
||
let message = | ||
'Minified React error #' + | ||
code + | ||
'; visit ' + | ||
'http://reactjs.org/docs/error-decoder.html?invariant=' + | ||
code; | ||
|
||
for (let argIdx = 0; argIdx < argCount; argIdx++) { | ||
message += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]); | ||
} | ||
|
||
message += | ||
' for the full message or use the non-minified dev environment' + | ||
' for full errors and additional helpful warnings.'; | ||
|
||
// www doesn't strip this because we mark the React bundle | ||
// with @preserve-invariant-messages docblock. | ||
const i = invariant; | ||
// However, we call it with a different name to avoid | ||
// transforming this file itself as part of React's own build. | ||
i(false, message); | ||
} | ||
|
||
export default reactProdInvariant; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters