I have added a require statement to require the ws library inside an if statement so that it will be imported only if its not the browser. For example, require ws only for the tests.
if (!process.browser) {
webSocketLinkConfig.webSocketImpl = require('ws');
}
But the problem is, even though the rest of the assignment webSocketLinkConfig.webSocketImpl doesn't happen, the require gets executed and I get a warning in the browser saying Module not found: Can't resolve 'bufferutil' in '/Users/pubudu/Projects/FleetManager/fm-dash-front/node_modules/ws/lib'
Any idea what's happening and how to fix it?
This is a react app built with create-react-app.