paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

Publish javascript client as npm package

Open Kresshy opened this issue 9 years ago • 12 comments
trafficstars

It would be great to be able to use this package via npm, could you please publish the package to npm?

Kresshy avatar Apr 19 '16 09:04 Kresshy

This sounds like a good idea, We're coming up to our Neon release very soon, so I'll try and get it in npm for that.

jpwsutton avatar May 03 '16 09:05 jpwsutton

Hi, any progress on this?

I've been using MQTT.js in the browser until I can get mqttws31.js from npm. (the browserify step for that other library is the longest part of my build process ).

If I could include this library instead it'd be much more convenient.

There are unofficial uploads of this library popping up in npm to address the gap, but obviously there wouldn't be any ongoing updates if I were to include one of those. An official npm release would also pave the way to better bindings into Typescript (which is my use case).

sjmf avatar Aug 14 '16 17:08 sjmf

Hi @sjmf, I'm planning on pushing this library to npmjs once I'm back from my Holidays so that I can fully test it. It will be after the 29th of August though unless another Eclipse Committer can do the job before I'm back. (こんにちは from Japan!)

jpwsutton avatar Aug 15 '16 04:08 jpwsutton

I've published this library onto npm as paho-mqtt which is one of the standards we've been using lately for this library: https://www.npmjs.com/package/paho-mqtt

At the moment, mqttws31.js and mqttws31-min.js are at the top level without any code changes, so still can't be used with node.js. I'll leave this issue open for now in case anybody has any problems with the way it's been published.

jpwsutton avatar Aug 30 '16 13:08 jpwsutton

I have installed the liabrary with npm install paho-mqtt --save How can I now import it?

I tired

import mqtt from 'paho-mqtt'
import * as mqtt from 'paho-mqtt'

but it does not seem to work?

maecky avatar Apr 02 '17 22:04 maecky

@maecky While I am currently not using the NPM version, I have integrated Paho MQTT in an ES6 project

It reuired two fixes to the code published. One is trouble with strict mode of ES6 that requires a var statement to be added (I could track it down for you) and the other is this line missing at the bottom:

export default Paho.MQTT

Check if that line is there. If it is missing then import is not going to work properly anyway. Since it doesn't know what to bind to the local file scope.

Can you check if that statement is there.

TichShowers avatar Apr 20 '17 08:04 TichShowers

Hi @maecky and @TichShowers , I'm desperately trying to use Paho.MQTT in a very basic React app, but I can't get it to work. (I'm pretty sure this isn't the right place to ask, but I don't know where to ask instead...) Do you know of any minimal code to correctly load/import Paho.MQTT and define the main Paho.MQTT object in a basic React app (e.g. the boilerplate given by create-react-app)? Whatever I try I'm always getting various compiler errors. (I'm using an npm-based dev setup)

I tried replacing node_modules/paho-mqtt/mqttws31.js by the current paho-mqtt.js from the develop branch, to no avail.

gschintgen avatar May 12 '17 19:05 gschintgen

@gschintgen have you tried @TichShowers approach? I haven't had any time yet to try it and ended up including the Paho library in my index.html file: <script src="lib/mqttws31-min.js" type="text/javascript"></script>

maecky avatar May 13 '17 20:05 maecky

Any progress on this? I'd like to use it via npmjs.org instead of copying it to my project.

gfx avatar Jan 14 '19 07:01 gfx

It is basic requirement I think for every node project... I just rewrote our lib to give Paho a frist try, to see if it would work for us. Without even thinking I could stumble upon not being able to import { Paho } from 'Paho' :(

tvld avatar Mar 06 '19 10:03 tvld

unable to import it

abhayfrontend avatar Jan 10 '20 12:01 abhayfrontend

If it'll help anyone I have this running in a React app bundled with Webpack.

I had to add this to my webpack config

  resolve: {
    alias: {
      'paho-mqtt': path.resolve(
        __dirname,
        'node_modules/paho-mqtt/src/paho-mqtt.js'
      ),
    },
  },

Which enables me to import it with

import Paho from 'paho-mqtt';

// Not tested but it'd probably work with commonjs too
const Pah = require('paho-mqtt');

benswinburne avatar May 17 '20 16:05 benswinburne