Describe the bug
Description
- Set syntax bug: In
packages/shadcn/src/registry/constants.ts (lines 48–52), BUILTIN_MODULES is defined as new Set([[ "node:assert", ... ]]). The outer brackets cause BUILTIN_MODULES.size to be 1 (a Set containing one Array), so BUILTIN_MODULES.has(...) always returns false.
- Missing check: In
packages/shadcn/src/registry/utils.ts (lines 36–60), getDependencyFromModuleSpecifier never checks BUILTIN_MODULES. Bare Node imports (path, fs/promises, crypto) are returned as npm dependencies and added to package.json.
Suggested Fix
- Remove outer array brackets in
constants.ts: export const BUILTIN_MODULES = new Set([...]).
- In
utils.ts, check if (BUILTIN_MODULES.has(moduleSpecifier) || BUILTIN_MODULES.has(moduleSpecifier.split("/")[0])) return null;.
Affected component/components
packages/shadcn/src/registry/constants.ts (lines 48–170) - packages/shadcn/src/registry/utils.ts (lines 36–60)
How to reproduce
Steps to Reproduce
import { BUILTIN_MODULES } from "./src/registry/constants"
import { getDependencyFromModuleSpecifier } from "./src/registry/utils"
console.log(BUILTIN_MODULES.size) // 1 (Expected: 90+)
console.log(BUILTIN_MODULES.has("fs")) // false (Expected: true)
console.log(getDependencyFromModuleSpecifier("fs/promises")) // "fs" (Expected: null)
Codesandbox/StackBlitz link
No response
Logs
System Info
- OS: Windows 11 (all OS affected)
- Node: >= 20.x
- Package: shadcn CLI (@latest / 4.18.0)
Before submitting
Describe the bug
Description
packages/shadcn/src/registry/constants.ts(lines 48–52),BUILTIN_MODULESis defined asnew Set([[ "node:assert", ... ]]). The outer brackets causeBUILTIN_MODULES.sizeto be1(a Set containing one Array), soBUILTIN_MODULES.has(...)always returnsfalse.packages/shadcn/src/registry/utils.ts(lines 36–60),getDependencyFromModuleSpecifiernever checksBUILTIN_MODULES. Bare Node imports (path,fs/promises,crypto) are returned as npm dependencies and added topackage.json.Suggested Fix
constants.ts:export const BUILTIN_MODULES = new Set([...]).utils.ts, checkif (BUILTIN_MODULES.has(moduleSpecifier) || BUILTIN_MODULES.has(moduleSpecifier.split("/")[0])) return null;.Affected component/components
packages/shadcn/src/registry/constants.ts(lines 48–170) -packages/shadcn/src/registry/utils.ts(lines 36–60)How to reproduce
Steps to Reproduce
Codesandbox/StackBlitz link
No response
Logs
System Info
- OS: Windows 11 (all OS affected) - Node: >= 20.x - Package: shadcn CLI (@latest / 4.18.0)Before submitting