Skip to content

Commit

Permalink
Adjust codegen logic for suspense patch
Browse files Browse the repository at this point in the history
Correctly account for Next 13.1 - 13.3.0
Add new for 13.3.1

(Yes, Blitz b26 depends on Next 13.3.0,
so we could account for >=13.3 scenarios only)

Fixes: blitz-js#4112
  • Loading branch information
gjmoed authored and G.J. Moed committed Apr 30, 2023
1 parent 7e0e0f9 commit fa0e590
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/blitz/src/cli/utils/codegen-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,24 @@ export const codegenTasks = async () => {
)
await fs.writeFile(nextClientIndex, updatedFile)
log.success("Next.js was successfully patched with a React Suspense fix")
} else if (nextVersion && semver.satisfies(nextVersion, ">=13.2")) {
} else if (nextVersion && semver.satisfies(nextVersion, "13.1 - 13.3.0")) {
const updatedFile = readFile
.toString()
.replace(
/_onRecoverableError\.default/,
/_onRecoverableError\.default$/,
`(err) => (err.toString().includes("DYNAMIC_SERVER_USAGE") || err.toString().includes("could not finish this Suspense boundary") || err.toString().includes("Minified React error #419")) ? null : _onRecoverableError.default(err)`,
)
await fs.writeFile(nextClientIndex, updatedFile)
log.success("Next.js was successfully patched with a React Suspense fix")
} else if (nextVersion && semver.satisfies(nextVersion, ">=13.3.1")) {
const updatedFile = readFile
.toString()
.replace(
/_onrecoverableerror\.default$/,
`(err) => (err.toString().includes("DYNAMIC_SERVER_USAGE") || err.toString().includes("could not finish this Suspense boundary") || err.toString().includes("Minified React error #419")) ? null : _onrecoverableerror.default(err)`,
)
await fs.writeFile(nextClientIndex, updatedFile)
log.success("Next.js was successfully patched with a React Suspense fix")
}
} catch (err) {
log.error(JSON.stringify(err, null, 2))
Expand Down

0 comments on commit fa0e590

Please sign in to comment.