-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(loader): JSON parse throwing if isn't valid #37
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/shuding/nextra/37uomuqnq [Deployment for b85a003 failed] |
packages/nextra/src/loader.js
Outdated
let parsed | ||
try { | ||
parsed = JSON.parse(file) | ||
} catch (err) { | ||
throw Error(`Error parsing ${path}, make sure it's a valid JSON \n` + err) | ||
} | ||
|
||
return parsed |
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.
Thank you! Will this error thrown make the dev server recoverable? Like do I need to restart the dev server once I fix the JSON file?
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.
Couldn't make the examples working with the local version so I can't test it manually. But I would assume so, since if there's any throw in a webpack loader it's a node process and it would crash. I believe there's a way to "accumulate" those errors in the webpack plugin API somewhere.
It might be simpler to console.error
thought.
Let me try to run examples locally.
Yeah the deployment fails is because the |
Co-authored-by: Shu Ding <g@shud.in>
Thanks! |
fix(loader): JSON parse throwing if isn't valid
For some reason when I cloned nextra-docs meta.json files were considered "META" from my editor and I kept doing silly mistakes.
-- Not sure why the deploy failed, but I would assume it's because It's not on my vercel account?