ui
ui copied to clipboard
[feat]: Allow omitting aliases and generate components based on relative path
Feature description
This would simplify scenarios where you want to use the final generated components in a monorepo.
Monorepos are a superior mechanism of handling package namespaces as it bypasses the finicky tooling.
Affected component/components
No response
Additional Context
Additional details here...
Before submitting
- [x] I've made research efforts and searched the documentation
- [x] I've searched for existing issues and PRs
I'm also having a hard time using aliases.. I want to use relative paths
If I use relative paths I get this error https://github.com/shadcn-ui/ui/issues/4737
│ $ bunx --bun shadcn@canary add && bun lint
│ ✔ Which components would you like to add? › button
│
│ Something went wrong. Please check the error below for more details.
│ If the problem persists, please open an issue on GitHub.
│
│ Validation failed:
│ - resolvedPaths: Required,Required,Required,Required,Required
This would be a real plus to portability of shadcn-ui as a solution. Unfortunately the js ecosystem is very inconsistent with support around tsconfig paths, particularly within monorepo settings. Simply being able to omit usage of these paths is a big bonus.
One random specific issue for related context: https://github.com/oven-sh/bun/issues/14694
For now I've worked around this by bundling my shared packages using tsup (relatively unpainful!).
Following is a "build" script in my package.json. Also have turbo configured so this gets run automatically before running my downstream bun processes.
bunx tsup src/**/* --dts --format esm --sourcemap
I stepped in this same problem today in a similar way to @chrisui as I'm also building in a Turbo monorepo, with a framework heavily dependent on aliases which is Nuxt 4
For my problem, just redeclaring the alias in the tsconfig.json of my given application solved the issue. (I mean redeclaring because Nuxt already declares it in its references files)
{
// https://nuxt.com/docs/guide/concepts/typescript
"files": [],
"references": [
{
"path": "./.nuxt/tsconfig.app.json"
},
{
"path": "./.nuxt/tsconfig.server.json"
},
{
"path": "./.nuxt/tsconfig.shared.json"
},
{
"path": "./.nuxt/tsconfig.node.json"
}
],
"compilerOptions": {
"paths": {
"~/*": ["~/app/*"] // REDECLARED
}
}
}
It was tricky to find a solution, as I was having the same error message mentioned by @SohelIslamImran (#4737), and it does not help; but intuitively it can be seem that each resolvedPath maps to one alias configured in your "aliases" within the components.json file.