fabian-hiller / valibot

The modular and type safe schema library for validating structural data 🤖
https://valibot.dev
MIT License
5.88k stars 181 forks source link

Error: 'pipe' not found in imported namespace 'v' #723

Open cosmemarins opened 1 month ago

cosmemarins commented 1 month ago

Error when running npm run build or yarn build

package.json:

"react-hook-form": "7.51.5",
"@hookform/resolvers": "3.6.0",
"valibot": "0.31.1"

I tried too:

"react-hook-form": "7.51.5",
"@hookform/resolvers": "3.6.0",
"valibot": "0.36.0"

image

Login.tsx page

image

fabian-hiller commented 1 month ago

Please try again after updating everything to the latest version.

"react-hook-form": "7.52.1",
"@hookform/resolvers": "3.9.0",
"valibot": "0.36.0"
cosmemarins commented 1 month ago

I tried but it didn't work

The error is only on production, locally it works

It worked for me by separating the import pipe

import * as v from 'valibot'
import { pipe } from 'valibot'
...
const schema = v.object({
  email: pipe(v.string('É preciso digitar um email'), v.email('Email inválido')),
  password: pipe(v.string('É preciso digitar uma senha'), v.minLength(5, 'A senha deve conter no mínimo 5 caracteres'))
})
fabian-hiller commented 1 month ago

Thanks for the info. I will leave this open for now to see if more people encounter this problem.

mxa0079 commented 3 weeks ago

I am also running into this issue (or am I missing something?). The workaround did not work for me:

image

or....

image

Dependencies versions:

    "react-hook-form": "^7.52.2",
    "@hookform/resolvers": "^3.9.0",
    "valibot": "^0.37.0",
    "@typeschema/valibot": "^0.13.5",
mxa0079 commented 3 weeks ago

Update, the workaround did work by downgrading to version 0.36:

image

fabian-hiller commented 3 weeks ago

Yes, I think the problem is that some packages may use a different version of Valibot.

mxa0079 commented 3 weeks ago

Some packages as in the hookform resolvers?

fabian-hiller commented 3 weeks ago

Could be. If more people encounter this problem, I will look into it.