ResizeObserver polyfill does not work when bundled
See original GitHub issueWhat
ResizeObserver is undefined
when the RO polyfill script is used.
repro: https://codesandbox.io/s/polyfill-io-resizeobserver-failing-to-install-t3pwln?file=/src/polyfill.js
Details
Required setup:
- Use Safari (or any browser that doesn’t have Resize Observer)
- Go to Safari devtools and disable Resize Observer ** Develop > Experimental Features > Uncheck Resize Observer
- go to https://t3pwln.csb.app/
Upon visiting that page you’ll see ReferenceError: Can't find variable: ResizeObserver
I’m at a bit of a loss why this isn’t working.
What I’ve done is just copy/paste the output from https://polyfill.io/v3/polyfill.js?version=3.110.1&features=ResizeObserver
using a spoofed UA of
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/E7FBAF
But whats really mind bending is if I use the polyfill.io script in the index.html
the polyfill works as expected.
What am I missing here?
Issue Analytics
- State:
- Created a year ago
- Comments:10
Top Results From Across the Web
ResizeObserver Polyfill creates errors with Webpack & UglifyJS
Looks like 1.4.x uses ResizeObserver polyfill which created the above error when webpack & uglifyjs are bundling. Technically you would be ...
Read more >Loading polyfills conditionally & bundles - Stack Overflow
Say I have my index file which is the main file exported with the library, should I add this statement outside the function...
Read more >4lolo/resize-observer-polyfill - npm
A polyfill for the Resize Observer API. Implementation is based on the MutationObserver and uses Mutation Events as a fall back if the...
Read more >resize-observer-polyfill v1.5.1 Bundlephobia
Size of resize-observer-polyfill v1.5.1 is 7.8 kB (minified), and 2.5 kB when compressed using GZIP. Bundlephobia helps you find the performance impact of ......
Read more >resize-observer-polyfill/README.md - UNPKG
The CDN for resize-observer-polyfill. ... (has style problems in IE10 and lower). 14. 15, ## Installation ... Creates UMD bundle in the `dist`...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Apologies, this appears to be something with how we bundle the polyfills that breaks the UMD in this case. Will investigate locally.
Agree! This is a tricky problem…
On my end I can always patch the package to modify the RO implementation to work for us if a change here is seen as too risky. So far changing it to use
exports
has been fruitful but I can’t guarantee anything outside of my usage