This PR implements full npm package import support for both the tscircuit CLI and tscircuit.com website, addressing issue #760.
// Your circuit code - works in both CLI and web!
import lodash from "lodash"
import { Circuit, Resistor } from "@tscircuit/core"
const values = lodash.range(1, 5)
// ... use npm packages naturally
// Programmatic API
import { withNpmImports } from "tscircuit"
const result = await withNpmImports({
code: userCode,
environment: 'cli' | 'web' | 'auto',
cdnProvider: 'skypack' | 'jsdelivr' | 'unpkg' | 'esm'
})
# Run tests
bun test test/npm-imports.test.ts # ✅ 6 tests pass
# Try examples
bun run examples/npm-import-usage.ts
import x from "package"
→ import x from "https://cdn.skypack.dev/package"
Fixes #760 /claim #760
Rishi Mondal
@MAVRICK-1
tscircuit
@tscircuit