Timkor / nuxt-polyfill

Ease adding polyfills to your Nuxt.js project
MIT License
97 stars 1 forks source link

Question - How to use for IE 11 ? #2

Closed nicolas-bonnel closed 5 years ago

nicolas-bonnel commented 5 years ago

Hello,

I'm having hard time making my app run on IE 11. This module seems interesting, but I can't figure how to configure it.

My error on IE 11 is : "object doesn't support property or method from"

How can I configure your module to detect this error and import the correct polyfill ?

Thanks in advance !

Timkor commented 5 years ago

Hi,

Can you give me a more specific error message?

I guess it's about Array.from, but that strange because it should be polyfilled automatically by Nuxt since it uses core-js.

Can you also supply your nuxt.config.js?

nicolas-bonnel commented 5 years ago

Thanks for your feedback.

You're right, I had a bugged version of nuxt and core-js were not used. That's now ok and I begin to understand the use for your module : to load polyfills not supported with core-js.

I still have a problem : I need the url-polyfill because an URL object is created in the store, in a function init() called by a plugin. Using your module the url-polyfill plugin is loaded and added as a new plugin, I believe before my init plugin (you insert them with unshift), but is not yet loaded when the init execute.

Adding a require('url-polyfill') in my init plugin, before calling store action works, so I believe my problem is the loading order.

Another difference is that my init plugin is loaded server side, whereas your plugin is not, but my app is built in spa mode...

Timkor commented 5 years ago

Hi Nicolas,

You are right. This module puts the polyfill plugins in front of the other plugins. But apparently Nuxt initializes all plugins which are rendered server side before that moment.

This issue has now been fixed.

Try to use the URL polyfill only within the exported default function of your plugin:

// URL is NOT available here yet.

export default () => {
    // URL is available here:
    new URL('https://google.nl');
}

Please install the latest version of this package:

npm i nuxt-polyfill@1.0.2