babel-plugin-flow-react-proptypes
babel-plugin-flow-react-proptypes copied to clipboard
Add an option for adding NODE_ENV checks for minifiers
Consumers of a library should be able to access the library's proptypes in dev builds, but then be able to seamlessly strip them out for production.
See conversation on https://github.com/brigand/babel-plugin-flow-react-proptypes/issues/70#issuecomment-278551711.
TODO:
- [x] add deadCode config option (see readme)
- [x] dce for the propTypes object
- [x] dce for exported types (export type Foo =)
- [ ] dce for imported types (import type {Foo} from './Foo)
- [ ] dce for the actual 'propTypes' property, both with the default assignment at end of file, and the the useStatic option (currently propTypes=null after minify)
Hi, tried dead code and running into issues with deadCode: true
Error: Error: No substitution given for "NODE_ENV". If this is not meant to be a
placeholder you may want to consider passing one of the following options to @babel/template:
- { placeholderPattern: false, placeholderWhitelist: new Set(['NODE_ENV'])}
- { placeholderPattern: /^NODE_ENV$/ }
any suggestion on fix?
@dlebedynskyi Thanks for the report, should be fixed in 24.1.2
@brigand confirmed, working now. Thank you