qmhc / vite-plugin-dts

A Vite plugin for generating `.d.ts` files.
MIT License
1.23k stars 84 forks source link

Adds many unrelated vue dependencies to the project #361

Open Akiyamka opened 1 month ago

Akiyamka commented 1 month ago

Describe the bug

In case it used in pure node.js app or for example in react app - it unnecessary adds such dependencies as @vue/language-core, @vue/compiler-core, @vue/compiler-dom, batch of @volar/** packages and so on. Can be fixed by moving next packages to peerDependencies or optionalDependencies

Reproduction

not related

Steps to reproduce

pnpm add vite-plugin-dts

System Info

Not related

Validations

Akiyamka commented 1 month ago

Temporary workaround: in case project uses pnpm you can add next settings in package.json

{
  "pnpm": {
    "packageExtensions": {
      "vite-plugin-dts": {
        "dependenciesMeta": {
          "@volar/typescript": {
            "optional": true
          },
          "vue-tsc": {
            "optional": true
          },
          "@vue/language-core": {
            "optional": true
          }
        }
      }
    }
  }
}
qmhc commented 3 weeks ago

Are you install the plugin to dependencies but not devDependencies? Dev dependencies will not be packed into the final chunk.

Those packages of Volar are the basic dependencies of the plugin, they are not optional.

Akiyamka commented 2 weeks ago

Let me be clear. It's not about final chunk. Such build time deps, regardless of whether is installed in dependencies or devDepenencies, usually not included in a bundle because it's not imported in final application anywhere.

However, if the project does not use vue, these dependencies are simply not used, in other words they are optional and are only needed for a certain tech stack

What's wrong with unnecessary dependencies that will never be used in some projects? I would say it's not a critical problem, but such dependencies cause some inconvenience:

  1. Waste of resources - unnecessary dependencies take up disk space and slow down the overall time it takes to install dependencies.
  2. If you are serious about security, dependencies should be audited and vulnerabilities in them promptly fixed. Adding unused dependencies significantly degrades the DX of those who do it

Thus, making these dependencies optional not only better reflects reality, but will make the users of this wonderful library a little happier ; )