stencil
stencil copied to clipboard
feat: expose `Fragment` on `h`
This way it's possible to set jsxFragmentFactory to h.Fragment in tsconfig, so that <></> syntax can be used without having to import Fragment explicitly (just importing h is sufficient).
The broken test is from eec7651fa723658c2c8d853dc44b6316709b2317 (see https://github.com/ionic-team/stencil/runs/1796291494). All other tests pass locally.
This is kind of cool!, i like it. My only concern is so performance regression because adding a property to an arrow function is disables some V8 optimization.
Wondering how we could check that
Interesting, I didn't know that. Is this different when using a normal function h instead of assigning an anonymous arrow function to h? Do you have a link that explains this optimization? Is there a way to measure the impact of this?
BTW In the meantime what I did was to patch h at runtime with a globalScript.
import { h, Fragment } from '@stencil/core;
export default () => {
if (!('Fragment' in h)) {
h.Fragment = Fragment;
}
}
(breaks spec tests with newSpecPage though)
Hm, idea:
const h = () => { /* ... */ }
export default h
export const Fragment = (_, children) => children
import h from './h'
export { h }
Never mind, mixing default and named exports doesn't seem to work with Rollup (see repl).