Deprecation testing and zero runtime cost in prod#791
Deprecation testing and zero runtime cost in prod#791BinaryMuse merged 3 commits intomkt/bundle-upfrom
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/primer/primer-components/hlfazcsks |
|
Since each deprecation has a |
emplums
left a comment
There was a problem hiding this comment.
This looks great! Thanks for running with this! 🙌 Do we need to add any docs anywhere about setting NODE_ENV?
|
@emplums We currently don't have any docs relating to using Primer Components with a module bundler. It's standard practice (at least in React apps) to compile using |
|
@BinaryMuse I think a small note in |
|
Merging this down to the base PR |
This PR builds on the Babel and compilation changes in #789 and @emplums' deprecation work in #777. It adds the following features:
a
useDeprecationhook that ensures we only log a deprecation warning to the console once if a component re-renders. For example:the ability to test for deprecations, e.g.:
a global test to ensure we're not shipping deprecated code that we meant to be removed:
zero runtime overhead in production
All the deprecation code is wrapped in
if (__DEV__), which gets compiled toif (process.env.NODE_ENV !== "production"). When a user bundles their code and setsNODE_ENVto"production", this changes toif (false)and minifiers will remove the entire function block