@tscircuit/eval 0.0.363 → 0.0.365
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.
- package/dist/blob-url.js +1 -1
- package/dist/webworker/entrypoint.js +28 -28
- package/package.json +6 -3
- package/.github/workflows/bun-formatcheck.yml +0 -27
- package/.github/workflows/bun-pver-release.yml +0 -70
- package/.github/workflows/bun-test.yml +0 -87
- package/.github/workflows/bun-typecheck.yml +0 -27
- package/.github/workflows/playwright.yml +0 -40
- package/.github/workflows/update-deps.yml +0 -47
- package/.github/workflows/update-tscircuit-core.yml +0 -59
- package/biome.json +0 -50
- package/browser-tests/browser.test.ts +0 -15
- package/browser-tests/browsertest.html +0 -15
- package/browser-tests/browsertest.ts +0 -53
- package/bunfig.toml +0 -6
- package/lib/getPlatformConfig.ts +0 -41
- package/lib/getPossibleEntrypointComponentPaths.ts +0 -42
- package/lib/index.ts +0 -5
- package/lib/runner/CircuitRunner.ts +0 -201
- package/lib/runner/index.ts +0 -4
- package/lib/runner/normalizeFsMap.ts +0 -20
- package/lib/runner/resolveFilePath.ts +0 -90
- package/lib/runner/runTscircuitCode.ts +0 -30
- package/lib/runner/runTscircuitModule.ts +0 -37
- package/lib/runner/setupDefaultEntrypointIfNeeded.ts +0 -81
- package/lib/shared/static-asset-extensions.ts +0 -10
- package/lib/shared/types.ts +0 -79
- package/lib/utils/dirname.ts +0 -21
- package/lib/utils/get-imports-from-code.ts +0 -23
- package/lib/utils/index.ts +0 -1
- package/lib/utils/resolve-node-module.ts +0 -193
- package/lib/worker.ts +0 -246
- package/playwright.config.ts +0 -23
- package/scripts/build-worker-blob-url.ts +0 -27
- package/scripts/copy-core-versions.ts +0 -81
- package/scripts/validate-test-matrix.js +0 -148
- package/tests/circuit-runner/circuitrunner1-readme-example.test.tsx +0 -29
- package/tests/custom-component-with-fsmap/should-reject-invalid-main-component-path.test.ts +0 -26
- package/tests/custom-component-with-fsmap/should-render-multiple-components-from-fsmap.test.ts +0 -46
- package/tests/custom-component-with-fsmap/should-render-single-component-from-fsmap.test.ts +0 -38
- package/tests/examples/__snapshots__/example18-kicad-footprint-server.snap.svg +0 -1
- package/tests/examples/example01-readme-example.test.tsx +0 -30
- package/tests/examples/example02-multiple-files.test.tsx +0 -45
- package/tests/examples/example03-encoded-url.test.tsx +0 -28
- package/tests/examples/example04-root-child-issue.test.tsx +0 -37
- package/tests/examples/example05-event-recording.test.tsx +0 -44
- package/tests/examples/example06-dynamic-load-blob-url.test.tsx +0 -29
- package/tests/examples/example07-import-default-and-namespace.test.tsx +0 -74
- package/tests/examples/example08-footprinter-to220.test.tsx +0 -30
- package/tests/examples/example09-not-defined-component.test.tsx +0 -24
- package/tests/examples/example10-run-tscircuit-code.test.tsx +0 -14
- package/tests/examples/example11-flexible-import-extensions.test.tsx +0 -20
- package/tests/examples/example12-import-from-subdirectory.test.tsx +0 -26
- package/tests/examples/example13-webworker-without-entrypoint.test.tsx +0 -32
- package/tests/examples/example14-run-tscircuit-module.test.tsx +0 -20
- package/tests/examples/example15-run-tscircuit-module-with-props.test.tsx +0 -24
- package/tests/examples/example16-parts-engine.test.tsx +0 -118
- package/tests/examples/example17-parse-tscircuit-config.test.tsx +0 -49
- package/tests/examples/example18-kicad-footprint-server.test.tsx +0 -39
- package/tests/examples/example19-support-backwards-compat.test.tsx +0 -31
- package/tests/examples/example20-kicad-import.test.tsx +0 -48
- package/tests/features/circuit-event-forwarding.test.tsx +0 -45
- package/tests/features/enable-debug.test.ts +0 -26
- package/tests/features/execute-component-runner.test.tsx +0 -47
- package/tests/features/execute-component-worker.test.tsx +0 -25
- package/tests/features/fetch-proxy/fetch-override.test.ts +0 -46
- package/tests/features/fetch-proxy/fetch-proxy-validation.test.ts +0 -95
- package/tests/features/kill.test.ts +0 -24
- package/tests/features/manual-edits.test.tsx +0 -118
- package/tests/features/npm-import.test.tsx +0 -47
- package/tests/features/parent-directory-import.test.tsx +0 -26
- package/tests/features/platform-config.test.tsx +0 -23
- package/tests/features/prioritize-default-export.test.tsx +0 -27
- package/tests/features/project-config.test.tsx +0 -25
- package/tests/features/static-file-imports/static-file-import.test.ts +0 -50
- package/tests/fixtures/preload.ts +0 -10
- package/tests/fixtures/resourcePaths.ts +0 -3
- package/tests/node-resolution/node-module-resolution-1.test.tsx +0 -32
- package/tests/node-resolution/node-module-resolution-10.test.tsx +0 -30
- package/tests/node-resolution/node-module-resolution-11.test.tsx +0 -41
- package/tests/node-resolution/node-module-resolution-2.test.tsx +0 -33
- package/tests/node-resolution/node-module-resolution-3.test.tsx +0 -38
- package/tests/node-resolution/node-module-resolution-4.test.tsx +0 -29
- package/tests/node-resolution/node-module-resolution-5.test.tsx +0 -38
- package/tests/node-resolution/node-module-resolution-6.test.tsx +0 -40
- package/tests/node-resolution/node-module-resolution-7.test.tsx +0 -43
- package/tests/node-resolution/node-module-resolution-8.test.tsx +0 -32
- package/tests/node-resolution/node-module-resolution-9.test.tsx +0 -29
- package/tests/node-resolution/node-modules-resolution-12.test.tsx +0 -30
- package/tests/repros/group-wrapper.test.tsx +0 -18
- package/tests/repros/nine-keyboard-default-export.test.tsx +0 -26
- package/tests/util-fns/get-imports-from-code.test.tsx +0 -93
- package/tests/util-fns/getPossibleEntrypointComponentPaths.test.ts +0 -35
- package/tsconfig.json +0 -34
- package/tsup-lib.config.ts +0 -11
- package/tsup-runner.config.ts +0 -12
- package/tsup-webworker.config.ts +0 -21
- package/webworker/entrypoint.ts +0 -227
- package/webworker/eval-compiled-js.ts +0 -61
- package/webworker/execution-context.ts +0 -64
- package/webworker/fetchProxy.ts +0 -83
- package/webworker/import-eval-path.ts +0 -78
- package/webworker/import-local-file.ts +0 -93
- package/webworker/import-node-module.ts +0 -54
- package/webworker/import-npm-package.ts +0 -77
- package/webworker/import-snippet.ts +0 -30
- package/webworker/index.ts +0 -1
- package/webworker/transform-with-sucrase.ts +0 -68
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { runTscircuitCode } from "lib/runner"
|
|
3
|
-
|
|
4
|
-
describe("node module resolution", () => {
|
|
5
|
-
test("resolves package.json exports field with default condition", async () => {
|
|
6
|
-
const circuitJson = await runTscircuitCode(
|
|
7
|
-
{
|
|
8
|
-
"node_modules/test-package/package.json": JSON.stringify({
|
|
9
|
-
name: "test-package",
|
|
10
|
-
exports: {
|
|
11
|
-
".": "./dist/modern.js",
|
|
12
|
-
},
|
|
13
|
-
}),
|
|
14
|
-
"node_modules/test-package/dist/modern.js": `
|
|
15
|
-
export const resistorName = "R4"
|
|
16
|
-
export const resistanceValue = "4k"
|
|
17
|
-
`,
|
|
18
|
-
"node_modules/test-package/index.js": `
|
|
19
|
-
export const resistorName = "wrong-name"
|
|
20
|
-
export const resistanceValue = "wrong-value"
|
|
21
|
-
`,
|
|
22
|
-
"user-code.tsx": `
|
|
23
|
-
import { resistorName, resistanceValue } from "test-package"
|
|
24
|
-
export default () => (<resistor name={resistorName} resistance={resistanceValue} />)
|
|
25
|
-
`,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
mainComponentPath: "user-code",
|
|
29
|
-
},
|
|
30
|
-
)
|
|
31
|
-
const resistor = circuitJson.find(
|
|
32
|
-
(element) => element.type === "source_component",
|
|
33
|
-
) as any
|
|
34
|
-
expect(resistor).toBeDefined()
|
|
35
|
-
expect(resistor.resistance).toBe(4000)
|
|
36
|
-
expect(resistor.name).toBe("R4")
|
|
37
|
-
})
|
|
38
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { runTscircuitCode } from "lib/runner"
|
|
3
|
-
|
|
4
|
-
describe("node module resolution", () => {
|
|
5
|
-
test("resolves package.json exports field with conditional exports", async () => {
|
|
6
|
-
const circuitJson = await runTscircuitCode(
|
|
7
|
-
{
|
|
8
|
-
"node_modules/test-package/package.json": JSON.stringify({
|
|
9
|
-
name: "test-package",
|
|
10
|
-
exports: {
|
|
11
|
-
import: "./dist/esm/index.js",
|
|
12
|
-
require: "./dist/cjs/index.js",
|
|
13
|
-
},
|
|
14
|
-
}),
|
|
15
|
-
"node_modules/test-package/dist/esm/index.js": `
|
|
16
|
-
export const resistorName = "R5"
|
|
17
|
-
export const resistanceValue = "5k"
|
|
18
|
-
`,
|
|
19
|
-
"node_modules/test-package/dist/cjs/index.js": `
|
|
20
|
-
exports.resistorName = "wrong-name"
|
|
21
|
-
exports.resistanceValue = "wrong-value"
|
|
22
|
-
`,
|
|
23
|
-
"user-code.tsx": `
|
|
24
|
-
import { resistorName, resistanceValue } from "test-package"
|
|
25
|
-
export default () => (<resistor name={resistorName} resistance={resistanceValue} />)
|
|
26
|
-
`,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
mainComponentPath: "user-code",
|
|
30
|
-
},
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
const resistor = circuitJson.find(
|
|
34
|
-
(element) => element.type === "source_component" && element.name === "R5",
|
|
35
|
-
) as any
|
|
36
|
-
expect(resistor).toBeDefined()
|
|
37
|
-
expect(resistor.resistance).toBe(5000)
|
|
38
|
-
expect(resistor.name).toBe("R5")
|
|
39
|
-
})
|
|
40
|
-
})
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { runTscircuitCode } from "lib/runner"
|
|
3
|
-
|
|
4
|
-
describe("node module resolution", () => {
|
|
5
|
-
test.skip("resolves nested node_modules packages", async () => {
|
|
6
|
-
const circuitJson = await runTscircuitCode(
|
|
7
|
-
{
|
|
8
|
-
"node_modules/parent-package/package.json": JSON.stringify({
|
|
9
|
-
name: "parent-package",
|
|
10
|
-
main: "index.js",
|
|
11
|
-
}),
|
|
12
|
-
"node_modules/parent-package/index.js": `
|
|
13
|
-
import { nestedResistorName, nestedResistanceValue } from "nested-package"
|
|
14
|
-
export const resistorName = nestedResistorName
|
|
15
|
-
export const resistanceValue = nestedResistanceValue
|
|
16
|
-
`,
|
|
17
|
-
"node_modules/parent-package/node_modules/nested-package/package.json":
|
|
18
|
-
JSON.stringify({
|
|
19
|
-
name: "nested-package",
|
|
20
|
-
main: "index.js",
|
|
21
|
-
}),
|
|
22
|
-
"node_modules/parent-package/node_modules/nested-package/index.js": `
|
|
23
|
-
export const nestedResistorName = "R7"
|
|
24
|
-
export const nestedResistanceValue = "7k"
|
|
25
|
-
`,
|
|
26
|
-
"user-code.tsx": `
|
|
27
|
-
import { resistorName, resistanceValue } from "parent-package"
|
|
28
|
-
export default () => (<resistor name={resistorName} resistance={resistanceValue} />)
|
|
29
|
-
`,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
mainComponentPath: "user-code",
|
|
33
|
-
},
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
const resistor = circuitJson.find(
|
|
37
|
-
(element) => element.type === "source_component" && element.name === "R7",
|
|
38
|
-
) as any
|
|
39
|
-
expect(resistor).toBeDefined()
|
|
40
|
-
expect(resistor.resistance).toBe(7000)
|
|
41
|
-
expect(resistor.name).toBe("R7")
|
|
42
|
-
})
|
|
43
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { runTscircuitCode } from "lib/runner"
|
|
3
|
-
|
|
4
|
-
describe("node module resolution", () => {
|
|
5
|
-
test.skip("resolves file with explicit extension", async () => {
|
|
6
|
-
const circuitJson = await runTscircuitCode(
|
|
7
|
-
{
|
|
8
|
-
"node_modules/test-package/index.js": `
|
|
9
|
-
export * from "./resistor.js"
|
|
10
|
-
`,
|
|
11
|
-
"node_modules/test-package/resistor.js": `
|
|
12
|
-
export const resistorName = "R8"
|
|
13
|
-
export const resistanceValue = "8k"
|
|
14
|
-
`,
|
|
15
|
-
"user-code.tsx": `
|
|
16
|
-
import { resistorName, resistanceValue } from "test-package"
|
|
17
|
-
export default () => (<resistor name={resistorName} resistance={resistanceValue} />)
|
|
18
|
-
`,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
mainComponentPath: "user-code",
|
|
22
|
-
},
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
const resistor = circuitJson.find(
|
|
26
|
-
(element) => element.type === "source_component" && element.name === "R8",
|
|
27
|
-
) as any
|
|
28
|
-
expect(resistor).toBeDefined()
|
|
29
|
-
expect(resistor.resistance).toBe(8000)
|
|
30
|
-
expect(resistor.name).toBe("R8")
|
|
31
|
-
})
|
|
32
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { runTscircuitCode } from "lib/runner"
|
|
3
|
-
|
|
4
|
-
describe("node module resolution", () => {
|
|
5
|
-
test("resolves directory import with index.js", async () => {
|
|
6
|
-
const circuitJson = await runTscircuitCode(
|
|
7
|
-
{
|
|
8
|
-
"node_modules/test-package/lib/index.js": `
|
|
9
|
-
export const resistorName = "R9"
|
|
10
|
-
export const resistanceValue = "9k"
|
|
11
|
-
`,
|
|
12
|
-
"user-code.tsx": `
|
|
13
|
-
import { resistorName, resistanceValue } from "test-package/lib"
|
|
14
|
-
export default () => (<resistor name={resistorName} resistance={resistanceValue} />)
|
|
15
|
-
`,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
mainComponentPath: "user-code",
|
|
19
|
-
},
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
const resistor = circuitJson.find(
|
|
23
|
-
(element) => element.type === "source_component" && element.name === "R9",
|
|
24
|
-
) as any
|
|
25
|
-
expect(resistor).toBeDefined()
|
|
26
|
-
expect(resistor.resistance).toBe(9000)
|
|
27
|
-
expect(resistor.name).toBe("R9")
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { CircuitRunner } from "lib/runner/CircuitRunner"
|
|
3
|
-
describe("node module resolution", () => {
|
|
4
|
-
test("node_modules resolution supports tsx", async () => {
|
|
5
|
-
const runner = new CircuitRunner()
|
|
6
|
-
const fsMap = {
|
|
7
|
-
"node_modules/my-resistor/index.tsx": `
|
|
8
|
-
export const MyResistor = ({ name }) => (<resistor name={name} resistance="1k" />)
|
|
9
|
-
`,
|
|
10
|
-
"user-code.tsx": `
|
|
11
|
-
import { MyResistor } from "my-resistor";
|
|
12
|
-
export default () => (<MyResistor name="R1" />)
|
|
13
|
-
`,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
await runner.executeWithFsMap({
|
|
17
|
-
fsMap,
|
|
18
|
-
mainComponentPath: "user-code",
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
await runner.renderUntilSettled()
|
|
22
|
-
const circuitJson = await runner.getCircuitJson()
|
|
23
|
-
|
|
24
|
-
const resistor = circuitJson.find(
|
|
25
|
-
(element) => element.type === "source_component" && element.name === "R1",
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
expect(resistor).toBeDefined()
|
|
29
|
-
})
|
|
30
|
-
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test"
|
|
2
|
-
import { runTscircuitCode } from "lib/runner"
|
|
3
|
-
|
|
4
|
-
test("group is not wrapped in board", async () => {
|
|
5
|
-
const circuitJson = await runTscircuitCode(`
|
|
6
|
-
export default () => (
|
|
7
|
-
<group name="G2">
|
|
8
|
-
<resistor name="R1" footprint="0402" resistance="10k" />
|
|
9
|
-
<capacitor name="C1" capacitance="10uF" footprint="0603" />
|
|
10
|
-
</group>
|
|
11
|
-
)
|
|
12
|
-
`)
|
|
13
|
-
|
|
14
|
-
const sourceGroups = circuitJson.filter((el) => el.type === "source_group")
|
|
15
|
-
|
|
16
|
-
expect(sourceGroups.length).toBe(1)
|
|
17
|
-
expect(sourceGroups[0].name).toBe("G2")
|
|
18
|
-
})
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { runTscircuitCode } from "lib/runner"
|
|
2
|
-
import { test, expect } from "bun:test"
|
|
3
|
-
|
|
4
|
-
test(
|
|
5
|
-
"NineKeyKeyboard default export resolves and renders correctly",
|
|
6
|
-
async () => {
|
|
7
|
-
const circuitJson = await runTscircuitCode(
|
|
8
|
-
{
|
|
9
|
-
"user-code.tsx": `
|
|
10
|
-
import NineKeyKeyboard from "@tsci/seveibar.nine-key-keyboard"
|
|
11
|
-
export default () => <NineKeyKeyboard />
|
|
12
|
-
`,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
mainComponentPath: "user-code",
|
|
16
|
-
},
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
const someSourceElm = circuitJson.find(
|
|
20
|
-
(element) => element.type === "source_component",
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
expect(someSourceElm).toBeDefined()
|
|
24
|
-
},
|
|
25
|
-
{ timeout: 60000 },
|
|
26
|
-
)
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { getImportsFromCode } from "lib/utils/get-imports-from-code"
|
|
2
|
-
import { expect, test } from "bun:test"
|
|
3
|
-
|
|
4
|
-
test("getImportsFromCode should extract imports correctly", () => {
|
|
5
|
-
const sourceCode = `
|
|
6
|
-
import defaultExport from "./local-module"
|
|
7
|
-
import * as namespace from "./namespace-module"
|
|
8
|
-
import { export1, export2 as alias2 } from "./named-exports"
|
|
9
|
-
import "./side-effect-only"
|
|
10
|
-
import { something } from "@tsci/package"
|
|
11
|
-
`
|
|
12
|
-
expect(getImportsFromCode(sourceCode)).toMatchInlineSnapshot(`
|
|
13
|
-
[
|
|
14
|
-
"./local-module",
|
|
15
|
-
"./namespace-module",
|
|
16
|
-
"./named-exports",
|
|
17
|
-
"./side-effect-only",
|
|
18
|
-
"@tsci/package",
|
|
19
|
-
]
|
|
20
|
-
`)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test("getImportsFromCode should handle combined default and namespace imports", () => {
|
|
24
|
-
const sourceCode = `
|
|
25
|
-
import SomeDefault, * as OtherExports from "./file.tsx"
|
|
26
|
-
`
|
|
27
|
-
expect(getImportsFromCode(sourceCode)).toEqual(["./file.tsx"])
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test("getImportsFromCode should handle multiline imports", () => {
|
|
31
|
-
const sourceCode = `
|
|
32
|
-
import {
|
|
33
|
-
export1,
|
|
34
|
-
export2,
|
|
35
|
-
export3 as alias3,
|
|
36
|
-
} from "./multiline"
|
|
37
|
-
`
|
|
38
|
-
expect(getImportsFromCode(sourceCode)).toMatchInlineSnapshot(`
|
|
39
|
-
[
|
|
40
|
-
"./multiline",
|
|
41
|
-
]
|
|
42
|
-
`)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test("getImportsFromCode should handle string literals", () => {
|
|
46
|
-
const sourceCode = `
|
|
47
|
-
// Should handle single and double quotes
|
|
48
|
-
import foo from './single-quotes'
|
|
49
|
-
import bar from "./double-quotes"
|
|
50
|
-
|
|
51
|
-
// These should not be captured:
|
|
52
|
-
const str = "import foo from 'bar'"
|
|
53
|
-
const template = \`import foo from 'bar'\`
|
|
54
|
-
`
|
|
55
|
-
expect(getImportsFromCode(sourceCode)).toMatchInlineSnapshot(`
|
|
56
|
-
[
|
|
57
|
-
"./single-quotes",
|
|
58
|
-
"./double-quotes",
|
|
59
|
-
]
|
|
60
|
-
`)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test("getImportsFromCode should handle dynamic imports", () => {
|
|
64
|
-
const sourceCode = `
|
|
65
|
-
// Dynamic imports should not be captured
|
|
66
|
-
const module = await import('./dynamic-import')
|
|
67
|
-
const otherModule = import('@tsci/package')
|
|
68
|
-
|
|
69
|
-
// Only static imports should be captured
|
|
70
|
-
import staticImport from './static-import'
|
|
71
|
-
`
|
|
72
|
-
expect(getImportsFromCode(sourceCode)).toMatchInlineSnapshot(`
|
|
73
|
-
[
|
|
74
|
-
"./static-import",
|
|
75
|
-
]
|
|
76
|
-
`)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test("getImportsFromCode should handle comments and commented imports", () => {
|
|
80
|
-
const sourceCode = `
|
|
81
|
-
// import foo from './commented'
|
|
82
|
-
/* import bar from './also-commented' */
|
|
83
|
-
import actual from './real-import'
|
|
84
|
-
// More comments
|
|
85
|
-
import another from './another-import'
|
|
86
|
-
`
|
|
87
|
-
expect(getImportsFromCode(sourceCode)).toMatchInlineSnapshot(`
|
|
88
|
-
[
|
|
89
|
-
"./real-import",
|
|
90
|
-
"./another-import",
|
|
91
|
-
]
|
|
92
|
-
`)
|
|
93
|
-
})
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import { getPossibleEntrypointComponentPaths } from "lib/getPossibleEntrypointComponentPaths"
|
|
3
|
-
|
|
4
|
-
test("returns index.tsx if present", () => {
|
|
5
|
-
const paths = getPossibleEntrypointComponentPaths({
|
|
6
|
-
"index.tsx": "export default () => null",
|
|
7
|
-
"foo.tsx": "",
|
|
8
|
-
})
|
|
9
|
-
expect(paths).toContain("index.tsx")
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test("returns *.circuit.tsx files", () => {
|
|
13
|
-
const paths = getPossibleEntrypointComponentPaths({
|
|
14
|
-
"a.circuit.tsx": "",
|
|
15
|
-
"b.circuit.tsx": "",
|
|
16
|
-
})
|
|
17
|
-
expect(paths).toEqual(
|
|
18
|
-
expect.arrayContaining(["a.circuit.tsx", "b.circuit.tsx"]),
|
|
19
|
-
)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test("returns mainEntrypoint from config", () => {
|
|
23
|
-
const paths = getPossibleEntrypointComponentPaths({
|
|
24
|
-
"tscircuit.config.json": '{"mainEntrypoint": "src/main.tsx"}',
|
|
25
|
-
"src/main.tsx": "",
|
|
26
|
-
})
|
|
27
|
-
expect(paths).toContain("src/main.tsx")
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test("returns single tsx file if only one", () => {
|
|
31
|
-
const paths = getPossibleEntrypointComponentPaths({
|
|
32
|
-
"only.tsx": "",
|
|
33
|
-
})
|
|
34
|
-
expect(paths).toContain("only.tsx")
|
|
35
|
-
})
|
package/tsconfig.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
// Enable latest features
|
|
4
|
-
"lib": ["ESNext", "DOM"],
|
|
5
|
-
"target": "es2020",
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"moduleDetection": "force",
|
|
8
|
-
"jsx": "react-jsx",
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
"baseUrl": ".",
|
|
11
|
-
"paths": {
|
|
12
|
-
"lib/*": ["lib/*"],
|
|
13
|
-
"webworker/*": ["webworker/*"],
|
|
14
|
-
"shared/*": ["lib/shared/*"]
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// Bundler mode
|
|
18
|
-
"moduleResolution": "bundler",
|
|
19
|
-
"allowImportingTsExtensions": true,
|
|
20
|
-
"verbatimModuleSyntax": true,
|
|
21
|
-
"noEmit": true,
|
|
22
|
-
|
|
23
|
-
// Best practices
|
|
24
|
-
"strict": true,
|
|
25
|
-
"skipLibCheck": true,
|
|
26
|
-
"noFallthroughCasesInSwitch": true,
|
|
27
|
-
|
|
28
|
-
// Some stricter flags (disabled by default)
|
|
29
|
-
"noUnusedLocals": false,
|
|
30
|
-
"noUnusedParameters": false,
|
|
31
|
-
"noPropertyAccessFromIndexSignature": false
|
|
32
|
-
},
|
|
33
|
-
"exclude": ["node_modules", "dist"]
|
|
34
|
-
}
|
package/tsup-lib.config.ts
DELETED
package/tsup-runner.config.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup"
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ["./lib/runner/index.ts"], // Assuming index.ts is the entrypoint within the runner directory
|
|
5
|
-
format: ["esm"],
|
|
6
|
-
platform: "browser",
|
|
7
|
-
sourcemap: "inline", // Added for consistency
|
|
8
|
-
outDir: "dist/eval",
|
|
9
|
-
noExternal: ["@tscircuit/parts-engine"],
|
|
10
|
-
clean: true, // Added for consistency
|
|
11
|
-
dts: true,
|
|
12
|
-
})
|
package/tsup-webworker.config.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup"
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ["./webworker/entrypoint.ts"],
|
|
5
|
-
format: ["esm"],
|
|
6
|
-
platform: "browser",
|
|
7
|
-
// sourcemap: "inline",
|
|
8
|
-
outDir: "dist/webworker",
|
|
9
|
-
splitting: false,
|
|
10
|
-
minify: true,
|
|
11
|
-
noExternal: [
|
|
12
|
-
"@tscircuit/core",
|
|
13
|
-
"circuit-json",
|
|
14
|
-
"@tscircuit/parts-engine",
|
|
15
|
-
"sucrase",
|
|
16
|
-
"@tscircuit/math-utils",
|
|
17
|
-
"zod",
|
|
18
|
-
],
|
|
19
|
-
clean: true,
|
|
20
|
-
dts: true,
|
|
21
|
-
})
|