ui icon indicating copy to clipboard operation
ui copied to clipboard

[feat]: Allow omitting aliases and generate components based on relative path

Open clink-aaron opened this issue 8 months ago • 2 comments
trafficstars

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

clink-aaron avatar Mar 05 '25 21:03 clink-aaron

I'm also having a hard time using aliases.. I want to use relative paths

Image

SohelIslamImran avatar Apr 21 '25 07:04 SohelIslamImran

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

SohelIslamImran avatar Apr 21 '25 07:04 SohelIslamImran

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

chrisui avatar Jul 17 '25 16:07 chrisui

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

chrisui avatar Jul 17 '25 16:07 chrisui

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.

patrickkmatias avatar Sep 30 '25 14:09 patrickkmatias