fabian-hiller / valibot

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

Can't run test code using 0.31.0-rc #596

Closed chimame closed 1 month ago

chimame commented 1 month ago

When I install the 0.31.0-rc version and try to run the test code using Vitest, I get the error

 SyntaxError: Invalid regular expression flags

image

I've created a minimal sample code that will cause this to happen here. The sample code simply outputs the valibot API string to the log. Of course, there is no error when using 0.30.0. Is there anything special I need to do from 0.31.0 onwards?

import { describe, it, expect } from 'vitest'
import { string } from 'valibot'

describe('sample', () => {
  it('should pass', () => {
    console.log(string) // <-- After deleting it, the test can be executed normally.
    expect(1 + 1).toBe(2)
  })
})
fabian-hiller commented 1 month ago

I know what the problem is. What JavaScript runtime and version are you using? If you are using Node.js, try running your code with >=v20.

chimame commented 1 month ago

Thank you for your quick response!

My Node.js version was 18.18.2. I changed it to 20.13.1 and the test ran normally. Does 0.31.0 support Node.js versions 20 or higher?

fabian-hiller commented 1 month ago

I have started to use an advanced regex feature to improve and simplify the emoji regex. Unfortunately, this is not supported in Node.js v18 or older.

chimame commented 1 month ago

Thanks for your answer! I'll keep in mind that supported versions of Node.js change.

fabian-hiller commented 1 month ago

If there are people who can't upgrade, I will reconsider this change and reschedule it for a later date. On the other hand, as far as I know, upgrading from v18 to v20 shouldn't cause any problems.

fabian-hiller commented 1 month ago

This is fixed in v0.31.0-rc.4