From 6f90e2844ede2ac4ede73a2429e6af78bd1a9438 Mon Sep 17 00:00:00 2001 From: bezalel6 <51681171+bezalel6@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:23:06 +0300 Subject: [PATCH 1/2] modify parseDefaultExportName so it does not grab an HOC, but the first Argument it takes. presumably the actual component --- packages/blitz/src/cli/utils/routes-manifest.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/blitz/src/cli/utils/routes-manifest.ts b/packages/blitz/src/cli/utils/routes-manifest.ts index 9e721b3534..7115e8d5f1 100644 --- a/packages/blitz/src/cli/utils/routes-manifest.ts +++ b/packages/blitz/src/cli/utils/routes-manifest.ts @@ -504,12 +504,13 @@ const pascalCase = (value: string): string => { return val.substr(0, 1).toUpperCase() + val.substr(1) } export function parseDefaultExportName(contents: string): string | null { - const result = contents.match(/export\s+default(?:\s+(?:const|let|class|var|function))?\s+(\w+)/) + const result = contents.match(/export\s+default(?:\s+(const|let|class|var|function))?\s+(\w+)(?:\(([a-zA-Z_$][a-zA-Z0-9_$]*\b).*\))?/) if (!result) { return null } - - return result[1] ?? null + const [,declaration,compOrHOCName,comp] = result + if(declaration||!comp) return compOrHOCName ?? null; + return comp ?? null } export async function generateManifest() { const config = await loadConfig(process.cwd()) From 379feafd3ca70cab5118af642a5cdd60503708fe Mon Sep 17 00:00:00 2001 From: bezalel6 Date: Sun, 14 Jul 2024 20:52:50 +0300 Subject: [PATCH 2/2] created changeset --- .changeset/little-boats-rest.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/little-boats-rest.md diff --git a/.changeset/little-boats-rest.md b/.changeset/little-boats-rest.md new file mode 100644 index 0000000000..c21ec9a254 --- /dev/null +++ b/.changeset/little-boats-rest.md @@ -0,0 +1,5 @@ +--- +"blitz": patch +--- + +Improved parsing of default export names to handle higher-order components (HOCs) in the `parseDefaultExportName` function.