Skip to content

tsci build: registry components whose CJS build requires @tscircuit/core fail — core is ESM-only (repro of stale #1657) #3982

Description

@Hero988

Description

In a fresh tsci init project, adding some registry components makes tsci build fail with:

error: Cannot find module '@tscircuit/core' from '.../node_modules/@tsci/Anshgrover23.AMS1117_3_3/index.cjs'
Fatal error [circuit_generation_failed]: ResolveMessage: Cannot find module '@tscircuit/core'

Steps to reproduce

  1. tsci init my-board (tscircuit 0.0.2205, cli 0.1.1804, bun 1.3.14)
  2. tsci add Anshgrover23/AMS1117_3_3
  3. Use it in index.circuit.tsx and run tsci build

Root cause (as far as I can tell)

The registry's CJS build of that component starts with:

var core = require('@tscircuit/core');

but @tscircuit/core (0.0.1581 in a fresh project) is now ESM-only — "type": "module" and an exports map with only an import condition:

"exports": { ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" } }

so the require() can never resolve. Components with newer registry builds (e.g. @tsci/seveibar.smd-usb-c, @tsci/seveibar.WS2812B_2020) don't reference @tscircuit/core from their CJS output and work fine in the same project — the breakage seems limited to components whose published build predates core going ESM-only (this one imports createUseComponent from core).

#1657 reported the same symptom in April; it was read as a not-installed problem and auto-closed by the stale bot, but it still reproduces today with the package above.

Why it hurts

You only find out at build time, with a module-resolution error that points at a package you installed exactly the way the site suggests. There's no way for a user to tell "this component's published build is stale" from "my project is broken" — I lost a while re-checking my own setup before diffing the working vs failing packages' index.cjs. Anything that either rebuilds stale registry artifacts, adds a require condition/CJS entry to core, or fails tsci add early with "this component needs a rebuild" would fix the experience.

Happy to provide the full project if useful — my workaround was converting the part locally with the easyeda library and importing the generated .tsx instead of the registry package.

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