Timkor/nuxt-polyfill

Polyfill Object.entries

Closed this issue ยท 8 comments

Hi! First thank you for this awesome module. It makes polyfilling much easier.
I want to polyfill Object.entries, using this npm package:
https://www.npmjs.com/package/object.entries

What's wrong with my code?

 {
        require: 'object.entries',
        detect: () => 'entries' in window.Object,
        install: entries => entries.shim(),
 }

@mornir
Thank you.

Your code does look correct.

What error are you getting? Or what behaviour is not working for you?

In IE11, I still get the error Object doesn't support property or method 'entries' ๐Ÿค”

Can you try this and see if shimmed is logged into the console of IE11?

{
        require: 'object.entries',
        detect: () => 'entries' in window.Object,
        install: entries => {  
                entries.shim()
                console.log('shimmed')
        }
 }

No, it's not logged. ๐Ÿ˜•

I don't know if this information is useful: the method 'entries' is used in this package https://www.npmjs.com/package/vue2-google-maps, which I import as a Nuxt plugin.

If I import the polyfill via polyfill.io, it works.

Can you post your Nuxt plugin here?

I made a pull request.

The polyfills are loaded subsequentially and only available in the default exported function of a plugin.

https://github.com/mornir/sounding-soil/pull/10

Awesome! It works! Thanks! ๐Ÿ˜ƒ