brunch / brunch.github.io

The website
https://brunch.io
MIT License
114 stars 99 forks source link

"module.exports" vs "exports" in brunch-config.js examples #269

Closed wam closed 7 years ago

wam commented 7 years ago

Some of the brunch-config.js examples on the site use module.exports at the top level, but the default dead-simple skeleton uses plain exports.

For example, the concepts page shows this as the simplest possible config:

module.exports = {
  files: {
    javascripts: {joinTo: 'app.js'},
    stylesheets: {joinTo: 'app.css'}
  }
}

but if you run brunch new projectname (v2.10.9), you actually get:

exports.files = {
  javascripts: {joinTo: 'app.js'},
  stylesheets: {joinTo: 'app.css'}
};

Should the examples on the site be brought up to date with the current output of brunch new? I looked through a random sample of skeletons and some of them do use module.exports, and both ways currently work. But exports at the top level seems to be the default.

I'm happy to submit a PR with changes to the relevant examples.

denysdovhan commented 7 years ago

Well, that's the matter of taste. Personally, I prefer to use module.export notation. Think about it as export default from ES2015, while export.[name] is like export [name].

I agree that we need to find some consistency in our configs around the docs, but that's not the most important task we need to solve on the way to better Brunch.

wam commented 7 years ago

That is a very useful way of thinking about it. Thanks!

My concern was mostly that, as a newcomer to Brunch, at first I wasn't sure whether it was simply a matter of style, or if there were subtle differences in behavior, or if I'd done something wrong, or if the docs were out of date with the code.

Anyway, if you do end up wanting to change it in the docs at some point, I'd be happy to tackle that.