GithubHelp home page GithubHelp logo

Vue support about dts-bundle-generator HOT 14 CLOSED

f-lawe avatar f-lawe commented on June 9, 2024 1
Vue support

from dts-bundle-generator.

Comments (14)

timocov avatar timocov commented on June 9, 2024

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

from dts-bundle-generator.

f-lawe avatar f-lawe commented on June 9, 2024

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.

from dts-bundle-generator.

timocov avatar timocov commented on June 9, 2024

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

from dts-bundle-generator.

f-lawe avatar f-lawe commented on June 9, 2024

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.

from dts-bundle-generator.

f-lawe avatar f-lawe commented on June 9, 2024

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

from dts-bundle-generator.

timocov avatar timocov commented on June 9, 2024

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.

from dts-bundle-generator.

timocov avatar timocov commented on June 9, 2024

I'll try to address this problem soon

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

from dts-bundle-generator.

f-lawe avatar f-lawe commented on June 9, 2024

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?

from dts-bundle-generator.

f-lawe avatar f-lawe commented on June 9, 2024

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

from dts-bundle-generator.

timocov avatar timocov commented on June 9, 2024

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

from dts-bundle-generator.

f-lawe avatar f-lawe commented on June 9, 2024

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.

from dts-bundle-generator.

timocov avatar timocov commented on June 9, 2024

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

from dts-bundle-generator.

f-lawe avatar f-lawe commented on June 9, 2024

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.

from dts-bundle-generator.

timocov avatar timocov commented on June 9, 2024

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.

from dts-bundle-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.