container-query icon indicating copy to clipboard operation
container-query copied to clipboard

Revisit polyfilling

Open ZeeCoder opened this issue 7 years ago • 4 comments

It might worth reconsidering the polyfilling issue. Originally I shipped all necessary polyfills to make it easier to adapt the library, but that comes with some cons:

  • Shipping the polyfill adds extra weight to the lib
  • If the polyfill is applied automatically, then that could be applied before the app developer applies its own polyfill => this could result in hard to debug situations, where this lib would polyfill something sooner than the app developer.

Using something like polyfill.io, or just a separate polyfill js file made by the app author should be an easy enough thing to do, since I'm already assuming a lot of knowledge with these modules anyway.

Anyway, needs some more research into polyfilling best practices.

ZeeCoder avatar Dec 05 '17 13:12 ZeeCoder

I wonder if it would be possible to ship polyfilled and non-polyfilled versions. 🤔

ZeeCoder avatar Dec 05 '17 13:12 ZeeCoder

note: Look into babel-preset-env, which is supposedly able to auto-polyfill source code by injecting require statements where needed. (It still probably doesn't polyfill ResizeObserver though.)

ZeeCoder avatar Dec 28 '17 12:12 ZeeCoder

Still no easy solution for this (https://github.com/w3ctag/polyfills/issues/6) but shipping a polyfilled / /non-polyfilled version seems like the best way for now. (Where polyfills should be included in the lib in a way that does not affect globals.)

ZeeCoder avatar Feb 04 '18 16:02 ZeeCoder

UMD support will probably need to be dropped, as automatic polyfilling causes some weird issues with it. (cjs, esm are both fine) I can polyfill most things automatically, but ResizeObserver will be a harder nut to crack: https://github.com/babel/babel/issues/7328

ZeeCoder avatar Feb 04 '18 23:02 ZeeCoder