feat: Add runtime errors overlay to show undefined nodes location #372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR:
UndefinedNodesOverlay-speed.mp4
Important notes
Two routes were added for when
environment.development === true
(written inserver/devRoutes.js
):/nullstack-dev-server/get-file?fileName=full/path/to/File.jsx&lineNumber=20&columnNumber=2
:Returns the formatted
file
pointing exactly where the undefined error happens and therelativePath
to it (for showing purposes)./nullstack-dev-server/open-editor?fileName=full/path/to/File.jsx:20:2
:Opens editor in that line/column using Evan You's
launch-editor
.The default editor can be configured, I moved that possibility to a env variable
NULLSTACK_EDITOR
defaulting to VSCode.Only works in development mode (when
__source
object is injected for every node by SWC & Babel), otherwise throws saying to retry that route in development mode to see the source of error.The errors are always cleared at every
generateTree
call, keeping it all updated at every rerender step.Throws became the last-case warning, only happening in production (
__source === undefined
) or when the main component tries to render an undefined node itself, like: