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

[1.6.1] Missing Reflect in Internet Explorer 11 when app includes a class that extends a built-in class #9598

Closed
y-ich opened this issue Jan 30, 2018 · 2 comments

Comments

@y-ich
Copy link

y-ich commented Jan 30, 2018

Accessing an app by IE11 causes '"Reflect" is not defined' error in modules.js.

To reproduce it,

  1. meteor create reproduction.

  2. cd reproduction

  3. add the following code into client/main.js.

    class DummyError extends Error {}

  4. invoke meteor

  5. access the page by IE11.

Doesn't Babel 7 support IE11?

@abernix
Copy link
Contributor

abernix commented Jan 30, 2018

This seems related to changes in the way built-ins (e.g. Date, Uint16Array, Error, ...) are able to be extended in Babel 7 (surfacing in babel/babel#7020).

In Babel's wrapNativeSuper, the use of typeof Reflect is transpiled (when published) to use Babel's own _typeof helper function, which IE11 takes issue with (throws) as Reflect is undeclared. It ends up looking like this when shipped to the client:

var _construct = _typeof(Reflect) === "object" && _Reflect$construct || function _construct(Parent, args, Class) {
  var Constructor,
      a = [null];
  a.push.apply(a, args);
  Constructor = Parent.bind.apply(Parent, a);
  return _sPO(new Constructor(), Class.prototype);
};

A native typeof Reflect in IE11 does return "undefined", as expected, but the problem arises specifically with the use of _typeof(Reflect). Additionally, if the line above is changed to the following, everything seems to work okay in IE11:

var _construct = Reflect && _typeof(Reflect) === "object" && _Reflect$construct || function _construct(Parent, args, Class) {

I suppose Meteor could fix this by shipping Reflect polyfills in ecmascript-runtime-client, but this does seem like a bug in Babel and seeing as IE11 is one of two so-called "modern browsers" which doesn't natively support Reflect, it seems like a waste to ship that polyfill if we can avoid it.

This is my take, however @benjamn may know the cleanest way to fix this.

@benjamn benjamn changed the title 1.6.1 does not work on Internet Explorer 11 when app includes a definition of a class with extends [1.6.1] Missing Reflect in Internet Explorer 11 when app includes a class that extends a built-in class Jan 30, 2018
@benjamn benjamn added this to the Package Patches milestone Jan 30, 2018
@benjamn
Copy link
Contributor

benjamn commented Jan 31, 2018

I believe we can make this work with a patch update to ecmascript-runtime-client by adding just the Reflect.construct polyfill (which is a small subset of the whole Reflect polyfill). Then in Meteor 1.6.2 we can restrict that polyfill to legacy browsers (#9439), since modern browsers (as we're defining them—anything with native async/await) should all have native support for Reflect.construct.

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