Skip to content

Commit 804bd9c

Browse files
authored
Add tslib to pre-supplied imports (#1630)
1 parent 8e58d63 commit 804bd9c

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/eval/execution-context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as tscircuitMathUtils from "@tscircuit/math-utils"
77
import type { PlatformConfig } from "@tscircuit/props"
88
import { getPlatformConfig } from "lib/getPlatformConfig"
99
import type { TsConfig } from "lib/runner/tsconfigPaths"
10+
import * as tslib from "tslib"
1011
import Debug from "debug"
1112

1213
const debug = Debug("tsci:eval:execution-context")
@@ -79,6 +80,7 @@ export function createExecutionContext(
7980
react: React,
8081
"react/jsx-runtime": ReactJsxRuntime,
8182
debug: Debug,
83+
tslib,
8284

8385
// This is usually used as a type import, we can remove the shim when we
8486
// ignore type imports in getImportsFromCode

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"sucrase": "^3.35.0",
122122
"ts-expect": "^1.3.0",
123123
"tsup": "^8.2.4",
124+
"tslib": "^2.8.1",
124125
"@tscircuit/common": "^0.0.20",
125126
"@tscircuit/copper-pour-solver": "^0.0.14"
126127
},
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { expect, test } from "bun:test"
2+
import { CircuitRunner } from "lib/runner/CircuitRunner"
3+
4+
test("tslib is added to pre-supplied imports", async () => {
5+
const runner = new CircuitRunner()
6+
7+
await runner.execute(`
8+
import { __assign } from "tslib"
9+
10+
const dimensions = __assign({ width: "10mm" }, { height: "10mm" })
11+
12+
circuit.add(<board {...dimensions} />)
13+
`)
14+
15+
await runner.renderUntilSettled()
16+
17+
expect(runner._executionContext?.preSuppliedImports.tslib).toBeDefined()
18+
})

0 commit comments

Comments
 (0)