nuxt-community / nuxt-property-decorator

Property decorators for Nuxt (base on vue-property-decorator)
https://github.com/kaorun343/vue-property-decorator
MIT License
400 stars 34 forks source link

nuxt-class-component and nuxt-property-decorator #25

Closed husayt closed 5 years ago

husayt commented 5 years ago

This library is currently doing whatever nuxt-class-component doing and bit more. So it is not dependant on nuxt-class-component as it says in the beginning of readme. So we can change that statement. Better to say that this library includes all nuxt-class-component features and examples on it's readme pretty much apply here to.

But maybe even better option is to merge them. There is certainly a case in favour of merging the two libraries together, since they are both small libraries and are very similar and overlap. They are both parts of nuxt-community and this will be clearly in the interests of nuxt community. Many people including myself are confused when to use which of them.

Currently nuxt-property-decorator has all the functionality so it can become the new umbrella and we can change name to better accommodate for both use cases (nuxt-class-tools). That will be very timely, since latest nuxt adds enhanced typescript support.

@breakingrobot @alexchopin @pi @DavidBernal @Atinux and others what do you think?

qm3ster commented 5 years ago

I am very negative about this library duplicating the decorators from https://github.com/kaorun343/vue-property-decorator. At a glance, I don't see it doing anything more than that one. I see there have recently been PRs merged to this, but they would be of more use at the origin, unless similar have already been deployed there. Furthermore, like you pointed out, instead of importing nuxt-class-component, it just copies it to the top of the file: https://github.com/nuxt-community/nuxt-property-decorator/blob/70a3e6d7dc7be382392841417485482f00930fcb/src/nuxt-property-decorator.ts#L4-L18

Furthermore, due to how registerHooks is implemented, this actually contaminates the normal Component decorator, which some might import directly in non-page components.

I strongly suggest that this module be taken out behind the barn.

I know this will be controversial, as it may increase, visually, the number of inputs in some cases, but I would also vote to neuter nuxt-class-component to the following:

import Component, from 'vue-class-component'

Component.registerHooks([
  'beforeRouteEnter',
  'beforeRouteLeave',
  'asyncData',
  'fetch',
  'head',
  'middleware',
  'layout',
  'transition',
  'scrollToTop',
  'validate'
])

export Component

If someone wants to import all of vuex-class, vue-class-component, vue-property-decorators and nuxt-class-component all the time, they can re-export them themselves, in a single short file inside their project. It's not rocket surgery.

husayt commented 5 years ago

Mihal, also see #27. I touched most of these points there and made a suggestion.

On Thu, 6 Dec 2018, 23:00 Mihal Malostanidis <notifications@github.com wrote:

I am very negative about this library duplicating the decorators from https://github.com/kaorun343/vue-property-decorator. At a glance, I don't see it doing anything more than that one. I see there have recently been PRs merged to this, but they would be of more use at the origin, unless similar have already been deployed there. Furthermore, like you pointed out, instead of importing nuxt-class-component, it just copies it to the top of the file:

https://github.com/nuxt-community/nuxt-property-decorator/blob/70a3e6d7dc7be382392841417485482f00930fcb/src/nuxt-property-decorator.ts#L4-L18

Furthermore, due to how registerHooks is implemented, this actually contaminates the normal Component decorator, which some might import directly in non-page components.

I strongly suggest that this module be taken out behind the barn.

I know this will be controversial, as it may increase, visually, the number of inputs in some cases, but I would also vote to neuter nuxt-class-component to the following:

import Component, from 'vue-class-component' Component.registerHooks([ 'beforeRouteEnter', 'beforeRouteLeave', 'asyncData', 'fetch', 'head', 'middleware', 'layout', 'transition', 'scrollToTop', 'validate' ]) export Component

If someone wants to import all of vuex-class, vue-class-component, vue-property-decorators and nuxt-class-component all the time, they can re-export them themselves, in a single short file inside their project. It's not rocket surgery.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nuxt-community/nuxt-property-decorator/issues/25#issuecomment-445061571, or mute the thread https://github.com/notifications/unsubscribe-auth/ABHXrC48YKpomQMXPjmnMQbqPvs-jnodks5u2aGIgaJpZM4ZAvGi .

qm3ster commented 5 years ago

@husayt we can reexport the exports of vuex-class and vue-class-component, directly or from nuxt-class-component, and reexport third-party vue-property-decorators... Or we can deprecate this module.

husayt commented 5 years ago

Coming back to this chain as over last few months I have resolved some of the issues highlighted here. It is not using nuxt-class-component anymore. It's making it easy to write class based TS/JS components with Nuxt, unlocking all the coolness from vue-class-component , vue-property-decorator and vuex-class and adding nuxt specific hooks and decorators. Also this completely deprecates nuxt-class-component