tsci dev: ngspice spiceEngine from tscircuit.config.ts fails three ways (package.json, top-level await, blob import)

Aperta
#5,666 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@cocvn157 ci sta già lavorando.

Dal 5/11/2026.

  • #5707 di @cocvn157 — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
bun, react, typescript
Ambito
cli, tooling

Direzione di ricerca

Start in loadTscircuitConfig, where tscircuit.config.ts is evaluated, and compare how importEvalPath resolves @tscircuit/ngspice-spice-engine against the tsci build path. The browser failure needs the analog simulation loader and the blob import resolution, which the payload does not show. Done means tsci dev loads the ngspice config, runs the analog simulation without the blob import error, and the top-level await case works or gives a clear message.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

A project that registers ngspice in tscircuit.config.ts works with tsci build and tsci simulate, but not in tsci dev. There are three separate failures in a row. The first two have workarounds; the third doesn't.

Versions: tscircuit 0.0.3062 (CLI), @tscircuit/core 0.0.2259, @tscircuit/ngspice-spice-engine 0.0.22, @tscircuit/eval 0.0.1696, macOS arm64, Bun 1.3.14.

Repro

tsci init ngspice-dev-repro -y && cd ngspice-dev-repro

index.circuit.tsx:

export default () => (
  <board width="20mm" height="15mm" routingDisabled>
    <voltagesource name="V1" voltage="5V" />
    <resistor name="R1" resistance="1k" connections={{ pin1: ".V1 > .pin1" }} />
    <capacitor name="C1" capacitance="10uF" connections={{ pin1: ".R1 > .pin2", pin2: ".V1 > .pin2" }} />
    <voltageprobe name="VCAP" connectsTo=".C1 > .pin1" />
    <analogsimulation duration="50ms" timePerStep="0.5ms" spiceEngine="ngspice" />
  </board>
)
Failure 1: package not in package.json

tscircuit.config.ts:

import createNgspiceSpiceEngine from "@tscircuit/ngspice-spice-engine"
export default {
  platformConfig: { spiceEngineMap: { ngspice: await createNgspiceSpiceEngine() } },
}

tsci build index.circuit.tsx works (the package is installed as a transitive dependency of tscircuit). tsci dev → Errors:

Execution Error: Node module imported but not in package.json "@tscircuit/ngspice-spice-engine"
importEvalPath("./tscircuit.config.ts", ...) importLocalFile("tscircuit.config.ts")
importEvalPath("@tscircuit/ngspice-spice-engine", ...) importNodeModule("@tscircuit/ngspice-spice-engine")
  at loadTscircuitConfig

Workaround: bun add -d @tscircuit/ngspice-spice-engine.

Failure 2: top-level await in tscircuit.config.ts

With the same config, tsci dev then shows:

Execution Error: Error evaluating "tscircuit.config.ts": Unexpected identifier '_ngspicespiceengine2'
  at loadTscircuitConfig

The in-browser evaluator can't handle the top-level await, though the CLI can. Workaround: create the engine lazily.

let engine: ReturnType<typeof createNgspiceSpiceEngine> | undefined
export default {
  platformConfig: {
    spiceEngineMap: {
      ngspice: {
        simulate: async (spice: string) => {
          engine ??= createNgspiceSpiceEngine()
          return (await engine).simulate(spice)
        },
      },
    },
  },
}
Failure 3: the engine can't load in the dev browser (no workaround)

The config now loads, and the PCB view renders. ⋯ → Analog Simulation shows:

Error running analog simulation
Import "blob:http://localhost:3020/352059b6-0861-489a-8d1d-2f9bf2683551" not found in "node_modules/@tscircuit/ngspice-spice-engine/dist"

The same circuit with the default spicey engine (no spiceEngine prop) renders its graph in the Analog Simulation view.

Expected

Either ngspice works in tsci dev, or the docs say that spiceEngine="ngspice" is CLI-only. It would also help if failures 1 and 2 gave a hint, since the same config works in tsci build.

🤖 Generated with Claude Code

Lingua principale
TypeScript
Stelle
19
Fork
115
Merge medio
1h 50m
PR unite (30g)
260

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tscircuit/cli

Tutte le issue di tscircuit/cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.