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

do not wrap default-exported functions in object literals #65

Merged
merged 2 commits into from Apr 3, 2019

Conversation

bakkot
Copy link
Member

@bakkot bakkot commented Apr 2, 2019

On master, export default (function f (){}); compiles to

(function(e) {
  'use strict';
  var w = { default: function f() {} }.default;
  var r = { __proto__: null, default: w };
  if (e.Symbol)
    e.Object.defineProperty(r, e.Symbol.toStringTag, { value: 'Module' });
  r = e.Object.freeze(r);
  return r;
})(this);

Now it compiles to

(function(e) {
  'use strict';
  var w = function f() {};
  var r = { __proto__: null, default: w };
  if (e.Symbol)
    e.Object.defineProperty(r, e.Symbol.toStringTag, { value: 'Module' });
  r = e.Object.freeze(r);
  return r;
})(this);

There's also a test that default exports work, because I'm not sure they were sufficiently stressed before.

Contains version bump commit, so please rebase, not squash.

@bakkot bakkot requested a review from Protryon April 2, 2019 22:35
@bakkot
Copy link
Member Author

bakkot commented Apr 2, 2019

It's plausible this breaks function name inference in some cases, but it's already pretty broken (see #64), so I don't think we should worry about that.

@Protryon Protryon merged commit e4963b3 into es2017 Apr 3, 2019
@Protryon Protryon deleted the fewer-function-names branch April 3, 2019 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants