react-tracking icon indicating copy to clipboard operation
react-tracking copied to clipboard

Building/bundling react-tracking

Open tizmagik opened this issue 5 years ago • 6 comments

As per discussion in #119 we need a better way of bundling/building react-tracking. In v7.0.1 we had to move core-js@3 to a direct dependency, even though we don't need the entire library so that user-land doesn't need to adjust their babel configuration. This means we're reporting +40KB on bundlephobia which is misleading.

Maybe there will be some churn in the ecosystem as folks upgrade to core-js@3 and babel 7.4+ and better solutions/patterns will be established, but in the mean time, are there any ways to:

  1. Avoid having to include the entirety of core-js as a direct dependency
  2. Avoid having user-land have to modify babel configuration to use react-tracking (apart form decorators support, which is optional anyway.
  3. Keep it as simple as possible

Any thoughts/ideas/other libs you know about that have solved this in a better way please feel free to chime in!

Some ideas:

  • Use microbundle (WIP branch)
  • Use Rollup
  • Parcel/Webpack?
  • Other thoughts...?

tizmagik avatar May 21 '19 19:05 tizmagik

Hey, why not leave core-js implementation to userland? For example, we detect old browsers and load core-js for them only. We'd rather libraries not import their own core-js.

If you look at the modules ecosystem this practice is almost non-existent for this reason.

Would change library size from ~13kb to around ~3kb. I think userland is accustomed to having take care of polyfills

dortzur avatar Jul 17 '20 14:07 dortzur

Yea, ideally we would do that, but the tension was trying to keep the upgrade path as simple as possible since having core-js defined as a peerDependency means folks had to specify core-js@3 in their babel config which wasn't even an option before babel@7. More context in that other issue, #119

It's been some time since then so maybe worth revisiting, especially if, as you said, this is the common practice in other module ecosystems. In fact, if you can point me to a few examples, maybe we can bundle in the same way so there isn't an exception here.

I'd also be happy to review a PR to make this change if you're up for it, @dortzur . Thanks for commenting!

tizmagik avatar Jul 17 '20 14:07 tizmagik

Let's do it, polyfills are global and should be within consumer responsibility.

adi518 avatar Oct 12 '20 16:10 adi518

Happy to accept a PR

tizmagik avatar Oct 12 '20 16:10 tizmagik

I'll create a PR soon, thanks.

adi518 avatar Oct 12 '20 17:10 adi518

Done: #167

adi518 avatar Oct 20 '20 22:10 adi518