Skip to content

Commit

Permalink
feat: add bundle with msgpack parser
Browse files Browse the repository at this point in the history
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
  • Loading branch information
darrachequesne committed Oct 25, 2020
1 parent f3cbe98 commit 71d6048
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"prettier": "^2.1.2",
"socket.io": "3.0.0-rc2",
"socket.io-browsers": "^1.0.0",
"socket.io-msgpack-parser": "^3.0.0",
"text-blob-builder": "0.0.1",
"ts-loader": "^8.0.5",
"ts-node": "^9.0.0",
Expand All @@ -72,7 +73,7 @@
"test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
"test:node": "mocha --require ts-node/register --reporter dot --require test/support/server.js test/index.js",
"test:browser": "zuul test/index.js",
"build": "npm run compile && webpack --config ./support/webpack.config.js --config ./support/prod.config.js",
"build": "npm run compile && webpack --config ./support/webpack.config.js --config ./support/prod.config.js --config ./support/msgpack-parser.config.js",
"format:check": "prettier --check 'lib/**/*.ts' 'test/**/*.js' 'test/**/*.ts' 'support/**/*.js'",
"format:fix": "prettier --write 'lib/**/*.ts' 'test/**/*.js' 'test/**/*.ts' 'support/**/*.js'",
"prepack": "npm run compile"
Expand Down
17 changes: 17 additions & 0 deletions support/msgpack-parser.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { NormalModuleReplacementPlugin } = require("webpack");
const config = require("./prod.config");

module.exports = {
...config,
output: {
...config.output,
filename: "socket.io.msgpack.min.js",
},
plugins: [
...config.plugins,
new NormalModuleReplacementPlugin(
/^socket.io-parser$/,
"socket.io-msgpack-parser"
),
],
};

0 comments on commit 71d6048

Please sign in to comment.