Socketcluster.io: Can I require npm core modules? (can I put a square peg in a round hole)

Hi all,
So I am trying to write an add-on to take advantage of a websocket api offered by a site that I love. They use socketcluster.io on server side, so I have no choice but to use that on client side.

I wrote a quick version, that works, by putting the socketcluster-client code into the content script of a panel, but I would like to move the socket connection into addon code so that I can have multiple content pages updated from a central source. To go into a little more detail, I would like to have a button with a panel attached to it, as well as a toolbar, that both get updated with the same information coming from the socket connection.

I created a new project and used NPM to install socketcluster-client and wrote out some test code, but when I try to ‘jpm run’ I get an error:
Module 'url' is not found at resource://gre/modules/commonjs/url.js
After doing a little research it seems like the issue is that jpm is NOT node, and so it doesn’t use the same core modules.

Is there ANY way to get around this issue? It seems like the modules that are missing are: url, util, http, https, crypto, and stream.

If this isn’t possible, could someone please explain why? I am new to jpm and would like to at least know more about it and its limitations.

Thanks!

JPM is mostly a tool for packaging add-ons. The APIs you have available are the ones from the Add-ons SDK. You can include additional libraries, but they are web libraries like jQuery or Bootstrap.

You can use some third party modules - it depends on what those modules use. Here is some documetnation on the subject - [Using third-party modules (jpm)])https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Using_third-party_modules_(jpm))

And here is a custom module a friend of mine made, it uses all the firefox sdk stuff so it works for sure. This is just an example in case you want to try to make a module yourself - but this also exlains on how to require it into your own addon - https://github.com/freaktechnik/jetpack-panelview/blob/master/docs/panelview.md