react-jsonschema-form
react-jsonschema-form copied to clipboard
Is Precompiled Schema Validation Supported in RJSF 6.0.0-beta.7?
Prerequisites
- [x] I have read the documentation
What theme are you using?
shadcn
What is your question?
Hi! Thanks for the recent updates—support for shadcn is awesome! 😊
I'm building a Chrome extension and running into the following error:
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
From what I understand, based on the docs, I need to precompile my schema to avoid eval. However, the example there seems outdated.
First, it shows a TypeScript error indicating it needs more arguments than what's shown in the documentation:
Even if I pass JSONSchema that I used to generate precompiledValidator it throws following error in the browsers console.
Am I doing something the wrong way or is it not supported yet in the 6.0.0-beta.7 version?
Here's a part my package.json
"dependencies": {
...
"@rjsf/core": "6.0.0-beta.7",
"@rjsf/shadcn": "6.0.0-beta.7",
"@rjsf/utils": "6.0.0-beta.7",
"@rjsf/validator-ajv8": "6.0.0-beta.7",
...
},
@WiktorG You have to precompile the schema on the server and serve it up to the browser. You can't precompile on the browser since the precompilation step actually does the evals. If you have a static schema, then you can precompile it as part of your build process and then simply import it per the documentation.
You did point out some documentation issues, which I am fixing.
@heath-freenome Hi - thanks for the fixes!
Yeah - build process precompilation is what I'm trying to do. I assume that I should be able to do it manually on my computer and then just use it in my project.
@WiktorG I've set up my npm install to precompile the schema via a postinstall script so that everytime I install/update the project I don't have to remember to recompile the schema.
@WiktorG If you are able to get this working, please close the ticket, otherwise keep asking questions
Hi – I haven't had much time to work lately, but I'll keep you updated, as getting this work is very important in my project.