-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: none (this is relative to usage in the browser)
- joi version: 16
- environment (node, browser): browser
- used with (hapi, standalone, ...): standalone
What are you trying to achieve or the steps to reproduce ?
I want to simply load joi to use it in the browser (chrome). I created a client-side build using the webpack configuration provided in the "browser" directory.
When loading the build produced by webpack, an error in thrown:
Uncaught TypeError: Trace.setup is not a function
at Object.internals.root (index.js:84)
at eval (index.js:245)
at Object.../lib/index.js (joi-browser.min.js:179)
at __webpack_require__ (joi-browser.min.js:30)
at joi-browser.min.js:94
at joi-browser.min.js:97
at webpackUniversalModuleDefinition (joi-browser.min.js:9)
at joi-browser.min.js:10This happens because webpack will always return plain js object here (lib/index.js):
const Trace = require('./trace');Note: the "null-loader" is being used with lib/trace.js, but the effect is that it will erase all the code when creating the output. So we end up with a plain object when we require('./trace') (but still, a truthy value)
What did you expect ?
The browser build should load without any errors.
Fixed in pr #2082
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect