mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
493 stars 76 forks source link

Use msgpack5 in the browser #26

Closed drawmindmap closed 9 years ago

drawmindmap commented 9 years ago

I get this error when i use msgpack5 in the browser: msgpack5_bundle.js:3015 Uncaught TypeError: this.once is not a function

<!DOCTYPE html>
<head>
  <meta charset="UTF-8">
  <title>Test msgpack5</title>
  <script src="msgpack5_bundle.js"></script>
  <script>
function init() {
  msgpack = msgpack5();
  console.log(msgpack.decode(msgpack.encode('Test')));
}
  </script>
</head>
<body onload="init()">
</body>
</html>
mcollina commented 9 years ago

How did you do your bundle?

Probably it's missing a require('stream') at the very beginning. Il giorno mer 24 giu 2015 alle 03:21 drawmindmap notifications@github.com ha scritto:

I get this error when i use msgpack5 in the browser: msgpack5_bundle.js:3015 Uncaught TypeError: this.once is not a function

<!DOCTYPE html>

Test msgpack5

— Reply to this email directly or view it on GitHub https://github.com/mcollina/msgpack5/issues/26.

drawmindmap commented 9 years ago

From https://github.com/mcollina/msgpack5/blob/master/dist/msgpack5_bundle.js Run 'npm run browserify', it ok now using dist/msgpack5.js

ibeeger commented 9 years ago

create a test.js code

global.msg =require("msgpack5")();

browserify test.js -s msgpack -o client.js

mcollina commented 9 years ago

I have updated the bundles, please check again.

ibeeger commented 9 years ago

thank you