diff --git a/.size-limit.cjs b/.size-limit.cjs new file mode 100644 index 0000000000..8b6dd5d1c1 --- /dev/null +++ b/.size-limit.cjs @@ -0,0 +1,52 @@ +const modifyWebpackConfig = (webpackConfig) => { + if (!webpackConfig.resolve) webpackConfig.resolve = {}; + if (!webpackConfig.resolve.fallback) webpackConfig.resolve.fallback = {}; + // Can be removed once https://github.com/libp2p/js-libp2p-pubsub/pull/92 is merged and released + webpackConfig.resolve.fallback.buffer = false; + return webpackConfig; +}; + +module.exports = [ + { + name: "Waku core", + path: "dist/bundle.min.js", + import: "{ Waku }", + modifyWebpackConfig, + }, + { + name: "Waku default setup", + path: "dist/bundle.min.js", + import: "{ createWaku, waitForRemotePeer }", + modifyWebpackConfig, + }, + { + name: "Asymmetric, symmetric encryption and signature", + path: "dist/bundle.min.js", + import: "{ waku_message }", + modifyWebpackConfig, + }, + { + name: "DNS discovery", + path: "dist/bundle.min.js", + import: "{ discovery }", + modifyWebpackConfig, + }, + { + name: "Privacy preserving protocols", + path: "dist/bundle.min.js", + import: "{ WakuRelay }", + modifyWebpackConfig, + }, + { + name: "Light protocols", + path: "dist/bundle.min.js", + import: "{ WakuLightPush, WakuFilter }", + modifyWebpackConfig, + }, + { + name: "History retrieval protocols", + path: "dist/bundle.min.js", + import: "{ WakuStore }", + modifyWebpackConfig, + }, +]; diff --git a/CHANGELOG.md b/CHANGELOG.md index 69eb8c602b..62590a4434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fix - size-limit config to test several usages of Waku. +- `buffer` is not needed in the browser. ## [0.24.0] - 2022-05-27 diff --git a/package.json b/package.json index 7e862449eb..57b0ad0447 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "reset-hard": "git clean -dfx && git reset --hard && npm i && npm run build && for d in examples/*/; do (cd $d; npm i); done" }, "browser": { + "buffer": false, "crypto": false }, "engines": { @@ -163,43 +164,6 @@ "**/*.spec.js" ] }, - "size-limit": [ - { - "name": "Waku core", - "path": "dist/bundle.min.js", - "import": "{ Waku }" - }, - { - "name": "Waku default setup", - "path": "dist/bundle.min.js", - "import": "{ createWaku, waitForRemotePeer }" - }, - { - "name": "Asymmetric, symmetric encryption and signature", - "path": "dist/bundle.min.js", - "import": "{ waku_message }" - }, - { - "name": "DNS discovery", - "path": "dist/bundle.min.js", - "import": "{ discovery }" - }, - { - "name": "Privacy preserving protocols", - "path": "dist/bundle.min.js", - "import": "{ WakuRelay }" - }, - { - "name": "Light protocols", - "path": "dist/bundle.min.js", - "import": "{ WakuLightPush, WakuFilter }" - }, - { - "name": "History retrieval protocols", - "path": "dist/bundle.min.js", - "import": "{ WakuStore }" - } - ], "lint-staged": { "*.ts": [ "eslint --fix"