use-axios-client icon indicating copy to clipboard operation
use-axios-client copied to clipboard

Optimize build artifact

Open zxqx opened this issue 5 years ago • 3 comments

Update our babel-plugin-transform-runtime config to specify exactly which runtime polyfills the library needs.

Currently we're using defaults:

{
  absoluteRuntime: false,
  corejs: false,
  helpers: true,
  regenerator: true,
  useESModules: false
}

We could maybe use babel-plugin-transform-regenerator to more granularly specify runtime transforms.

zxqx avatar Oct 04 '19 20:10 zxqx

We may want to consider one of these two options:

  1. Use Promise instead of async/await in useBaseAxios
  2. Use something like babel-plugin-transform-async-to-promises to transform async/await to native Promise calls to remove the need for regenerator runtime

Ran a few test builds and it looks like either one of these will reduce the build artifact size by 25-30%.

zxqx avatar Oct 07 '19 17:10 zxqx

If we implement https://github.com/angelle-sw/use-axios-client/pull/97, I think we would just need to specify a node target in the @babel/preset-env config along with a browserslist entry in package.json and the rest should be taken care of (in theory 😄 ).

therealparmesh avatar Dec 19 '19 14:12 therealparmesh

That would be sick - will do a comparison of the current build artifact size vs. the one generated by pika and report back.

zxqx avatar Dec 19 '19 16:12 zxqx