scan

Bun

Symbol

Transpiler.scan

scan(code: StringOrBuffer): { exports: string[]; imports: Import[] }

Get a list of import paths and paths from a TypeScript, JSX, TSX, or JavaScript file.

@param code

The code to scan

const {imports, exports} = transpiler.scan(`
import {foo} from "baz";
export const hello = "hi!";
`);

console.log(imports); // ["baz"]
console.log(exports); // ["hello"]

Referenced types

type StringOrBuffer = string | NodeJS.TypedArray | ArrayBufferLike