question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removing propTypes in production build?

See original GitHub issue

What do you think about removing the propTypes in the production build to reduce the bundle size using babel-plugin-transform-react-remove-prop-types?

I’ve already prepared a fork, so if you think it is a good idea, I can submit a pull request.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:13
  • Comments:39 (24 by maintainers)

github_iconTop GitHub Comments

17reactions
gaearoncommented, Jun 7, 2017

To be honest I feel like it might have been better to actually enforce stripping propTypes in user code. We might make a breaking change like this in the future.

We definitely don’t recommend relying on propTypes for any runtime behavior. It’s not at all obvious, and can lead to confusing times for anyone working on the project in the future.

5reactions
gaearoncommented, Jul 26, 2016

I think there are some valid use cases for accessing it, like

DangerButton.propTypes = {
  ...Button.propTypes,
  somethingElse: ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing propTypes on Production > React with Symfony
This is a Babel plugin that can remove propTypes. Copy the library name, find your terminal, and get it!
Read more >
How to remove React PropTypes from production rollup build?
You can use transform-react-remove-prop-types babel plugin with options removeImport: true . So this condition finally remove prop-types ...
Read more >
gatsby-plugin-babel-remove-prop-types
Gatsby plugin for removing unnecessary React propTypes from the production build by implementing babel-plugin-transform-react-remove-prop-types.
Read more >
How to use babel-plugin-transform-react-remove-prop-types
devMode && [ // Remove PropTypes from production build require('babel-plugin-transform-react-remove-prop-types').default, { removeImport: true, } ...
Read more >
Optimizing React apps: Hardcore edition - DEV Community ‍ ‍
Remove prop-types from your production bundle ... PropTypes are incredibly helpful during development, but they are of no use for your users. You ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found