You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The use of invariant pulls in loose-envify which in turn pulls in js-tokens. This has little consequence when used with React since it already uses them, but when used outside React these are relatively heavy dependencies (as already noted in #126)
Also as noted in #83 (comment), this way of writing invariant checks can cause significant performance penalty, since the error message arguments are always evaluated (unless combined with a compile-time code rewriter, but this project doesn't do that)
I would like to suggest at a minimum switching to use tiny-invariant, which is compatible with invariant except that it does not provide the %s formatting. The library still works with compile-time code rewriters and does not have any dependencies (and is tiny itself).
And better would be to also run the code through a transformer as part of the build process so that the built code only evaluates error arguments if the condition fails (or see my suggested improvement to tiny-invariant alexreardon/tiny-invariant#62 if a build-time transformation is not desirable).
The text was updated successfully, but these errors were encountered:
The use of
invariant
pulls inloose-envify
which in turn pulls injs-tokens
. This has little consequence when used with React since it already uses them, but when used outside React these are relatively heavy dependencies (as already noted in #126)Also as noted in #83 (comment), this way of writing invariant checks can cause significant performance penalty, since the error message arguments are always evaluated (unless combined with a compile-time code rewriter, but this project doesn't do that)
I would like to suggest at a minimum switching to use tiny-invariant, which is compatible with
invariant
except that it does not provide the%s
formatting. The library still works with compile-time code rewriters and does not have any dependencies (and is tiny itself).And better would be to also run the code through a transformer as part of the build process so that the built code only evaluates error arguments if the condition fails (or see my suggested improvement to tiny-invariant alexreardon/tiny-invariant#62 if a build-time transformation is not desirable).
The text was updated successfully, but these errors were encountered: