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

Projects
None yet
2 participants
@bakkot
Copy link
Collaborator

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 Apr 2, 2019

@bakkot

This comment has been minimized.

Copy link
Collaborator 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.

@bakkot bakkot force-pushed the fewer-function-names branch from 91b2602 to 148bddb Apr 2, 2019

@Protryon Protryon merged commit e4963b3 into es2017 Apr 3, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@Protryon Protryon deleted the fewer-function-names branch Apr 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.