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
feat(babel-preset-gatsby): add babel-plugin-transform-react-remove-prop-types for production builds #14987
feat(babel-preset-gatsby): add babel-plugin-transform-react-remove-prop-types for production builds #14987
Conversation
…stalled when developing but nev #14814
…ugin-transform-react-remove-prop-types
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.
Thank you for this @luisFilipePT 🥇
Left a small comment!
should we expose some config like |
@neo We could definitely add |
…plugin-transform-react-remove-prop-types
@neo You can modify babel with .babelrc - see https://www.gatsbyjs.org/docs/babel/#how-to-use-a-custom-babelrc-file |
yea, that's what I figured – I was just curious about where do we draw the line. |
Proptypes is used in a lot of dependencies as it's the only runtime check supported by react. We want to be as fast and as small as possible. Having good defaults is key so removing prop-types by default in production makes a lot of sense. |
…op-types for production builds (gatsbyjs#14987) * feat(babel-preset-gatsby): Add babel-plugin-transform-react-remove-prop-types to babel-preset-gatsby Remove PropTypes from production build re gatsbyjs#14814 * docs(babel-preset-gatsby): Add babel-plugin-transform-react-remove-prop-types link to README in #pac re gatsbyjs#14814 * test(babel-preset-gatsby): Add test - in production mode specifies proper presets gatsbyjs#14814 * fix(babel-preset-gatsby): Remove core-js package from package.json installed when developing but nev gatsbyjs#14814 * refactor(babel-preset-gatsby): Use GATSBY_BUILD_STAGE in place of BABEL_ENV || NODE_ENV gatsbyjs#14814 * test(babel-preset-gatsby): Remove beforeEach in tests on production env gatsbyjs#14814 * update lock file * update tests * fixup after merge conflict resolution/small refactor
PR Checklist
Purpose of this PR
What kind of change does this Pull Request introduce?
Changes
Remove PropTypes from production build by adding babel-plugin-transform-react-remove-prop-types.
This change removes PropTypes and their imports from the production build.
This change DOES NOT remove proptypes from dependencies from external packages (in
node_modules
)Is there anything you would like reviewers to focus on?
No
Does this PR introduce a breaking change?
Related issue
Closes #14814.
Reviewers
Gatsby team?
Additional Reviewers
Please review: @sidharthachatterjee @neo @wardpeet