@tscircuit/eval 0.0.286 → 0.0.287
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -54,9 +54,10 @@ export const setupDefaultEntrypointIfNeeded = (opts: {
|
|
|
54
54
|
? `
|
|
55
55
|
const ComponentToRender = UserComponents["${opts.mainComponentName}"]
|
|
56
56
|
`
|
|
57
|
-
: `const ComponentToRender =
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
: `const ComponentToRender = UserComponents.default ||
|
|
58
|
+
Object.entries(UserComponents)
|
|
59
|
+
.filter(([name]) => !name.startsWith("use"))
|
|
60
|
+
.map(([_, component]) => component)[0] || (() => null);`
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
${
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/eval",
|
|
3
3
|
"main": "dist/lib/index.js",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.287",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "bun run build:lib && bun run build:webworker && bun run build:blob-url && bun run build:runner && bun run build:worker-wrapper",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { runTscircuitCode } from "lib/runner"
|
|
2
|
+
import { expect, test } from "bun:test"
|
|
3
|
+
|
|
4
|
+
test("example12 subdirectory relative imports", async () => {
|
|
5
|
+
const circuitJson = await runTscircuitCode(
|
|
6
|
+
{
|
|
7
|
+
"lib/resistor.tsx": `
|
|
8
|
+
export default () => (<resistor name="R1" resistance="1k" />)
|
|
9
|
+
`,
|
|
10
|
+
"user-code.tsx": `
|
|
11
|
+
import Resistor from "./lib/resistor";
|
|
12
|
+
export default () => (<resistor name="R2" resistance="2k" />)
|
|
13
|
+
export {Resistor}
|
|
14
|
+
`,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
mainComponentPath: "user-code",
|
|
18
|
+
},
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const resistor = circuitJson.find(
|
|
22
|
+
(element) => element.type === "source_component",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
expect(resistor).toBeDefined()
|
|
26
|
+
expect(resistor?.name).toBe("R2")
|
|
27
|
+
})
|