koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.
https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/
MIT License
546 stars 155 forks source link

ReferenceError: regeneratorRuntime in File Input #301

Closed dkumor closed 2 years ago

dkumor commented 3 years ago

When using a schema which includes a file upload, I am getting the following error:

[Vue warn]: Error in v-on handler: "ReferenceError: regeneratorRuntime is not defined"

found in

---> <VFileInput>
       <VJsf>... (1 recursive calls)
         <VForm>

To the best of my understanding this happens because vuetify-jsonschema-form uses babel-polyfill for async functionality. My project does not use babel, and therefore doesn't have regeneratorRuntime defined, leading to an error in file uploads.

I tried working around this by using import VJsf from "@koumoul/vjsf/lib/VJsfNoDeps"; in the hopes that it would avoid the polyfill, but got an error about require.

To the best of my understanding, the polyfill is not meant for libraries, https://babeljs.io/docs/en/babel-polyfill/ says: is intended to be used in an application rather than a library/tool..

I am not entirely sure what the fix here would be, other than the recommendations given here: https://babeljs.io/docs/en/usage/#polyfill

I was able to work around the issue by explicitly importing the regenerator runtime:

import VJsf from "@koumoul/vjsf";
import "@koumoul/vjsf/dist/main.css";
import "regenerator-runtime/runtime"; // Needed to vjsf file upload support
michalgmazurek commented 2 years ago

Any info about fixing that? Workaround mentioned above did not work for me :( I still receive error


Uncaught ReferenceError: regeneratorRuntime is not defined
    at main.js:1:47777
    at Object../node_modules/@koumoul/vjsf/dist/main.js (main.js:1:48394)```
albanm commented 2 years ago

I just released a new version 2.10.2, I think this is solved in it.