From fb510879a7cbe1a1f9dee106717a925cc38495d0 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Tue, 23 Jun 2026 14:57:18 +0100 Subject: [PATCH] perf: remove string-width We can use fast-string-width instead which is much faster and smaller, already in wide use too. --- package-lock.json | 49 +++++++++++++------------------- packages/build/package.json | 2 +- packages/build/src/log/header.ts | 2 +- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9facd1e11c..b40012366b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11063,10 +11063,6 @@ "url": "https://github.com/sindresorhus/emittery?sponsor=1" } }, - "node_modules/emoji-regex": { - "version": "10.6.0", - "license": "MIT" - }, "node_modules/empathic": { "version": "2.0.1", "license": "MIT", @@ -12360,6 +12356,21 @@ "version": "2.1.1", "license": "MIT" }, + "node_modules/fast-string-truncated-width": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz", + "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==", + "license": "MIT" + }, + "node_modules/fast-string-width": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fast-string-width/-/fast-string-width-3.0.2.tgz", + "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==", + "license": "MIT", + "dependencies": { + "fast-string-truncated-width": "^3.0.2" + } + }, "node_modules/fast-stringify": { "version": "4.0.0", "license": "MIT" @@ -12753,6 +12764,9 @@ }, "node_modules/fsevents": { "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, "license": "MIT", "optional": true, "os": [ @@ -12833,16 +12847,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-east-asian-width": { - "version": "1.6.0", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/get-intrinsic": { "version": "1.3.0", "license": "MIT", @@ -20183,21 +20187,6 @@ "safe-buffer": "~5.2.0" } }, - "node_modules/string-width": { - "version": "7.2.0", - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/string-width-cjs": { "name": "string-width", "version": "4.2.3", @@ -22962,6 +22951,7 @@ "ansis": "^4.1.0", "clean-stack": "^5.0.0", "execa": "^8.0.0", + "fast-string-width": "^3.0.2", "fdir": "^6.0.1", "figures": "^6.0.0", "filter-obj": "^6.0.0", @@ -22989,7 +22979,6 @@ "rfdc": "^1.3.0", "safe-json-stringify": "^1.2.0", "semver": "^7.3.8", - "string-width": "^7.0.0", "supports-color": "^10.0.0", "terminal-link": "^4.0.0", "ts-node": "^10.9.1", diff --git a/packages/build/package.json b/packages/build/package.json index 0c14b26cfe..e057c33736 100644 --- a/packages/build/package.json +++ b/packages/build/package.json @@ -82,6 +82,7 @@ "ansis": "^4.1.0", "clean-stack": "^5.0.0", "execa": "^8.0.0", + "fast-string-width": "^3.0.2", "fdir": "^6.0.1", "figures": "^6.0.0", "filter-obj": "^6.0.0", @@ -109,7 +110,6 @@ "rfdc": "^1.3.0", "safe-json-stringify": "^1.2.0", "semver": "^7.3.8", - "string-width": "^7.0.0", "supports-color": "^10.0.0", "terminal-link": "^4.0.0", "ts-node": "^10.9.1", diff --git a/packages/build/src/log/header.ts b/packages/build/src/log/header.ts index 93dd8186a1..0999fd9ccb 100644 --- a/packages/build/src/log/header.ts +++ b/packages/build/src/log/header.ts @@ -1,4 +1,4 @@ -import stringWidth from 'string-width' +import stringWidth from 'fast-string-width' const HEADER_MIN_WIDTH = 60 const PADDING_WIDTH = 2