Skip to content

Commit

Permalink
more exports
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Oct 9, 2024
1 parent fa87c23 commit d5c5cf5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions lib/code-runner-utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./get-imports-from-code"
2 changes: 1 addition & 1 deletion lib/code-runner/index.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 11 additions & 4 deletions tests/lib/get-imports-from-code.test.ts
Original file line number Diff line number Diff line change
@@ -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 = `
Expand All @@ -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", () => {
Expand All @@ -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", () => {
Expand All @@ -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"])
})

0 comments on commit d5c5cf5

Please sign in to comment.