bublejs / buble

https://buble.surge.sh
MIT License
869 stars 67 forks source link

JSX Only? #213

Closed curran closed 4 years ago

curran commented 5 years ago

I have a use case where I only need the JSX feature of Bublé, and I'm using it in the browser.

The issue I have is that all the unused logic for varous ES6 transpilation features is included in the bundle (my app bundle, which includes Bublé as part of it).

Is there any way to tree-shake Bublé itself so that only the JSX-related logic is included?

curran commented 5 years ago

Nevermind - I just discovered a way to use JSX only with Rollup (which is what I need), from https://rollupjs.org/guide/en/#acorninjectplugins

import jsx from 'acorn-jsx';

export default {
    // … other options …
    acornInjectPlugins: [
        jsx()
    ]
};
curran commented 5 years ago

Reopening as I tried the acornInjectPlugins approach, and realized that it just outputs the JSX, it doesn't transpile it.

curran commented 5 years ago

I forked Bublé and removed all the non-JSX transforms: https://github.com/datavis-tech/buble-jsx-only

Minified & gzipped size comparisons:

Probably could be optimized further, but this is quite satisfying.

mourner commented 4 years ago

Thanks for taking on this!