Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify parseDefaultExportName so it does not grab an HOC, but the fir… #4359

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/little-boats-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"blitz": patch
---

Improved parsing of default export names to handle higher-order components (HOCs) in the `parseDefaultExportName` function.
7 changes: 4 additions & 3 deletions packages/blitz/src/cli/utils/routes-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading