Running NODE_ENV=production node node_modules/webpack/bin/webpack.js -p --config=webpack.prod.config.js through webpack throws these errors in joi.
ERROR in ./~/joi/lib/string.js
Module not found: Error: Cannot resolve module 'net' in /node_modules/joi/lib
@ ./~/joi/lib/string.js 5:12-26
ERROR in ./~/isemail/lib/index.js
Module not found: Error: Cannot resolve module 'dns' in /node_modules/isemail/lib
@ ./~/isemail/lib/index.js 5:12-26
ERROR in main.entry.js from UglifyJs
Unexpected token: name (Alternatives) [./~/joi/lib/any.js:8,0]
ERROR in main.entry.js from UglifyJs
Unexpected token: name (Alternatives) [./~/joi/lib/any.js:8,0]
Adding:
node: {
net: 'empty',
tls: 'empty',
dns: 'empty'
}
to the webpack config kills off the first two errors, but not the second two and fails to build our client js.
why would you bundle this library with webpack/uglify/etc?
This library is not supposed to be used on browsers
We make auth token requests client side through an api, so we need to parse the token purely on the client..
If you need just to _decode tokens_ in the client-side please use: https://github.com/auth0/jwt-decode
If you need to validate tokens in the client-side you can try: https://github.com/kjur/jsrsasign
This library is not meant to be used in the browser, it was designed to be used in node.js.
@jfromaniello I'm using it server side but I also need it browser side to implement a mock for development purpose.. But I know browser side cryptography is a bad idea..
PS: Related to https://github.com/hapijs/joi/issues/706 and https://github.com/hapijs/joi/issues/528
Is there a fundamental reason that this package isn't intended to be used on the client side, or simply that the current implementation details make it incompatible?
Most helpful comment
If you need just to _decode tokens_ in the client-side please use: https://github.com/auth0/jwt-decode
If you need to validate tokens in the client-side you can try: https://github.com/kjur/jsrsasign
This library is not meant to be used in the browser, it was designed to be used in node.js.