gilbarbara / react-floater

Advanced tooltips for React
https://codesandbox.io/s/github/gilbarbara/react-floater/tree/main/demo
MIT License
220 stars 37 forks source link

Add UMD build #59

Closed perliedman closed 4 years ago

perliedman commented 5 years ago

Hi, and thanks for a very nice component library!

Since I am still in an old build setup, I rely on libraries being bundled up as UMD or IIFE. I have added an IIFE build to the project to support this, and I guess it might be of use to other people in my situation.

This change bundles the component together with the project's dependencies, but leaves out the peer dependencies, which I guess makes most sense for a standalone browser bundle.

I had to make an inelegant hack to solve a problem where global for some reason is not properly polyfilled in the IIFE build - I am too inexperienced with Babel to understand why this is, but it seems other people have the same problem: https://github.com/rollup/rollup-plugin-commonjs/issues/6#issuecomment-526447762 - please tell me if you know of a better way to solve this (or if there is anything else that needs to be addressed in this PR, of course!)

perliedman commented 5 years ago

I notice DeepScan reporting an error, but from what I can tell it is not related to the changes I made. Is it possible that the warning was already there before my PR?

gilbarbara commented 5 years ago

Hey, Thanks for the PR. You are the first person to talk about UMD/IIFE in all my packages, so I don't think a lot of people still use it. How do you optimize bundles? 😜

Anyway, I'm rewriting this library with TypeScript and I'll stop using rollup. I don't think it's possible to generate IIFE with it, so can you update the setup to use UMD?

And the DeepScan error is a new check they've added, so not related to this PR.

perliedman commented 5 years ago

Yeah, I know it's a bit old school to bundle things like that, and regarding optimizing bundles: we don't :smile: I mean, the bundle ends up with whatever duplication our dependencies happen to include (and surprisingly many libs still include IIFE/UMD builds). Far from ideal, and definitely one of the things I'm less happy about, but for now I just need to deal with it.

Anyway, I converted to UMD, it works for my very limited test.