vuese / vuese

🤗 One-stop solution for vue component documentation. Original org: https://github.com/vuese
https://vuese.github.io/website/
MIT License
1.7k stars 119 forks source link

export default {...} vs const Something = {...}, export { Something } #33

Closed GastroGeek closed 4 years ago

GastroGeek commented 5 years ago

Describe the bug

export default {
 // this works OK?
}
const MyThing = {
 // this does not work OK
 // only slots is generated?
}

export default MyThing

To Reproduce Steps to reproduce the behavior: Use the cli tool to parse a single component 'IButton.vue' => 'IButton.md'. Nothing especially fancy. Component content is:

<template>
  <div class="inline-block button" :class="classList">
    <slot name="content"/>
  </div>
</template>
<script>
const classMap = {
  sm: 'px-5 py-3 bg-blue text-white hover:bg-red',
  md: 'px-5 py-3 bg-red text-white hover:bg-red',
  lg: 'px-5 py-3 bg-green text-white hover:bg-red'
}

const IButton = {
  name: 'IButton',
  props: {
    // The color of the button
    color: {
      type: String,
      default: 'blue'
    },
    size: {
      type: String,
      default: 'md',
      validator: value => ['sm', 'md', 'lg'].includes(value)
    }
  },
  computed: {
    classList() {
      return classMap[this.size]
    }
  }
}

export { IButton }
export default IButton
</script>

Expected behavior It should still work and generate all props, slots etc info

Which version do you use: "@vuese/cli": "^2.0.1"

HcySunYang commented 5 years ago

This is because vuese only treats export default {} as a component. But I don't understand why you use named export?

GastroGeek commented 5 years ago

OK, here goes...

Personal taste? consistent conventions? multiple exports? Refactoring large codebases where you may temporarily have said multiple exports from an SFC? the man himself added it to vue-loader (so again, consistency in the broader sense)? Tree shaking in certain scenarios? Because I am adding please to the request?

https://github.com/vuejs/vue-loader/releases/tag/v13.6.0

But seriously, this tool is great so thank you for making it regardless of your decision to allow named exports.

PS - Please allow named exports 👍

HcySunYang commented 5 years ago

Thanks for your information, I will seriously consider it.

IWANABETHATGUY commented 4 years ago

test should pass https://github.com/vuejs/vue-loader/issues/1080

IWANABETHATGUY commented 4 years ago

will be finished by #159

IWANABETHATGUY commented 4 years ago

will be released next version, if you have any question you could reopen it