Skip to content

Commit 71d6048

Browse files
feat: add bundle with msgpack parser
Pros: - events with binary content are sent as 1 WebSocket frame (instead of 2 with the default parser) - payloads with lots of numbers should be smaller Cons: - no IE9 support (https://caniuse.com/mdn-javascript_builtins_arraybuffer) - a slightly bigger bundle size (61.1 vs 59.9 KB) Source: https://github.com/darrachequesne/socket.io-msgpack-parser
1 parent f3cbe98 commit 71d6048

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"prettier": "^2.1.2",
5757
"socket.io": "3.0.0-rc2",
5858
"socket.io-browsers": "^1.0.0",
59+
"socket.io-msgpack-parser": "^3.0.0",
5960
"text-blob-builder": "0.0.1",
6061
"ts-loader": "^8.0.5",
6162
"ts-node": "^9.0.0",
@@ -72,7 +73,7 @@
7273
"test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
7374
"test:node": "mocha --require ts-node/register --reporter dot --require test/support/server.js test/index.js",
7475
"test:browser": "zuul test/index.js",
75-
"build": "npm run compile && webpack --config ./support/webpack.config.js --config ./support/prod.config.js",
76+
"build": "npm run compile && webpack --config ./support/webpack.config.js --config ./support/prod.config.js --config ./support/msgpack-parser.config.js",
7677
"format:check": "prettier --check 'lib/**/*.ts' 'test/**/*.js' 'test/**/*.ts' 'support/**/*.js'",
7778
"format:fix": "prettier --write 'lib/**/*.ts' 'test/**/*.js' 'test/**/*.ts' 'support/**/*.js'",
7879
"prepack": "npm run compile"

support/msgpack-parser.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { NormalModuleReplacementPlugin } = require("webpack");
2+
const config = require("./prod.config");
3+
4+
module.exports = {
5+
...config,
6+
output: {
7+
...config.output,
8+
filename: "socket.io.msgpack.min.js",
9+
},
10+
plugins: [
11+
...config.plugins,
12+
new NormalModuleReplacementPlugin(
13+
/^socket.io-parser$/,
14+
"socket.io-msgpack-parser"
15+
),
16+
],
17+
};

0 commit comments

Comments
 (0)