0

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

askeet
  • 689
  • 1
  • 11
  • 24
  • Here's how to create an `iife` export of `@vuelidate/core`: https://stackoverflow.com/a/70636365/1891677 – tao Jan 11 '22 at 06:44

1 Answers1

1

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

Daniel
  • 34,125
  • 17
  • 102
  • 150
  • Where should I add this I see an error module is not defined ? I would really appreciate to have jsfiddle example with links Here is my example of loading library to project function () { module.exports = { chainWebpack: config => { config.externals({ 'vuelidate': 'validators' }) } } return 'https://cdn.jsdelivr.net/npm/@vuelidate/core@2.0.0-alpha.14/dist/index.min.js'; }() – askeet Mar 02 '21 at 14:41
  • Project doesn't have Node.js it includes Vue 3 only from CDN . – askeet Mar 02 '21 at 15:16