getStats icon indicating copy to clipboard operation
getStats copied to clipboard

Don't put stuff on the `window` when module.exports is available

Open feross opened this issue 9 years ago • 3 comments

Polluting the window object with the getStats method shouldn't be necessary when module.exports is available. Instead just export the function. This will help users who bundle their javascript with tools like browserify: http://browserify.org/, or people using webrtc in node.js via wrtc.

feross avatar Apr 27 '15 21:04 feross

+1. Also, adding support for AMD-loaders like RequireJS would be great.

kashifshamaz21 avatar May 08 '15 00:05 kashifshamaz21

Yeah. Have a look at https://github.com/umdjs/umd for snippets to use.

Or, just write your code in CommonJS (node.js) style and build with browserify -s getStats -r ./. This is how simple-peer does it, for instance: https://github.com/feross/simple-peer/blob/master/package.json#L62

feross avatar May 08 '15 00:05 feross

I'm wondering what happened to this issue? It looks like it was added but then removed. Was there a reason for that? Would you be open to pull requests for this feature?

sanbornhilland avatar Sep 20 '17 19:09 sanbornhilland