Skip to content

Commit

Permalink
fix(findExports): support generator (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Sep 4, 2023
1 parent 294edfe commit 6ee6960
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const IMPORT_NAMED_TYPE_RE =
/(?<=\s|^|;)import\s*type\s+([\s"']*(?<imports>[\w\t\n\r $*,/{}]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gm;

export const EXPORT_DECAL_RE =
/\bexport\s+(?<declaration>(async function|function|let|const enum|const|enum|var|class))\s+(?<name>[\w$]+)/g;
/\bexport\s+(?<declaration>(async function\s*\*?|function\s*\*?|let|const enum|const|enum|var|class))\s+\*?(?<name>[\w$]+)/g;
export const EXPORT_DECAL_TYPE_RE =
/\bexport\s+(?<declaration>(interface|type|declare (async function|function|let|const enum|const|enum|var|class)))\s+(?<name>[\w$]+)/g;
const EXPORT_NAMED_RE =
Expand Down
2 changes: 2 additions & 0 deletions test/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ describe("findExports", () => {
specifier: "./path",
},
"export async function foo ()": { type: "declaration", names: ["foo"] },
"export async function* foo ()": { type: "declaration", names: ["foo"] },
"export async function *foo ()": { type: "declaration", names: ["foo"] },
"export const $foo = () => {}": { type: "declaration", names: ["$foo"] },
"export { foo as default }": {
type: "default",
Expand Down

0 comments on commit 6ee6960

Please sign in to comment.