diff --git a/README.md b/README.md index ea29b90..0a0c6c1 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ import { resolveImports } from 'mlly' console.log(await resolveImports(`import foo from './bar.mjs'`, { url: import.meta.url })) ``` -## Evaluating Moduls +## Evaluating Modules ### `evalModule` diff --git a/lib/index.d.ts b/lib/index.d.ts index 55bfd85..08ebe6d 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -49,9 +49,28 @@ export interface DynamicImport extends ESMImport { expression: string } +export interface ESMExport { + type: 'declaration' | 'named' | 'default', + code: string + start: number + end: number +} + +export interface DeclarationExport extends ESMExport { + type: 'declaration' + declaration: string + name: string +} + +export interface NamedExport extends ESMExport { + type: 'named' + exports: string + names: string[] +} + export function findStaticImports (code: string) : StaticImport[] export function findDynamicImports (code: string) : DynamicImport[] -export function findNamedExports (code:string): string[] +export function findExports (code: string): (NamedExport | DeclarationExport | ESMExport)[] export function parseStaticImport (staticImport: StaticImport) : ParsedStaticImport // Evaluate