Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ui-add doesn't set the import paths properly when adding a component #1035

Open
j-fdion opened this issue May 14, 2024 · 7 comments
Open

Comments

@j-fdion
Copy link

j-fdion commented May 14, 2024

Provide environment information

System: OS: Windows 10 10.0.19045 CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor Memory: 17.53 GB / 31.92 GB Binaries: Node: 22.1.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD pnpm: 9.1.1 - ~\AppData\Local\pnpm\pnpm.EXE Watchman: 20210110.135312.0 - c:\programdata\chocolatey\bin\watchman.EXE

Describe the bug

When using pnpm ui-add the added component doesn't have a correct import path.

`"use client";

import * as React from "react";
import { type DialogProps } from "@radix-ui/react-dialog";
import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
import { Command as CommandPrimitive } from "cmdk";
import { Dialog, DialogContent } from "src//dialog";

import { cn } from "@acme/ui";`

The import should be ./dialog and not src//dialog

Link to reproduction

https://github.com/t3-oss/create-t3-turbo

To reproduce

use pnpm ui-add and select the Command component

Additional information

No response

@juliusmarminge
Copy link
Member

What component did you add?

@juliusmarminge
Copy link
Member

shadcn cli generally isnt the best at handling monorepos but i thought we got the last issues sorted :/

@j-fdion
Copy link
Author

j-fdion commented May 14, 2024

What component did you add?

The command component (needs Dialog, imported as import { Dialog, DialogContent } from "src//dialog";, but it does it with every component which has dependency inside the /src directory such as Toaster (needs Toast, imported as import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, } from "src//toast";

@mr-toast
Copy link

mr-toast commented Sep 9, 2024

I'm also seeing an import mistake. Newly added components have the incorrect cn import.

Example:
import { cn } from "s/lib/utils"

Expecting:
import { cn } from "@acme/ui"

@xzedx
Copy link

xzedx commented Oct 16, 2024

could be solved by this method: shadcn-ui/ui#3854 (comment)

@hayata-suenaga
Copy link

@xzedx thank you for the link. can you tell us what is the content of your components.json and tsconfig.json?

@warrantor
Copy link

Is there any update regarding this issue?
The path alias in tsconfig.json also doesn't play well with a mono repo. When I set it to "@/*": "./src/*" it gives an error at runtime that it can't find the module, which ever one is referenced first.
Sot that isn't a fix either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants