Search code examples
cdnvuejs3vuelidate

Support Vuelidate with CDN for Vue 3


Unfortunate in current study migration of one big old JS project we can not use npm I would like to add vuelidate support for Vue 3 but don't see how I can do it without npm By official documentation from https://github.com/vuelidate/vuelidate/tree/next I see that I should to do

npm install @vuelidate/core @vuelidate/validators
# or
yarn add @vuelidate/core @vuelidate/validators 

But how to do this like it was done for browser read-only bundle vuelidate with Vue 2 https://github.com/vuelidate/vuelidate#installation ?

Here some example:

https://jsfiddle.net/b5v4faqf/

For Vue 3 I see this error enter image description here


Solution

  • Update

    So the problem is that since you're not bundling you can't include as a compiled dependency, and since you're using vue2 you can't use an available compiled dependency via CDN.

    The problem is that even though vuelidate is available through the jsdelivr CDN for Vue 3, it is not a compiled package and will not run with your project. The available package might work for something like snowpack, but that's for local development.

    You can...

    • wait until it is available for vue 3 as a bundled dependency that you can include the way you can for vue 2
    • use vue2 (I've had to do this for a project, wasn't happy about it, but was the simplest way to do it)
    • or create your own bundle and serve it with your project

    https://www.jsdelivr.com/?query=author%3A%20vuelidate