From 9e2baba06fca9afcac835ac3d7f22a10c4885712 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 11 Nov 2024 23:53:57 +0000 Subject: [PATCH] fix: do not require space before named exports --- src/analyze.ts | 2 +- test/exports.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/analyze.ts b/src/analyze.ts index ed439d0..f08adb3 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -267,7 +267,7 @@ export const EXPORT_DECAL_RE = export const EXPORT_DECAL_TYPE_RE = /\bexport\s+(?(interface|type|declare (async function|function|let|const enum|const|enum|var|class)))\s+(?[\w$]+)/g; const EXPORT_NAMED_RE = - /\bexport\s+{(?[^}]+?)[\s,]*}(\s*from\s*["']\s*(?(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g; + /\bexport\s*{(?[^}]+?)[\s,]*}(\s*from\s*["']\s*(?(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g; const EXPORT_NAMED_TYPE_RE = /\bexport\s+type\s+{(?[^}]+?)[\s,]*}(\s*from\s*["']\s*(?(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g; const EXPORT_NAMED_DESTRUCT = diff --git a/test/exports.test.ts b/test/exports.test.ts index f7ec0e3..46dd9e4 100644 --- a/test/exports.test.ts +++ b/test/exports.test.ts @@ -256,6 +256,14 @@ describe("findExportNames", () => { "default", ] `); + expect( + findExportNames(`export{a as globalMiddleware,d as namedMiddleware};`), + ).toMatchInlineSnapshot(` + [ + "globalMiddleware", + "namedMiddleware", + ] + `); }); });