Skip to content

Commit

Permalink
fix: do not require space before named exports
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Nov 11, 2024
1 parent c1c7faf commit 9e2baba
Show file tree
Hide file tree
Showing 2 changed files with 9 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 @@ -267,7 +267,7 @@ export const EXPORT_DECAL_RE =
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 =
/\bexport\s+{(?<exports>[^}]+?)[\s,]*}(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
/\bexport\s*{(?<exports>[^}]+?)[\s,]*}(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
const EXPORT_NAMED_TYPE_RE =
/\bexport\s+type\s+{(?<exports>[^}]+?)[\s,]*}(\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
const EXPORT_NAMED_DESTRUCT =
Expand Down
8 changes: 8 additions & 0 deletions test/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ describe("findExportNames", () => {
"default",
]
`);
expect(
findExportNames(`export{a as globalMiddleware,d as namedMiddleware};`),
).toMatchInlineSnapshot(`
[
"globalMiddleware",
"namedMiddleware",
]
`);
});
});

Expand Down

0 comments on commit 9e2baba

Please sign in to comment.