-1

Nuxt with server side rendering. Typescript and vee-validate 3.4.9.

This code is fine

extend('positive', value => {
  return value >= 0;
});

Add the default then I get the Unexpected token 'export' error

extend('required', { ...required });

What I have read so far is that this is a transpile error?

Interlated
  • 5,108
  • 6
  • 48
  • 79
  • 1
    Please, provide all necessary information, not just snippets. Please, provide the whole error, including stack. What is the context for this code? The obvious difference is that another snippet has `required`. *Add the default* - what is the meaning of this? – Estus Flask Jun 15 '21 at 06:50
  • That is the only line you have to change and nuxt breaks in a basic generated nuxt site – Interlated Jun 15 '21 at 06:59

2 Answers2

1

https://vee-validate.logaretm.com/v3/guide/rules.html#importing-the-rules

You can fix that by either ignoring vee-validate/dist/rules from the transpilation process or importing rules from vee-validate/dist/rules.umd instead

import { required } from "vee-validate/dist/rules.umd";

the above added umd works for me

BTW, I think you may just want extend('required', required); instead?

new2cpp
  • 3,311
  • 5
  • 28
  • 39
0

Transpile did fix it in nuxt.config.js

build: {
    transpile: [
        'vee-validate'
    ]
},
Interlated
  • 5,108
  • 6
  • 48
  • 79