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

export default should use const/let, not var. #653

Closed
zbraniecki opened this issue May 15, 2016 · 6 comments
Closed

export default should use const/let, not var. #653

zbraniecki opened this issue May 15, 2016 · 6 comments

Comments

@zbraniecki
Copy link

Currently, when exporting a default object, it assigns it using var which is unnecessary.

Example:

export default {
  foo: 1
};

rollup ./test.js

var test = {
  foo: 1
};

Instead, it should use const.

@eventualbuddha
Copy link
Contributor

This should be opt-in, if such and option existed. Rollup is most commonly used as the final step in bundling JavaScript libraries, so using const would render the output dependent on ES2015 features.

@zbraniecki
Copy link
Author

agree. I think we're at the point where we see projects that are targeting es6-compatible targets and rollup is used as a module bundler. I'd like to see this feature mostly for those scenarios so that using rollup doesn't mean regressing to es2015.

@nicolasparada
Copy link

Agree. Now I'm using:

const myModule = {
    foo: 'bar'
}

export default myModule

@Rich-Harris
Copy link
Contributor

Have raised #684

Rich-Harris added a commit that referenced this issue Jun 5, 2016
options.preferConst to use const instead of var when creating statements
@Rich-Harris
Copy link
Contributor

As of 0.26.6, you can use preferConst: true to use const instead of var in these situations

@zbraniecki
Copy link
Author

that works great! Thank you :)

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

5 participants