diff --git a/Makefile b/Makefile index 9cdb14dd..89a77289 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ restart: ./server/ctl.js restart bundlesize: - npx bundlesize + node test/bundlesize.js bundle: npx rollup -c rollup.config.js diff --git a/e2e.config.cjs b/e2e.config.cjs index 71764ac7..1fd95065 100644 --- a/e2e.config.cjs +++ b/e2e.config.cjs @@ -2,6 +2,6 @@ /** @type {import('jest').Config} */ module.exports = { - testMatch: ["<rootDir>/test/*.js"], + testMatch: ["<rootDir>/test/*.test.js"], setupFilesAfterEnv: ["jest-extended/all"], }; diff --git a/package-lock.json b/package-lock.json index 13d18a4d..4e3951cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@rollup/plugin-terser": "^0.4.4", "babel-jest": "^29.7.0", "babel-plugin-jsx-pragmatic": "^1.0.2", - "bundlesize": "^0.18.2", + "bytes": "^3.1.2", "eslint": "^9.17.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jest": "^28.10.0", @@ -4498,15 +4498,6 @@ "dev": true, "license": "ISC" }, - "node_modules/are-we-there-yet": { - "version": "1.1.7", - "dev": true, - "license": "ISC", - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, "node_modules/argparse": { "version": "1.0.10", "dev": true, @@ -4842,18 +4833,6 @@ "node": ">=8" } }, - "node_modules/brotli-size": { - "version": "0.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "duplexer": "^0.1.1", - "iltorb": "^2.4.3" - }, - "engines": { - "node": ">=0.12.0" - } - }, "node_modules/browserslist": { "version": "4.24.2", "dev": true, @@ -4909,28 +4888,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/bundlesize": { - "version": "0.18.2", - "dev": true, - "license": "MIT", - "dependencies": { - "axios": "^1.6.2", - "brotli-size": "0.1.0", - "bytes": "^3.1.0", - "ci-env": "^1.4.0", - "commander": "^2.20.0", - "cosmiconfig": "^5.2.1", - "github-build": "^1.2.4", - "glob": "^7.1.4", - "gzip-size": "^4.0.0", - "prettycli": "^1.4.3" - }, - "bin": { - "bundlesize": "index.js", - "bundlesize-init": "src/init-status.js", - "bundlesize-pipe": "pipe.js" - } - }, "node_modules/byte-size": { "version": "8.1.1", "dev": true, @@ -4941,6 +4898,8 @@ }, "node_modules/bytes": { "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "dev": true, "license": "MIT", "engines": { @@ -5015,36 +4974,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/caller-callsite": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "callsites": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/caller-callsite/node_modules/callsites": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/caller-path": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "caller-callsite": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/callsites": { "version": "3.1.0", "dev": true, @@ -5146,11 +5075,6 @@ "node": ">=10" } }, - "node_modules/ci-env": { - "version": "1.17.0", - "dev": true, - "license": "MIT" - }, "node_modules/ci-info": { "version": "3.9.0", "dev": true, @@ -5355,14 +5279,6 @@ "node": ">= 0.12.0" } }, - "node_modules/code-point-at": { - "version": "1.1.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/collect-v8-coverage": { "version": "1.0.2", "dev": true, @@ -5797,20 +5713,6 @@ "dev": true, "license": "MIT" }, - "node_modules/cosmiconfig": { - "version": "5.2.1", - "dev": true, - "license": "MIT", - "dependencies": { - "import-fresh": "^2.0.0", - "is-directory": "^0.3.1", - "js-yaml": "^3.13.1", - "parse-json": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/create-hash": { "version": "1.2.0", "license": "MIT", @@ -5969,25 +5871,6 @@ "dev": true, "license": "MIT" }, - "node_modules/decompress-response": { - "version": "4.2.1", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-response": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/deep-extend": { - "version": "0.6.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/deep-is": { "version": "0.1.4", "dev": true, @@ -6025,11 +5908,6 @@ "node": ">=0.4.0" } }, - "node_modules/delegates": { - "version": "1.0.0", - "dev": true, - "license": "MIT" - }, "node_modules/deprecation": { "version": "2.3.1", "dev": true, @@ -6043,17 +5921,6 @@ "node": ">=4" } }, - "node_modules/detect-libc": { - "version": "1.0.3", - "dev": true, - "license": "Apache-2.0", - "bin": { - "detect-libc": "bin/detect-libc.js" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/detect-newline": { "version": "3.1.0", "dev": true, @@ -6857,14 +6724,6 @@ "node": ">= 0.8.0" } }, - "node_modules/expand-template": { - "version": "2.0.3", - "dev": true, - "license": "(MIT OR WTFPL)", - "engines": { - "node": ">=6" - } - }, "node_modules/expect": { "version": "29.7.0", "dev": true, @@ -7184,69 +7043,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/gauge": { - "version": "2.7.4", - "dev": true, - "license": "ISC", - "dependencies": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "node_modules/gauge/node_modules/ansi-regex": { - "version": "2.1.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gauge/node_modules/aproba": { - "version": "1.2.0", - "dev": true, - "license": "ISC" - }, - "node_modules/gauge/node_modules/is-fullwidth-code-point": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "number-is-nan": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gauge/node_modules/string-width": { - "version": "1.0.2", - "dev": true, - "license": "MIT", - "dependencies": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gauge/node_modules/strip-ansi": { - "version": "3.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/gensync": { "version": "1.0.0-beta.2", "dev": true, @@ -7430,29 +7226,6 @@ "ini": "^1.3.2" } }, - "node_modules/github-build": { - "version": "1.2.4", - "dev": true, - "license": "MIT", - "dependencies": { - "axios": "1.6.0" - } - }, - "node_modules/github-build/node_modules/axios": { - "version": "1.6.0", - "dev": true, - "license": "MIT", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/github-from-package": { - "version": "0.0.0", - "dev": true, - "license": "MIT" - }, "node_modules/glob": { "version": "7.2.3", "dev": true, @@ -7518,18 +7291,6 @@ "dev": true, "license": "ISC" }, - "node_modules/gzip-size": { - "version": "4.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "duplexer": "^0.1.1", - "pify": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/handlebars": { "version": "4.7.8", "dev": true, @@ -7768,39 +7529,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/iltorb": { - "version": "2.4.5", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "detect-libc": "^1.0.3", - "nan": "^2.14.0", - "npmlog": "^4.1.2", - "prebuild-install": "^5.3.3", - "which-pm-runs": "^1.0.0" - } - }, - "node_modules/import-fresh": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "caller-path": "^2.0.0", - "resolve-from": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/import-fresh/node_modules/resolve-from": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/import-local": { "version": "3.1.0", "dev": true, @@ -8013,14 +7741,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-directory": { - "version": "0.3.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-docker": { "version": "2.2.1", "dev": true, @@ -10501,17 +10221,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mimic-response": { - "version": "2.1.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/min-indent": { "version": "1.0.1", "dev": true, @@ -10695,11 +10404,6 @@ "node": ">=10" } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "dev": true, - "license": "MIT" - }, "node_modules/modify-values": { "version": "1.0.1", "dev": true, @@ -10736,16 +10440,6 @@ "dev": true, "license": "ISC" }, - "node_modules/nan": { - "version": "2.22.0", - "dev": true, - "license": "MIT" - }, - "node_modules/napi-build-utils": { - "version": "1.0.2", - "dev": true, - "license": "MIT" - }, "node_modules/natural-compare": { "version": "1.4.0", "dev": true, @@ -10764,22 +10458,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-abi": { - "version": "2.30.1", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^5.4.1" - } - }, - "node_modules/node-abi/node_modules/semver": { - "version": "5.7.2", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver" - } - }, "node_modules/node-fetch": { "version": "2.7.0", "dev": true, @@ -10938,11 +10616,6 @@ "dev": true, "license": "MIT" }, - "node_modules/noop-logger": { - "version": "0.1.1", - "dev": true, - "license": "MIT" - }, "node_modules/nopt": { "version": "7.2.1", "dev": true, @@ -11120,25 +10793,6 @@ "node": ">=8" } }, - "node_modules/npmlog": { - "version": "4.1.2", - "dev": true, - "license": "ISC", - "dependencies": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "node_modules/number-is-nan": { - "version": "1.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/nwsapi": { "version": "2.2.16", "dev": true, @@ -11313,14 +10967,6 @@ "node": ">=12" } }, - "node_modules/object-assign": { - "version": "4.1.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/once": { "version": "1.4.0", "dev": true, @@ -11795,34 +11441,6 @@ "node": ">=4" } }, - "node_modules/prebuild-install": { - "version": "5.3.6", - "dev": true, - "license": "MIT", - "dependencies": { - "detect-libc": "^1.0.3", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^1.0.1", - "node-abi": "^2.7.0", - "noop-logger": "^0.1.1", - "npmlog": "^4.0.1", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^3.0.3", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0", - "which-pm-runs": "^1.0.0" - }, - "bin": { - "prebuild-install": "bin.js" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "dev": true, @@ -11858,78 +11476,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/prettycli": { - "version": "1.4.3", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "2.1.0" - } - }, - "node_modules/prettycli/node_modules/ansi-styles": { - "version": "3.2.1", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/prettycli/node_modules/chalk": { - "version": "2.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^3.1.0", - "escape-string-regexp": "^1.0.5", - "supports-color": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/prettycli/node_modules/color-convert": { - "version": "1.9.3", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/prettycli/node_modules/color-name": { - "version": "1.1.3", - "dev": true, - "license": "MIT" - }, - "node_modules/prettycli/node_modules/escape-string-regexp": { - "version": "1.0.5", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/prettycli/node_modules/has-flag": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/prettycli/node_modules/supports-color": { - "version": "4.5.0", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/proc-log": { "version": "4.2.0", "dev": true, @@ -12017,15 +11563,6 @@ "dev": true, "license": "MIT" }, - "node_modules/pump": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, "node_modules/pure-rand": { "version": "6.1.0", "dev": true, @@ -12075,28 +11612,6 @@ "safe-buffer": "^5.1.0" } }, - "node_modules/rc": { - "version": "1.2.8", - "dev": true, - "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, - "node_modules/rc/node_modules/strip-json-comments": { - "version": "2.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/react-is": { "version": "18.3.1", "dev": true, @@ -12770,35 +12285,6 @@ "node": "^16.14.0 || >=18.0.0" } }, - "node_modules/simple-concat": { - "version": "1.0.1", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/simple-get": { - "version": "3.1.1", - "dev": true, - "license": "MIT", - "dependencies": { - "decompress-response": "^4.2.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "node_modules/sisteransi": { "version": "1.0.5", "dev": true, @@ -13199,22 +12685,6 @@ "node": ">=10" } }, - "node_modules/tar-fs": { - "version": "2.1.1", - "dev": true, - "license": "MIT", - "dependencies": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "node_modules/tar-fs/node_modules/chownr": { - "version": "1.1.4", - "dev": true, - "license": "ISC" - }, "node_modules/tar-stream": { "version": "2.2.0", "dev": true, @@ -13461,17 +12931,6 @@ "node": "^16.14.0 || >=18.0.0" } }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/type-check": { "version": "0.4.0", "dev": true, @@ -13808,14 +13267,6 @@ "node": ">= 8" } }, - "node_modules/which-pm-runs": { - "version": "1.1.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/wide-align": { "version": "1.1.5", "dev": true, diff --git a/package.json b/package.json index fdd16165..524a8ccb 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "@rollup/plugin-terser": "^0.4.4", "babel-jest": "^29.7.0", "babel-plugin-jsx-pragmatic": "^1.0.2", - "bundlesize": "^0.18.2", + "bytes": "^3.1.2", "eslint": "^9.17.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jest": "^28.10.0", @@ -45,12 +45,6 @@ "workspaces": [ "packages/*" ], - "bundlesize": [ - { - "path": "./packages/client/dist/xmpp.min.js", - "maxSize": "15 KB" - } - ], "lint-staged": { "*.{js,cjs,mjs}": "eslint --cache --fix", "*.{json,md,html,css,yaml,yml}": "prettier --write" diff --git a/test/browser.js b/test/browser.test.js similarity index 100% rename from test/browser.js rename to test/browser.test.js diff --git a/test/bundlesize.js b/test/bundlesize.js new file mode 100644 index 00000000..39b952e2 --- /dev/null +++ b/test/bundlesize.js @@ -0,0 +1,31 @@ +/* eslint-disable unicorn/no-process-exit */ +/* eslint-disable n/no-process-exit */ + +import zlib from "node:zlib"; +import { readFile } from "node:fs/promises"; +import bytes from "bytes"; + +import { promisify } from "node:util"; + +const brotliCompress = promisify(zlib.brotliCompress); + +const path = "packages/client/dist/xmpp.min.js"; +const buffer = await readFile(path); +const compressed = await brotliCompress(buffer); + +const max_size = "15 KB"; + +console.log(`${path}:`); +if (compressed.length > bytes(max_size)) { + console.log( + "\u001B[31m%s\u001B[0m", + `${bytes(compressed.length)} > ${max_size} ❌`, + ); + process.exit(1); +} else { + console.log( + "\u001B[32m%s\u001B[0m", + `${bytes(compressed.length)} < ${max_size} ✅`, + ); + process.exit(0); +} diff --git a/test/client.js b/test/client.test.js similarity index 100% rename from test/client.js rename to test/client.test.js diff --git a/test/component.js b/test/component.test.js similarity index 100% rename from test/component.js rename to test/component.test.js diff --git a/test/sasl.js b/test/sasl.test.js similarity index 100% rename from test/sasl.js rename to test/sasl.test.js diff --git a/test/see-other-host.js b/test/see-other-host.test.js similarity index 100% rename from test/see-other-host.js rename to test/see-other-host.test.js