Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/eval/execution-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as tscircuitMathUtils from "@tscircuit/math-utils"
import type { PlatformConfig } from "@tscircuit/props"
import { getPlatformConfig } from "lib/getPlatformConfig"
import type { TsConfig } from "lib/runner/tsconfigPaths"
import * as tslib from "tslib"
import Debug from "debug"

const debug = Debug("tsci:eval:execution-context")
Expand Down Expand Up @@ -79,6 +80,7 @@ export function createExecutionContext(
react: React,
"react/jsx-runtime": ReactJsxRuntime,
debug: Debug,
tslib,

// This is usually used as a type import, we can remove the shim when we
// ignore type imports in getImportsFromCode
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"sucrase": "^3.35.0",
"ts-expect": "^1.3.0",
"tsup": "^8.2.4",
"tslib": "^2.8.1",
"@tscircuit/common": "^0.0.20",
"@tscircuit/copper-pour-solver": "^0.0.14"
},
Expand Down
18 changes: 18 additions & 0 deletions tests/features/presupplied-imports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from "bun:test"
import { CircuitRunner } from "lib/runner/CircuitRunner"

test("tslib is added to pre-supplied imports", async () => {
const runner = new CircuitRunner()

await runner.execute(`
import { __assign } from "tslib"

const dimensions = __assign({ width: "10mm" }, { height: "10mm" })

circuit.add(<board {...dimensions} />)
`)

await runner.renderUntilSettled()

expect(runner._executionContext?.preSuppliedImports.tslib).toBeDefined()
})