! Rushabh | Linux Shill - lib/import-eecircuit-...
lib/import eecircuit engine.ts loads the 21 MB engine by fetching it from the CDN, wrapping the source in a Blob, and calling import(blob:…). Browsers and Bun support importing a blob: URL; Node's ESM loader does not — it throws "Only URLs with a scheme in: file, data, and node a
Started by ! Rushabh | Linux ShillJun 25, 202664 messages
lib/import-eecircuit-engine.ts loads the 21 MB engine by fetching it from the CDN, wrapping the source in a Blob, and calling import(blob:…). Browsers and Bun support importing a blob: URL; Node's ESM loader does not — it throws "Only URLs with a scheme in: file, data, and node are supported… Received protocol 'blob:'". So any consumer that runs simulations under Node (e.g. svg.tscircuit.com's Next.js Node runtime) fails. I verified this end-to-end: with a file:// temp-file import the same circuit produces both transient graphs under Node.
Therefore svg.tscircuit.com fails
https://svg.tscircuit.com/?svg_type=schsim&code=H4sIAJSWPWoAA21S0WqDMBT9leBeWthau64vZQqF7mGwraPrZA%2FCSPVqA5qEmzg6xH9fok2Vrj55z8m5956T1B7jKRwnWh29pQdHKVCTFDJaFZqMxiQIySjmhDzuBcWUoKg04%2FmaKbovIA0tZcgfUWiagxIVJkA4LSGIvWgWe%2BTEmHK2iEytksNXUN%2FNGzJ1YlqWoAG7ijj16tXIHZaIQqABb7LMN19P5EjlwWwjC%2Fr71gmfv182q%2FVQyzkkmgmugrp2KCFSqCWJvUk0IyGZSMbNvNue5pC39PYa3TTd39kDgmJKC3Tbb633DqQ8scj92bzxngmhJTKuDeE%2F%2BJazrU7NNFKTYoaiNHS%2FgD2lhYXOK18IT2FLFHu4iDPafO6u5DmfLZIs%2BxeW2rVzht7dCYQMEIyn7shwlT4Td7OcFiJXrKwKai%2FA9UgrbGv7KkrV99ashHfADw3SUr5fDUglWQJPPGfc%2BuF5Ww%2BHmoHT9pWGY6%2F5A0JngCrYAgAA
for
```ts
<board routingDisabled>
<voltagesource name="V1" voltage="15V" schX={-3} />
<ammeter
name="AM1"
color="#ff0000"
graphDisplayName="I_LOAD"
connections={{
pos: ".V1 > .pin1",
neg: ".R1 > .pin1",
}}
/>
<resistor name="R1" resistance="2" schX={3} footprint="0402" />
<trace from=".R1 > .pin2" to=".V1 > .pin2" />
<voltageprobe
name="VOUT"
color="#315cff"
connectsTo=".R1 > .pin1"
referenceTo=".V1 > .pin2"
/>
<analogsimulation
duration="1ms"
timePerStep="100us"
spiceEngine="ngspice"
/>
</board>
```
<@778624824875941908>
actually I noticed no spice simulation works in the docs
shibo
<@452450065941004289>
shibo
it used to work
! Rushabh | Linux Shill
ik
! Rushabh | Linux Shill
the issue is in svg.tscircuit.com
! Rushabh | Linux Shill
<@778624824875941908> this broke it https://github.com/tscircuit/ngspice-spice-engine/pull/22
! Rushabh | Linux Shill
<@809856037376491570>
! Rushabh | Linux Shill
i think we should revert back to package imports
shibo
why? it works in eval, runframe and the cli, we just gotta figure out why it failed in svg.tscircuit.com
! Rushabh | Linux Shill
hmm
! Rushabh | Linux Shill
found the error
```
Compilation Error
Simulation failed for"simulation_experiment_0": OnlyURLs with a scheme in: file,data, and node are supported bythe default ESM loader. Receivedprotocol 'blob:'
```
! Rushabh | Linux Shill
- `runframe` works because browser
- `cli` works because temp-file import
shibo
<@757706909351411845>
Seve
ok so basically we don't work it NODE right now, we work in browser and bun is that right?
Seve
we might work in newer versions of node- <@452450065941004289> can you replicate locally
Seve
also RE: svg.tscircuit.com, we should preload the ngspice library, i think we might have done this for other libraries, should not be a big deal?
Seve
i.e. svg.tscircuit.com or basically ANY server shouldn't be loading from CDN- it should be a dev dep that is packaged when the server is deployed
<@452450065941004289> can you double check it it worked in the live deployment?
! Rushabh | Linux Shill
Yes, Its is not working for svg.tscircuit.com , but it works in https://svg-tscircuit-2mm13se43-tscircuit.vercel.app/
hey <@809856037376491570> is there any difference of environment between these two links in vercel
the thing is that main builds locally, why does it not build in vercel? maybe it does actually build if the snapshot sent by <@809856037376491570> is not from main
! Rushabh | Linux Shill
that one is not from main
! Rushabh | Linux Shill
it also fails locally , its just something i was testing locally, the build started cause i created a pr as i wanted to know how it behaves in prod
! Rushabh | Linux Shill
<@809856037376491570> needs to see the latest build on main branch
So here is what i found
I added better errros https://github.com/tscircuit/svg.tscircuit.com/pull/1688
live link i got for my pr (works perfectly fine): https://svg-tscircuit-6ty0d4oh2-tscircuit.vercel.app/
my vercel deployment of the same branch (errors): https://svg-tscircuit-pxjw8v8l2-rushabh1134s-projects.vercel.app/