simple-xmpp/node-simple-xmpp

require is not defined

Opened this issue · 0 comments

I'm trying to include node-simple-xmpp in my Electron-React-Webpack-Typescrip app.

In webpack.config.js I've added xmpp:

const xmpp = require("simple-xmpp");

    externals: [
      {
        'utf-8-validate': 'commonjs utf-8-validate',
        bufferutil: 'commonjs bufferutil',
      },
      {
        'xmpp': xmpp,
      }
    ],

But still I get require is not defined when adding these lines in a tsx file:

import xmpp from 'simple-xmpp';

xmpp.connect({
    jid: "",
    password: "",
    host: "",
    port: 5280
});
  • Electron: ^13.1.4
  • webpack: ^5.23.0
  • react: ^17.0.2
  • node: v14.17.0

How to resolve the problem?