wheatjs / vite-plugin-vue-type-imports

Import types in Vue SFC for defineProps
223 stars 18 forks source link

Transform `.vue` file test can miss matching valid files #50

Open smcenlly opened 1 year ago

smcenlly commented 1 year ago

The transform test code:

https://github.com/wheatjs/vite-plugin-vue-type-imports/blob/8de15f91cbab7672848a43bb0e68a4cd20c739dd/src/vite.ts#L15

expects the file to end in .vue. This may/may not be the case depending on upstream transformations.

Specifically, some other vue plugins can append querystring suffix on the files and then this transform fails to run resulting in errors.

For example, the filename may be:

/components/TheHeader/TheHeader.vue?vue&type=style&index=0&scoped=0d34c1b2&lang.scss

or, in the case of our plugin, it was:

/components/TheHeader/TheHeader.vue?ts=123456
userquin commented 1 year ago

I have this problem using Vitest Browser, rn we need to bypass browser cache adding a timestamp (xxx.vue?v=<random>), and so this plugin just does nothing.