radix-vue / shadcn-vue

Vue port of shadcn-ui
https://www.shadcn-vue.com/
MIT License
4.57k stars 262 forks source link

Feature(Nuxt): Add `radix-vue` and other main deps as `dependencies` #529

Closed MuhammadM1998 closed 4 months ago

MuhammadM1998 commented 4 months ago

Describe the feature

Hey 👋

There are primary dependencies that shadcn-vue relies on and automatically installed by the CLI

I think adding them as dependencies to the nuxt module makes sense. They would get installed with the module without cluttering the package.json. Similar to other nuxt modules which follows the pattern of a 'one-click-setup'.

I've created a branch locally and it works as expected. Happy to make a PR if this is accepted.

Additional information

sadeghbarati commented 4 months ago

I like the idea, but we should release shadcn-nuxt on every radix-vue or other deps version bump?

https://github.com/HugoRCD/blanked

MuhammadM1998 commented 4 months ago

I think releasing a new version won't be necessary for those deps as long as you keep the ^ in package.json. For example if we have tailwind-merge: ^2.3.0 a dependency and then tailwind-merge v2.3.1, the package manager would pick this automatically and install the updated version. The release would be only required for major changes for those deps which is reasonable as you'd want to migrate them and ensure everything works correctly first.

sadeghbarati commented 4 months ago

Nice TIL

MuhammadM1998 commented 4 months ago

Can you elaborate on the module you linked? Do you want to add it as a dependency too? I see it has a lot of modules that are needed by the module such as tailwindcss and colormode. I'm not sure if it's a good idea though

sadeghbarati commented 4 months ago

Can you elaborate on the module you linked? Do you want to add it as a dependency too? I see it has a lot of modules that are needed by the module such as tailwindcss and colormode. I'm not sure if it's a good idea though

I think that link is got the same idea as yours I just share it, thought it might be helpful

MuhammadM1998 commented 4 months ago

Oh I got it wrong then 😅 Yeah it's similar to it. Also similar to nuxt/tailwindcss that has tailwindcss as a dependency for example. It's actually a pattern I see in a lot of nuxt modules. If this sounds good I'd like to get assigned this please

sadeghbarati commented 4 months ago

@MuhammadM1998 one question, what is if I want to use class-variance-authority types like

import { type VariantProps } from 'class-variance-authority'

I should install it again (in devDependencies) even though cva is part of dependencies in shadcn-nuxt module right?

MuhammadM1998 commented 4 months ago

@sadeghbarati You don't need to add it again that import would just work. Actually 'class-variance-authority' has clsx as a dependency which is re-added as a dependency when you init the CLI. If you remove the clsx from depedencies things will continue to work normally (unless of course the version in the dependencies has a different major version from the on in cva's dependencies as there would be breaking changes, but this is not the case here)

So this

"dependencies": {
  "class-variance-authority": "^0.7.0",
  "clsx": "^2.1.1",
},

Can be simplified to this if the clsx (which is currently 2.0.0) version in cva's suits your needs

"dependencies": {
  "class-variance-authority": "^0.7.0",
 }

and the following import would still work

import { type ClassValue, clsx } from 'clsx'

If you want to use a different version than the one in cva's dependencies. You'd specify it as in overrides

"dependencies": {
  "class-variance-authority": "^0.7.0",
 },
"pnpm": {
  "overrides": {
    "clsx": "^3" // This would get installed instead of `2.0.0` specified by 'class-variance-authority'
  }
}