Skip to content

tsci build fails with "Cannot find module '@tscircuit/core'" when using registry components #1657

@charlielockyer-rice

Description

@charlielockyer-rice

Description:

When using tsci build with a component imported from the tscircuit registry (e.g., @tsci/seveibar.smd-usb-c), the build fails with a module resolution error. The same circuit works fine with tsci dev.

Steps to Reproduce:

  1. Create a new tscircuit project: tsci init
  2. Install a registry component: bun add @tsci/seveibar.smd-usb-c
  3. Create a circuit using the component:
import { SmdUsbC } from "@tsci/seveibar.smd-usb-c"

export default () => (
  <board width="30mm" height="30mm">
    <SmdUsbC name="J1" pcbX={0} pcbY={0} />
  </board>
)
  1. Run tsci dev - works fine
  2. Run tsci build - fails

Error:
error: Cannot find module '@tscircuit/core' from '/path/to/project/node_modules/@tsci/seveibar.smd-usb-c/index.cjs'

Building 1 file(s)...
Building index.tsx...
Generating circuit JSON...

Analysis:

The @tsci/seveibar.smd-usb-c package's package.json doesn't declare @tscircuit/core as a dependency or peerDependency:

{
  "name": "@tsci/seveibar.smd-usb-c",
  "version": "0.0.2",
  "main": "index.cjs",
  "module": "index.js",
  "types": "index.d.ts"
}

But index.cjs requires it at runtime. This works in tsci dev (likely due to bundling), but fails in tsci build which runs the CJS file directly.

Workaround:

Define the component inline using instead of importing from the registry.

Expected Behavior:

tsci build should work with registry components, or registry components should declare their dependencies properly.

Environment:

  • @tscircuit/cli: 0.1.755
  • @tsci/seveibar.smd-usb-c: 0.0.2
  • Runtime: Bun 1.3.5
  • OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions