jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.25k stars 508 forks source link

Add closure compiler #358

Open jaredpalmer opened 4 years ago

jaredpalmer commented 4 years ago

Steal it from here : https://github.com/ReactTraining/history/blob/dev/rollup.config.js

ambroseus commented 4 years ago

1st impression: it works :) (test react app also works with compiled package) just need to tune up configuration for typescript2 plugin: https://github.com/ezolenko/rollup-plugin-typescript2#plugins-using-asyncawait objectHashIgnoreUnknownHack: true result: Screenshot from 2019-12-16 22-37-28

ambroseus commented 4 years ago

oh, I see difference in bundle size: minified with terser: ~ 13900 b with closure compiler: ~ 12700 b (compilation_level: 'ADVANCED_OPTIMIZATIONS')

swyxio commented 4 years ago

good! what are the tradeoffs of simple vs advanced optimization?

we should try running against formik to get a good gauge on % savings

nice work so far!

ambroseus commented 4 years ago

good! what are the tradeoffs of simple vs advanced optimization?

SIMPLE_OPTIMIZATIONS do same things as Terser plugin (and in my case optimized bundle size was little bit larger than terser's one) https://developers.google.com/closure/compiler/docs/api-tutorial3

BUT. there was a problem with 'ADVANCED_OPTIMIZATIONS' level in my lib with regeneratorRuntime polyfill

ambroseus commented 4 years ago

can be implemented as tsdx plugin

DrSensor commented 4 years ago

Dynamic import doesn't work on the closure compiler 🤔 https://github.com/google/closure-compiler/issues/2770