Skip to content

Commit

Permalink
Fix #4 websocket-nats can't publish binary message (Uint8Array)
Browse files Browse the repository at this point in the history
Clean up package.json and webpack.config.js
Add sourcemap support to webpack.config.js
  • Loading branch information
isobit committed Nov 18, 2016
1 parent bf207d3 commit 5be066b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
11 changes: 6 additions & 5 deletions dist/bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/bundle.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions lib/nats.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,10 @@ Client.prototype.publish = function(subject, msg, opt_reply, opt_callback) {
psub = 'PUB ' + subject + SPC + opt_reply + SPC;
}

if ('ArrayBuffer' in window && ArrayBuffer.isView(msg)) {
msg = Buffer.from(msg);
}

// Need to treat sending buffers different.
if (!Buffer.isBuffer(msg)) {
var str = msg;
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "websocket-nats",
"version": "0.2.4",
"version": "0.2.5",
"description": "An in-browser websocket client for [NATS](http://nats.io/), a lightweight, high-performance cloud native messaging system.",
"keywords": [
"websocket",
Expand Down Expand Up @@ -28,8 +28,5 @@
},
"devDependencies": {
"webpack": "^1.13.0"
},
"dependencies": {
"url": "^0.11.0"
}
}
15 changes: 10 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
var webpack = require('webpack');
const path = require('path');
const webpack = require('webpack');

module.exports = {
entry: './bootstrap.js',
output: {
path: './dist',
filename: 'bundle.js',
}
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'bundle.js'
},
devtool: '#eval-source-map'
};

if (process.env.NODE_ENV === 'prod') {
module.exports.devtool = '#source-map';
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.optimize.UglifyJsPlugin({minimize: true})
new webpack.optimize.UglifyJsPlugin({minimize: true})
]);
}

0 comments on commit 5be066b

Please sign in to comment.