chore: keep prop-types if mode is not production #372
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
@tdeekens made a good write up about the problem here.
TL;DR: It will be easier for our consumers to use
ui-kit
if they get prop-types warnings during development.Approach
Use mode
wrap
from babel-plugin-transform-react-remove-prop-types.Which transforms our propTypes into
Why not
unsafe-wrap
? There's an open issue with using unsafe wrap when you use propTypes from variables, as we do inText.Headline
and (I believe?) some other components.Another possible approach
Use
unsafe-wrap
but stop using variables as propTypes. IE, copy pastenonEmptyString
into the propType declarations in each other Text components.This gives the output of
If we go with this approach, perhaps we can create a custom linter rule that doesn't allow variables for proptypes? 🤔
TL;DR
The second approach will produce a nicer production bundle, at the expense of having to duplicate custom propTypes, and without some sort of custom linter rule, it would be difficult to explain to developers why their code is breaking when they are using variables as proptypes...
WDYT?