logue / vite-vue2-vuetify-ts-starter

@vitejs template for @vuejs 2+@vuetifyjs+TypeScript
MIT License
84 stars 31 forks source link

feature request: Global injection of decorators #1

Closed ngjuping closed 2 years ago

ngjuping commented 2 years ago

Hi logue,

As components grow in quantity, repetitive imports of decorators such as Component and Prop from vue-property-decorator becomes bulky. In this template, auto import of components is achieved by components.d.ts which declares component globally. Is there something similar to this that can be done to remove the imports of decorators as well?

Best regards, Ju Ping

logue commented 2 years ago

I agree. I'm wondering what happened. For now, try setting the line in vite.config.ts to false or commenting it out.

https://github.com/logue/vite-vue2-vuetify-ts-starter/blob/74c1e2f935f8de82b2e1c8181e53175a06655a49/vite.config.ts#L49

Not only is the build slower, but it is recreated every time devserver is started, so I was wondering if it should be set to true by default.

ngjuping commented 2 years ago

Hi logue,

I have tried changing that but eslint still complains about the decorator not found...

error 'Component' is not defined

Any ideas?

logue commented 2 years ago

I found out what caused the build to be heavy, but it wasn't. Also, since unnecessary settings were included, it was supported in 0.4.7.

Hi logue,

I have tried changing that but eslint still complains about the decorator not found...

error 'Component' is not defined

Any ideas?

Are you using any external component library (such as vue-codemirror6 or vuetify-swatches )?

If you feel something is wrong, please run yarn run clean.

ngjuping commented 2 years ago

Hi logue,

I think I have delivered my confusion incorrectly.

Here's what I expected:

<script lang="ts">
@Component
export default class App extends mixins(Global) {}
</script>

No imports for Component decorator required. I have tried doing this in main.ts: global.Component = Component

and use it like @global.Component , which has failed.

Do you think this is a good idea?

logue commented 2 years ago

I think it's because the following line is missing.

import { Component, Vue } from 'vue-property-decorator';

There should have been no way to omit it in vue2... Also, Vue 2.7, which is currently in alpha release, supports composition api by default, so due to conflicting concerns, we have no plans to implement it, if possible.