Home

Issue: 984

trying to require 'ws' only on server side code

[issue link]

Hello
I’m failing in require only WebSocket for server side code:

plugin/apolloClient.js
  if (process.SERVER_BUILD) {
    const ws = require('ws')
    wsClient = new SubscriptionClient(wsUri, {
      reconnect: true
    }, ws)
  } else {
    wsClient = new SubscriptionClient(wsUri, {
      reconnect: true
    })
  }

nuxt.config.js
extend (config, {dev, isServer}) {
      if (!isServer) {
        config.node = {
          fs: 'empty',
          tls: 'empty'
        }
      }
    },

I receive following error warning / client and server side:

 WARNING  Compiled with 2 warnings                                                                                                                                                                  10:06:46

 warning  in ./~/bindings/bindings.js

76:22-40 Critical dependency: the request of a dependency is an expression

 warning  in ./~/bindings/bindings.js

76:43-53 Critical dependency: the request of a dependency is an expression
This bug report is available on Nuxt.js community (#c851)