react-tracking
react-tracking copied to clipboard
Building/bundling react-tracking
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:
- Avoid having to include the entirety of core-js as a direct dependency
- Avoid having user-land have to modify babel configuration to use react-tracking (apart form decorators support, which is optional anyway.
- 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...?
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
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!
Let's do it, polyfills are global and should be within consumer responsibility.
Happy to accept a PR
I'll create a PR soon, thanks.
Done: #167