joi icon indicating copy to clipboard operation
joi copied to clipboard

Is JOI usable in browser?

Open DaveStein opened this issue 1 year ago • 4 comments

Support plan

  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: N/A
  • module version: 17.7.0
  • environment (e.g. node, browser, native): browser (just TSC compilation)
  • used with (e.g. hapi application, another framework, standalone, ...): in an Open WC generator project
  • any other relevant information:

How can we help?

I have used JOI previously on my Node apps. I am now doing something client side, although I will hit server endpoints. I want to share the validation across both. I do import Joi from 'joi'; after turning on esModuleInterop in TS config, as it told me. In the browser I get this error:

The requested module './../../../node_modules/joi/lib/index.js' does not provide an export named 'default'

I saw elsewhere that this is supposed to work in React create app, but that uses Webpack. Is that a requirement of using this package in browser??

DaveStein avatar Jan 31 '23 03:01 DaveStein