Skip to content

Commit

Permalink
fix(types): types for findExports (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Oct 15, 2021
1 parent e5cfb8b commit 68b7c39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
21 changes: 20 additions & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 68b7c39

Please sign in to comment.