tscircuit / tscircuit/cli

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

Open
#3,982 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
18
Forks
91
Avg merge
31m
Merged PRs (30d)
349

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with tsci init, tsci add Anshgrover23/AMS1117_3_3, and tsci build, then compare the failing package's index.cjs with the working registry builds. Read the @tscircuit/core package exports and the CLI paths handling component installation and build resolution. Done means stale components no longer fail mysteriously at build time, either by compatible handling or an early actionable diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.