-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seems to not work with resize-observer-polyfill #7
Comments
@eniovalo just saw this now, sorry for the delay! |
@eniovalo I tried re-creating the issue on my end, but I'm not seeing it the Do you think you could create a minimal setup (either based on the example folder in the project or as a brand new gist / github repo), that shows this issue? I want to be sure I can recreate the issue on my machine before I start debugging more. |
@eniovalo I see the $1 in the builds, but the way these functions are setup, I believe they will still put a |
Just verified that none of the builds work with IE, but that is because IE needs the code to be transpiled (probably with babel). If you can get a version that shows the error in IE (or any browser), that would be useful. |
@JRJurman , I tested the 3 builds (iife, commonjs and umd) with Firefox ESR 68.7 and it failed ResizeObserver is not defined because So, I put resize-observer-polyfill with rollup-plugin-polyfill to make it compatible, but it generates ResizeObserver$1. If you change ResizeObserver$1 to ResizeObserver at bundle.js (line 893), it will work at IE. =] |
Reading the documentation for resize-observer-polyfill, it "recommends" using it as a ponyfill https://github.com/que-etc/resize-observer-polyfill#usage-example but in reality, you have to use it as a ponyfill, see que-etc/resize-observer-polyfill#68 It occurs to me that this would be incompatible with rollup-plugin-polyfill, as we assume that the polyfill should populate the global (as they usually do). It seems that your usage (at least in the examples you've provided) are not compatible with the usage of the resize-observer-polyfill library. Conversely, you could write a wrapper around resize-observer-polyfill which populates the global with a ResizeObserver, and then polyfill that wrapper! That should work just fine 👍 |
@JRJurman , thanks. |
@JRJurman , rollup-plugin-polyfill worked with a wrapper of resize-observer-polyfill. import ResizeObserver from 'resize-observer-polyfill';
//Finding the global variable.
const myGlobal = (function () {
if (typeof global !== 'undefined' && global.Math === Math) {
return global;
}
if (typeof self !== 'undefined' && self.Math === Math) {
return self;
}
if (typeof window !== 'undefined' && window.Math === Math) {
return window;
}
})();
//If ResizeObserver doesn't exist, set the Polyfill.
if(!myGlobal.ResizeObserver) {
myGlobal.ResizeObserver = ResizeObserver;
} |
Hi,
I was trying to include resize-observer-polyfill, but it seems to not work. I think this plugin or rollup is adding $1 at the name of the polyfill.
Example:
ResizeObserver
turns toResizeObserver$1
I used rollup-plugin-inject or an Import
import ResizeObserver from 'resize-observer-polyfill'
but I think it would be more legible if I use rollup-plugin-polyfill. ;)Below some code of my tests:
Thanks.
Code of ResizeObserver Polyfill
Using rollup-plugin-polyfill
Rollup config:
Generated file after rollup - Polyfill:
Generated file after rollup - Usage:
It results at
ResizeObserver is not defined
because rollup generated a polyfill named ResizeObserver$1 insted of ResizeObserverImporting directly the polyfill
Rollup config:
Importing ResizeObserver Polyfill directly in the code:
Using rollup-plugin-inject
Rollup config:
Importing directly and rollup-plugin-inject generate the same code that works
Generated file after rollup - Polyfill:
Generated file after rollup - Usage:
The text was updated successfully, but these errors were encountered: