Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 118 additions & 120 deletions packages/shadcn/src/registry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,127 +46,125 @@ export const BUILTIN_REGISTRIES: z.infer<typeof registryConfigSchema> = {
}

export const BUILTIN_MODULES = new Set([
[
// Node.js built-in modules
// From https://github.com/sindresorhus/builtin-modules.
"node:assert",
"assert",
"node:assert/strict",
"assert/strict",
"node:async_hooks",
"async_hooks",
"node:buffer",
"buffer",
"node:child_process",
"child_process",
"node:cluster",
"cluster",
"node:console",
"console",
"node:constants",
"constants",
"node:crypto",
"crypto",
"node:dgram",
"dgram",
"node:diagnostics_channel",
"diagnostics_channel",
"node:dns",
"dns",
"node:dns/promises",
"dns/promises",
"node:domain",
"domain",
"node:events",
"events",
"node:fs",
"fs",
"node:fs/promises",
"fs/promises",
"node:http",
"http",
"node:http2",
"http2",
"node:https",
"https",
"node:inspector",
"inspector",
"node:inspector/promises",
"inspector/promises",
"node:module",
"module",
"node:net",
"net",
"node:os",
"os",
"node:path",
"path",
"node:path/posix",
"path/posix",
"node:path/win32",
"path/win32",
"node:perf_hooks",
"perf_hooks",
"node:process",
"process",
"node:querystring",
"querystring",
"node:quic",
"node:readline",
"readline",
"node:readline/promises",
"readline/promises",
"node:repl",
"repl",
"node:sea",
"node:sqlite",
"node:stream",
"stream",
"node:stream/consumers",
"stream/consumers",
"node:stream/promises",
"stream/promises",
"node:stream/web",
"stream/web",
"node:string_decoder",
"string_decoder",
"node:test",
"node:test/reporters",
"node:timers",
"timers",
"node:timers/promises",
"timers/promises",
"node:tls",
"tls",
"node:trace_events",
"trace_events",
"node:tty",
"tty",
"node:url",
"url",
"node:util",
"util",
"node:util/types",
"util/types",
"node:v8",
"v8",
"node:vm",
"vm",
"node:wasi",
"wasi",
"node:worker_threads",
"worker_threads",
"node:zlib",
"zlib",
// Node.js built-in modules
// From https://github.com/sindresorhus/builtin-modules.
"node:assert",
"assert",
"node:assert/strict",
"assert/strict",
"node:async_hooks",
"async_hooks",
"node:buffer",
"buffer",
"node:child_process",
"child_process",
"node:cluster",
"cluster",
"node:console",
"console",
"node:constants",
"constants",
"node:crypto",
"crypto",
"node:dgram",
"dgram",
"node:diagnostics_channel",
"diagnostics_channel",
"node:dns",
"dns",
"node:dns/promises",
"dns/promises",
"node:domain",
"domain",
"node:events",
"events",
"node:fs",
"fs",
"node:fs/promises",
"fs/promises",
"node:http",
"http",
"node:http2",
"http2",
"node:https",
"https",
"node:inspector",
"inspector",
"node:inspector/promises",
"inspector/promises",
"node:module",
"module",
"node:net",
"net",
"node:os",
"os",
"node:path",
"path",
"node:path/posix",
"path/posix",
"node:path/win32",
"path/win32",
"node:perf_hooks",
"perf_hooks",
"node:process",
"process",
"node:querystring",
"querystring",
"node:quic",
"node:readline",
"readline",
"node:readline/promises",
"readline/promises",
"node:repl",
"repl",
"node:sea",
"node:sqlite",
"node:stream",
"stream",
"node:stream/consumers",
"stream/consumers",
"node:stream/promises",
"stream/promises",
"node:stream/web",
"stream/web",
"node:string_decoder",
"string_decoder",
"node:test",
"node:test/reporters",
"node:timers",
"timers",
"node:timers/promises",
"timers/promises",
"node:tls",
"tls",
"node:trace_events",
"trace_events",
"node:tty",
"tty",
"node:url",
"url",
"node:util",
"util",
"node:util/types",
"util/types",
"node:v8",
"v8",
"node:vm",
"vm",
"node:wasi",
"wasi",
"node:worker_threads",
"worker_threads",
"node:zlib",
"zlib",

// Bun built-in modules.
"bun",
"bun:test",
"bun:sqlite",
"bun:ffi",
"bun:jsc",
"bun:internal",
],
// Bun built-in modules.
"bun",
"bun:test",
"bun:sqlite",
"bun:ffi",
"bun:jsc",
"bun:internal",
])

type DeprecatedComponent = {
Expand Down
9 changes: 9 additions & 0 deletions packages/shadcn/src/registry/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { Project, ScriptKind } from "ts-morph"
import { loadConfig } from "tsconfig-paths"
import { z } from "zod"
import { BUILTIN_MODULES } from "@/src/registry/constants"

const FILE_EXTENSIONS_FOR_LOOKUP = [".tsx", ".ts", ".jsx", ".js", ".css"]
const FILE_PATH_SKIP_LIST = ["lib/utils.ts"]
Expand All @@ -41,6 +42,14 @@ export function getDependencyFromModuleSpecifier(
return null
}

// Skip if the module specifier is a Node.js built-in module
if (
BUILTIN_MODULES.has(moduleSpecifier) ||
BUILTIN_MODULES.has(moduleSpecifier.split("/")[0])
) {
return null
}

// If the module specifier does not start with `@` and has a /, add the dependency first part only.
// E.g. `foo/bar` -> `foo`
if (!moduleSpecifier.startsWith("@") && moduleSpecifier.includes("/")) {
Expand Down
Loading