Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue support #247

Closed
f-lawe opened this issue Mar 30, 2023 · 14 comments
Closed

Vue support #247

f-lawe opened this issue Mar 30, 2023 · 14 comments

Comments

@f-lawe
Copy link

f-lawe commented Mar 30, 2023

Hello!

I ran dts-bundle-generator against some .vue files, and it seems to ignore them completely. Is there a known setup to handle this case?

Thanks!

@timocov
Copy link
Owner

timocov commented Mar 30, 2023

Hi @f-lawe, do you have a repo that I can use as a repro?

@f-lawe
Copy link
Author

f-lawe commented Mar 30, 2023

I've started a new and very simple one: https://github.com/f-lawe/dts-bundle-generator-vue

For some reason, I'm stuck to Cannot find module './MyComponent.vue' or its corresponding type declarations, while on the project I'm currently working on, Vue files are just ignored.

It's set up with Vite if that can help you.

@timocov
Copy link
Owner

timocov commented Mar 30, 2023

Please read this #232, looks like this is exactly what you're experiencing.

@f-lawe
Copy link
Author

f-lawe commented Mar 30, 2023

Thanks for replying so fast!

I've updated the project using triple-slash directives, but I still face the same issue. Declaration bundle is built, but it's wrong. Regular build is ok, so it's only a Typescript thing.

@f-lawe
Copy link
Author

f-lawe commented Mar 30, 2023

I keep looking what's different on my other project.

@timocov
Copy link
Owner

timocov commented Mar 30, 2023

It seems that if you do the following it helps a bit:

At least it generates correct file now. But the problem that I see right now is your components would have {} props which I don't think is right. Sorry, I'm not that familiar with vuejs, not sure what's the best solution here and how it is done in other libraries.

@timocov
Copy link
Owner

timocov commented Mar 30, 2023

I'll try to address this problem soon

As for this, please add declare keyword to a constant here: declare const component: DefineComponent<{}, {}, any>;.

@f-lawe
Copy link
Author

f-lawe commented Mar 31, 2023

Ok, it works with your changes, thanks. And indeed, Vue components are empty.

I'm not familiar with Typescript declarations from my side. But I know that vue-tsc is able to generate a valid output. There may be a way to leverage something from it?

@f-lawe
Copy link
Author

f-lawe commented Mar 31, 2023

Project updated with a new script: npm run vue-tsc generates a full output.

@timocov
Copy link
Owner

timocov commented Apr 1, 2023

@f-lawe it seems vue-tsc already generates everything you need in 1 file and you don't need to use dts-bundle-generator?

@f-lawe
Copy link
Author

f-lawe commented Apr 3, 2023

I gave it a try, but the bundled output is not ok. I'm still investigating a bit and checking first if I'm not the one making a mistake. The regular output works, and this is what I use for the moment.

It just would be awesome to have one single package handling both regular JS and Vue. It's not a strong need.

@timocov
Copy link
Owner

timocov commented Apr 4, 2023

It just would be awesome to have one single package handling both regular JS and Vue

Can you provide what exactly you'd like to get eventually as an output? I'm not quite understand tbh

@f-lawe
Copy link
Author

f-lawe commented Apr 5, 2023

I updated the dts-bundle-generator-vue project so you can have a look.

npm run dst:bundle-generator -> Bundled declarations with your project, ok with regular Typescript, but missing details with Vue files

npm run dts:vue-tsc -> Declarations generated with vue-tsc, each file gets its own declaration file, but output is ok when using the lib within an other project

npm run dts-vue-tsc-bundle -> Bundled declarations with vue-tsc, not ok because every declaration is embedded into a module named after the original file

Ideally, the output should be bundled like your project and populated with the correct Vue declarations like vue-tsc.

@timocov
Copy link
Owner

timocov commented Apr 9, 2023

not ok because every declaration is embedded into a module named after the original file

@f-lawe is it the only problem with that output from your perspective? It feels like a feature request for vue-tsc tbh (e.g. they can generate random names or so). But also I suppose you can run dts:vue-tsc and then run dts-bundle-generator with dts:vue-tsc's output file as an input, but it fails right now as the tool doesn't support renaming (it is a known limitation), see #116 and #130. I'm closing this issue in favor of these.

@timocov timocov closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants