Open asmaloney opened 2 years ago
If I copy the parts I need to a local file (src/common/buefy.d.ts
) and import that instead:
import { BModalComponent } from '@/common/buefy'
...it runs fine. (Not a great workaround though.)
Anyone have any ideas why vite can't resolve this file properly in the minimal repro project?
You can use import type { BModalComponent } from 'buefy/types/components'
to workaround the error.
It also happens with plugin-vue
.
https://stackblitz.com/edit/vitejs-vite-dh6n4q?file=src%2Fcomponents%2FHelloWorld.vue,src%2Fmain.ts&terminal=dev
related: vitejs/vite#4810
You can use
import type { BModalComponent } from 'buefy/types/components'
to workaround the error.
Thanks @sapphi-red! That works.
Much better than having to duplicate a bunch of code.
it also happens with echarts with 'echarts/types/dist/shared.d.ts' Thanks @sapphi-red ! It works! It's in the doc: https://vitejs.dev/guide/features.html#typescript So I guess it's a non issue and it should be closed.
So I guess it's a non issue and it should be closed.
Just because they documented it doesn't mean it's not a bug. 😄
That's just a workaround "to avoid potential problems like type-only imports being incorrectly bundled" (i.e. a bug).
@asmaloney okay so, I I understand you correctly the problem is with typescript ? https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export ?
I have no idea where the bug is - I just reported it.
Yeah, you should use type only imports where it's possible. But there's some libraries that imports type def files in the component.
https://github.com/vitejs/vite-plugin-vue/issues/24#issuecomment-1336123030
You can see import Decimal from 'vue-slider-component/typings/utils/decimal';
doesn't throw an error if it existed in .ts
.
So I think there could be a way to fix this. It might be impossible though.
related PR: https://github.com/vitejs/vite/pull/5850
Describe the bug
(See discussion.)
Short version:
When I try to
import { BModalComponent } from 'buefy/types/components'
in a vue2 project, vite will fail to run:Reproduction
https://github.com/asmaloney/vite-resolve-bug
System Info
Used Package Manager
npm
Logs
Validations