paho.mqtt.javascript
paho.mqtt.javascript copied to clipboard
Publish javascript client as npm package
It would be great to be able to use this package via npm, could you please publish the package to npm?
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.
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).
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!)
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.
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 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.
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 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>
Any progress on this? I'd like to use it via npmjs.org instead of copying it to my project.
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' :(
unable to import it
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');