-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add future.v2_errorBoundary flag #4918
Conversation
🦋 Changeset detectedLatest commit: 9aa0dc1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
return <RemixRootDefaultCatchBoundaryImpl caught={caught} />; | ||
} | ||
|
||
function RemixRootDefaultCatchBoundaryImpl({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted internals into a component that can be used by the default Remix v2 Root Error Boundary
differentiateCatchVersusErrorBoundaries(build, context); | ||
if (build.future.v2_errorBoundary !== true) { | ||
differentiateCatchVersusErrorBoundaries(build, context); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to re-bubble if we only have one element
// @ts-expect-error | ||
return <ErrorBoundary />; | ||
} | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we've opted in, just render the ErrorBoundary
directly
cd971d0
to
13e5498
Compare
if (init.future) { | ||
let contents = fse.readFileSync( | ||
path.join(projectDir, "remix.config.js"), | ||
"utf-8" | ||
); | ||
if (!contents.includes("future: {},")) { | ||
throw new Error("Invalid formatted remix.config.js in template"); | ||
} | ||
contents = contents.replace( | ||
"future: {},", | ||
"future: " + JSON.stringify(init.future) + "," | ||
); | ||
fse.writeFileSync(path.join(projectDir, "remix.config.js"), contents); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you pass a future config into createFixtureProject
we'll write it into the remix config here
error={tError.error} | ||
/> | ||
); | ||
return <ErrorBoundary error={tError.error} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got rid of the Remix Error Boundary wrapper since we can just use on the RR one internally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacob-ebey This is what I was talking about. From my testing all seems fine here
let errorString = | ||
error == null | ||
? "Unknown Error" | ||
: typeof error === "object" && "toString" in error | ||
? error.toString() | ||
: JSON.stringify(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this worth it, maybe we just console.error
and fall back to new Error("Unknown Error")
?
I gotta figure out what's going on with this TSC error in the build :/. Can't seem to pull |
Co-authored-by: Sergio Xalambrí <hello@sergiodxa.com>
Co-authored-by: Mehdi Achour <machour@gmail.com>
depending on if you're generating type defs, you'll need to delete the dist directory from remix-dev |
Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Adds
future.v2_errorBoundary
flag to opt into Remix v2ErrorBoundary
behavior