Skip to content

[bug]: fix(cli): BUILTIN_MODULES Set nested array bug and missing builtin filtering in getDependencyFromModuleSpecifier #11565

Description

@Abhirup0

Describe the bug

Description

  1. 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.
  2. 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

  1. Remove outer array brackets in constants.ts: export const BUILTIN_MODULES = new Set([...]).
  2. 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

  • I've made research efforts and searched the documentation
  • I've searched for existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions