I’ve manage to include kafka-node in my Ionic2 app:
import {Client} from 'kafka-node';
...
export class Service {
public kafkaclient: any;
constructor(){
this.kafkaclient = new Client("localhost:2181","kafka-client-id");
...
However calling new Client(...) causes app.bundle.js to throw an error saying it can’t load module ./lib/BufferMaker
I’ve tried a bunch of things like explicitly listing buffermaker as a dependency in package.json, however nothing seems to work. I’m thinking it has something to do with how Ionic2 uses browserify.
I since found the problem that some node modules were using dynamic requires, which browserify does not detect. When I changed these then it fixed the above problem.
However now I have the problem that net.connect is not available in Ionic, it is rather a node built in of some kind.