Skip to content
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

Promise polyfill not working on IE11 #858

Closed
nanomad opened this issue Feb 18, 2018 · 11 comments
Closed

Promise polyfill not working on IE11 #858

nanomad opened this issue Feb 18, 2018 · 11 comments

Comments

@nanomad
Copy link
Contributor

nanomad commented Feb 18, 2018

Version

3.0.0-beta.1

Reproduction link

https://github.com/nanomad/vue-cli-promise-test

Steps to reproduce

  • Create a new project via vue-cli (accepts the defaults)
  • Add the following to main.js
Promise.all([0]).then(function() {
  alert("ALL OK");
})
  • Run yarn serve
  • Open IE11

What is expected?

An alert with "ALL OK" appears

What is actually happening?

  • No alert
  • Error in console Unhandled promise rejection TypeError: 0 is not iterable!

Seems like the babel preset for vue is pulling in the wrong polyfill

@LinusBorg
Copy link
Member

LinusBorg commented Feb 19, 2018

No, the template works fine - Your Javascript is invalid. Promise.all() expects an array of Promise objects - you passed it an array containing a Number.

The error message tells you that Promise itself has been polyfilled - it's a promise rejection error after all, and it tells you that you passed it the wrong kind of content.

@nanomad
Copy link
Contributor Author

nanomad commented Feb 19, 2018

@LinusBorg Please re-open because the following fails as well:

var p = Promise.resolve(0);
Promise.all([p]).then(function() {
  alert("ALL OK");
});

with error:

Unhandled promise rejection TypeError: [object Object] is not iterable!

Also, it's totally legal to use an object in place of a promise. See:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all

@nanomad
Copy link
Contributor Author

nanomad commented Feb 19, 2018

Ok, so i've done some digging by playing around with the built-in babel preset (@vue/babel-preset-app).
Seems like the culprit is the following piece of code:

polyfill: false,
regenerator: false,

If I switch polyfill to true babel will insert the non-global polluting version of the Promise polyfill that works properly on IE10

@LinusBorg
Copy link
Member

Then the question is why the normal polyfill doesn't work on IE10?

And the side-question is why do you have to support IE10? Poor guy, you have my sympthy :(

I don't think we want to add the ponyfills from babel-transform, as some libs (like vuex) need them available as globals anyway, so we would have to include a polyfill as well, which would blow up code size etc.

@LinusBorg LinusBorg reopened this Feb 19, 2018
@nanomad
Copy link
Contributor Author

nanomad commented Feb 19, 2018

@LinusBorg I think I can manage to leave IE10 out but I was a bit surprised it didn't work since it was theoretically included in the list of supported browsers.

Given that I can reproduce it successfully without vue, do you think it may be worth opening a ticket in the babel repo? Maybe that combination is not supposed to work on IE10

@nanomad
Copy link
Contributor Author

nanomad commented Feb 19, 2018

Filed a babel issue, seems like a feature detection error on IE10

babel/babel#7395

@LinusBorg LinusBorg changed the title Promise polyfill not working on IE11 Promise polyfill not working on IE10 Feb 19, 2018
@nanomad nanomad changed the title Promise polyfill not working on IE10 Promise polyfill not working on IE11 Feb 19, 2018
@nanomad
Copy link
Contributor Author

nanomad commented Feb 19, 2018

@LinusBorg I'm dumb... It's IE11 (the one available on Windows 10)

@yyx990803 yyx990803 removed the 3.0 label Mar 1, 2018
@yyx990803
Copy link
Member

Looks like a fixing PR has been merged into Babel and should be fixed in the next Babel 7 release.

@yyx990803
Copy link
Member

Closed as it's fixed in Babel 7.0.0-beta.46

@drbdvd
Copy link

drbdvd commented Jul 22, 2018

I still get the same error with 7.0.0-beta.46

@LinusBorg
Copy link
Member

Then you should probably report that in the Babel repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants