Add babel-plugin-transform-remove-prop-types Babel plugin #839
Conversation
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.
Tested and everything seems to work fine: all blocks load without problems and an error is still raised when props are invalid.
@@ -105,7 +105,10 @@ const GutenbergBlocksConfig = { | |||
use: { | |||
loader: 'babel-loader?cacheDirectory', | |||
options: { | |||
presets: [ '@wordpress/default' ], | |||
presets: [ '@wordpress/babel-preset-default' ], |
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.
I'm a bit confused with this. In @wordpress/babel-preset-default
docs it recommends using "presets": [ "@wordpress/default" ]
.
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.
Hmm ya, essentially I just noticed that the full form was being used everywhere in Gutenberg (but not that the docs were just recommending the shorthand). Incidentally, I asked about this in #core-editor slack and I learned about shorthands for presets - which I didn't know about.
So the original was sufficient. However, I'd prefer the longform because imo it's a bit clearer what package is providing the preset. Happy to change back though?
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.
Oh, I didn't know about this either. Thanks for posting the explanation!
So the original was sufficient. However, I'd prefer the longform because imo it's a bit clearer what package is providing the preset. Happy to change back though?
Agree, let's keep the long name.
This babel plugin will remove prop-types from production builds (prop-types remain in developer builds) bringing some file size savings. The file-size savings are minimal but could add up over time.
Changes in file size on production builds:
How to test the changes in this Pull Request:
This affects any production builds because the plugin does remove any prop-type definitions. So there should be a run through of each block type inserted/edited in posts to ensure there's no console errors. Any issues should surface immediately as they would typically be syntax type errors.
Changelog