From 2b0dc2116a6155c84d0f267bac984c019f2d6dab Mon Sep 17 00:00:00 2001 From: shadcn Date: Mon, 16 Mar 2026 16:49:31 +0400 Subject: [PATCH] fix --- .../src/utils/{import-entries.ts => import-matcher.ts} | 5 +++++ packages/shadcn/src/utils/package-imports.ts | 5 ++--- packages/shadcn/src/utils/resolve-import.ts | 2 +- .../src/utils/{workspace-package-exports.ts => workspace.ts} | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) rename packages/shadcn/src/utils/{import-entries.ts => import-matcher.ts} (91%) rename packages/shadcn/src/utils/{workspace-package-exports.ts => workspace.ts} (99%) diff --git a/packages/shadcn/src/utils/import-entries.ts b/packages/shadcn/src/utils/import-matcher.ts similarity index 91% rename from packages/shadcn/src/utils/import-entries.ts rename to packages/shadcn/src/utils/import-matcher.ts index 3914664857..b53375daa3 100644 --- a/packages/shadcn/src/utils/import-entries.ts +++ b/packages/shadcn/src/utils/import-matcher.ts @@ -1,5 +1,10 @@ import path from "path" +// Node can resolve `package.json#imports` and `package.json#exports` at +// runtime, but the CLI needs the matched pattern, local filesystem target, and +// emit behavior as data so it can place files and rewrite imports consistently. +// This module is the shared matcher for those normalized entry shapes. + export type ImportEmitMode = "strip_extension" | "preserve_extension" export type ImportResolutionEntry = { diff --git a/packages/shadcn/src/utils/package-imports.ts b/packages/shadcn/src/utils/package-imports.ts index ebed029b4a..6fb8c728a6 100644 --- a/packages/shadcn/src/utils/package-imports.ts +++ b/packages/shadcn/src/utils/package-imports.ts @@ -7,9 +7,8 @@ import { type ImportEmitMode, type ImportResolutionEntry, type ImportResolutionMatch, -} from "@/src/utils/import-entries" - -export type { ImportEmitMode } from "@/src/utils/import-entries" +} from "@/src/utils/import-matcher" +export type { ImportEmitMode } from "@/src/utils/import-matcher" export type PackageImportEntry = ImportResolutionEntry export type PackageImportMatch = ImportResolutionMatch diff --git a/packages/shadcn/src/utils/resolve-import.ts b/packages/shadcn/src/utils/resolve-import.ts index 905771906d..e5f663c5ef 100644 --- a/packages/shadcn/src/utils/resolve-import.ts +++ b/packages/shadcn/src/utils/resolve-import.ts @@ -2,7 +2,7 @@ import { resolvePackageImport, type ImportEmitMode, } from "@/src/utils/package-imports" -import { resolveWorkspacePackageExport } from "@/src/utils/workspace-package-exports" +import { resolveWorkspacePackageExport } from "@/src/utils/workspace" import { createMatchPath, type ConfigLoaderSuccessResult } from "tsconfig-paths" export type ResolvedImport = { diff --git a/packages/shadcn/src/utils/workspace-package-exports.ts b/packages/shadcn/src/utils/workspace.ts similarity index 99% rename from packages/shadcn/src/utils/workspace-package-exports.ts rename to packages/shadcn/src/utils/workspace.ts index f2ae6abf6d..b04fcc4dcf 100644 --- a/packages/shadcn/src/utils/workspace-package-exports.ts +++ b/packages/shadcn/src/utils/workspace.ts @@ -10,7 +10,7 @@ import { type ImportEmitMode, type ImportResolutionEntry, type ImportResolutionMatch, -} from "@/src/utils/import-entries" +} from "@/src/utils/import-matcher" type WorkspacePackageInfo = { packageName: string