Hello,
Before migrating to Preact, I've been using this babel-preset to optimize some React code.
https://github.com/thejameskyle/babel-react-optimize
It includes 3 problematic parts:
https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-inline-elements
I believe these two doesn't work because of their React.createElement() usage under the hood, which is not compatibile with Preact's h()
https://github.com/thejameskyle/babel-react-optimize/tree/master/packages/babel-plugin-transform-react-pure-class-to-function
The problem is, it doesn't support Preact's render function's paramteres (props, state, context).
Even tho those 3 plugins aren't dealbreakers, they help a lot (both in terms of bundle size and runtime performance).
I think there are 3 possible solutions to this problem:
babel-plugin-optimize-preact (possibly with other static optimizations).What do you think about it?
Babel maintainer here.
It might be simpler to create a new dedicated plugin for Preact with specific optimizations.
@developit what optimizations are possible in Preact and not in React?
Agreed, a preact-specific preset would be best. As for the optimizations:
The same is true for Preact X. Only the first plugin will actually improve performance. Just use it directly馃憤
Most helpful comment
Agreed, a preact-specific preset would be best. As for the optimizations: