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

Unnecessary __default #46

Closed
Rich-Harris opened this issue Jan 10, 2015 · 0 comments
Closed

Unnecessary __default #46

Rich-Harris opened this issue Jan 10, 2015 · 0 comments

Comments

@Rich-Harris
Copy link
Contributor

Most of the time, this...

var foo = require('foo');
var foo__default = ('default' in foo ? foo['default'] : foo);

foo__default();

...is unnecessary. If we're only using the default import (as is always the case in non-strict mode, by definition, and often the case in strict mode), then we don't need the original foo reference. So the code could be written more neatly:

var foo = require('foo');
foo = ('default' in foo ? foo['default'] : foo);

foo();

It's only on the rare occasions that we import both default and named bindings from external modules that we need to do the __default dance.

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

1 participant