diff --git a/lib/code-runner/get-imports-from-code.ts b/lib/code-runner-utils/get-imports-from-code.ts similarity index 100% rename from lib/code-runner/get-imports-from-code.ts rename to lib/code-runner-utils/get-imports-from-code.ts diff --git a/lib/code-runner-utils/index.ts b/lib/code-runner-utils/index.ts new file mode 100644 index 0000000..d8ad13c --- /dev/null +++ b/lib/code-runner-utils/index.ts @@ -0,0 +1 @@ +export * from "./get-imports-from-code" diff --git a/lib/code-runner/index.ts b/lib/code-runner/index.ts index 92bb51c..44748fa 100644 --- a/lib/code-runner/index.ts +++ b/lib/code-runner/index.ts @@ -1,5 +1,5 @@ export * from "./code-runner-context" -export * from "./get-imports-from-code" +export * from "../code-runner-utils/get-imports-from-code" export * from "./run-prompt" export * from "./safe-evaluate-code" export * from "./transpile-code" diff --git a/package.json b/package.json index 57dff2e..be8ceec 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,12 @@ "license": "MIT", "author": "Severin Ibarluzea", "scripts": { - "build": "tsup lib/index.ts lib/code-runner/index.ts --format esm --dts", + "build": "tsup lib/index.ts lib/code-runner/index.ts lib/code-runner-utils/index.ts --format esm --dts", "test": "bun test --timeout 60000" }, "exports": { "./code-runner": "./dist/code-runner/index.js", + "./code-runner-utils": "./dist/code-runner-utils/index.js", ".": "./dist/index.js" }, "type": "module", diff --git a/tests/lib/get-imports-from-code.test.ts b/tests/lib/get-imports-from-code.test.ts index d2cc2c7..b3b34dd 100644 --- a/tests/lib/get-imports-from-code.test.ts +++ b/tests/lib/get-imports-from-code.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test" -import { getImportsFromCode } from "../../lib/code-runner/get-imports-from-code" +import { getImportsFromCode } from "../../lib/code-runner-utils/get-imports-from-code" test("getImportsFromCode with various import styles", () => { const testCode = ` @@ -17,7 +17,14 @@ test("getImportsFromCode with various import styles", () => { const imports = getImportsFromCode(testCode) - expect(imports).toEqual(['react', 'react', 'axios', './utils', './types', './styles.css']) + expect(imports).toEqual([ + "react", + "react", + "axios", + "./utils", + "./types", + "./styles.css", + ]) }) test("getImportsFromCode with no imports", () => { @@ -42,7 +49,7 @@ test("getImportsFromCode with mixed quotes", () => { const imports = getImportsFromCode(testCode) - expect(imports).toEqual(['react', 'react', 'axios']) + expect(imports).toEqual(["react", "react", "axios"]) }) test("getImportsFromCode with side-effect imports", () => { @@ -53,5 +60,5 @@ test("getImportsFromCode with side-effect imports", () => { const imports = getImportsFromCode(testCode) - expect(imports).toEqual(['dotenv/config', './polyfills']) + expect(imports).toEqual(["dotenv/config", "./polyfills"]) })