simple-xmpp / node-simple-xmpp

Simple High Level NodeJS XMPP Client
302 stars 90 forks source link

require is not defined #96

Open raphael10-collab opened 3 years ago

raphael10-collab commented 3 years ago

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
});

How to resolve the problem?