New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecation testing and zero runtime cost in prod #791
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
useDeprecation
hook 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_ENV
to"production"
, this changes toif (false)
and minifiers will remove the entire function block