diff --git a/README.md b/README.md index cc7622a7..e3b77c68 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ interactive elements, using React/Vue/Svelte lib or vanilla JS. ```sh $ npm run size - Package size: 30.08 KB with all dependencies, minified and gzipped + Package size: 30.08 kB with all dependencies, minified and gzipped ``` 4. Now, let’s set the limit. Add 25% to the current total time and use that as @@ -134,7 +134,7 @@ interactive elements, using React/Vue/Svelte lib or vanilla JS. ```diff "size-limit": [ { - + "limit": "35 KB", + + "limit": "35 kB", "path": "dist/app-*.js" } ], @@ -159,10 +159,10 @@ interactive elements, using React/Vue/Svelte lib or vanilla JS. ### JS Application and Time-based Limit -File size limit (in KB) is not the best way to describe your JS application +File size limit (in kB) is not the best way to describe your JS application cost for developers. Developers will compare the size of the JS bundle -with the size of images. But browsers need much more time to parse 100 KB -of JS than 100 KB of an image since JS compilers are very complex. +with the size of images. But browsers need much more time to parse 100 kB +of JS than 100 kB of an image since JS compilers are very complex. This is why Size Limit support time-based limit. It runs headless Chrome to track the time a browser takes to compile and execute your JS. @@ -195,7 +195,7 @@ to track the time a browser takes to compile and execute your JS. ```sh $ npm run size - Package size: 30.08 KB with all dependencies, minified and gzipped + Package size: 30.08 kB with all dependencies, minified and gzipped Loading time: 602 ms on slow 3G Running time: 214 ms on Snapdragon 410 Total time: 815 ms @@ -232,10 +232,10 @@ to track the time a browser takes to compile and execute your JS. ### Big Libraries -JS libraries > 10 KB in size. +JS libraries > 10 kB in size. This preset includes headless Chrome, and will measure your lib’s execution -time. You likely don’t need this overhead for a small 2 KB lib, but for larger +time. You likely don’t need this overhead for a small 2 kB lib, but for larger ones the execution time is a more accurate and understandable metric that the size in bytes. Library like [React] is a good example for this preset. @@ -279,7 +279,7 @@ the size in bytes. Library like [React] is a good example for this preset. ```sh $ npm run size - Package size: 30.08 KB with all dependencies, minified and gzipped + Package size: 30.08 kB with all dependencies, minified and gzipped Loading time: 602 ms on slow 3G Running time: 214 ms on Snapdragon 410 Total time: 815 ms @@ -318,7 +318,7 @@ the size in bytes. Library like [React] is a good example for this preset. Short project description * **Fast.** 10% faster than competitor. - + * **Small.** 15 KB (minified and gzipped). + + * **Small.** 15 kB (minified and gzipped). + [Size Limit](https://github.com/ai/size-limit) controls the size. ``` @@ -327,7 +327,7 @@ the size in bytes. Library like [React] is a good example for this preset. ### Small Libraries -JS libraries < 10 KB in size. +JS libraries < 10 kB in size. This preset will only measure the size, without the execution time, so it’s suitable for small libraries. If your library is larger, you likely want @@ -377,7 +377,7 @@ for this preset. ```diff "size-limit": [ { - + "limit": "9 KB", + + "limit": "9 kB", "path": "index.js" } ], @@ -492,7 +492,7 @@ Each section in the config can have these options: to test multiple files. * **limit**: size or time limit for files from the `path` option. It should be a string with a number and unit, separated by a space. - Format: `100 B`, `10 KB`, `500 ms`, `1 s`. + Format: `100 B`, `10 kB`, `500 ms`, `1 s`. * **name**: the name of the current section. It will only be useful if you have multiple sections. * **entry**: when using a custom webpack config, a webpack entry could be given. @@ -508,7 +508,7 @@ Each section in the config can have these options: If you use Size Limit to track the size of CSS files, make sure to set `webpack: false`. Otherwise, you will get wrong numbers, because webpack -inserts `style-loader` runtime (≈2 KB) into the bundle. +inserts `style-loader` runtime (≈2 kB) into the bundle. [pattern]: https://github.com/sindresorhus/globby#globbing-patterns diff --git a/package.json b/package.json index fba35cc5..4aa19514 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ "CI", "gzip", "js", - "KB", + "kB", "nanoid", "npm", "Storeon", diff --git a/packages/preset-big-lib/README.md b/packages/preset-big-lib/README.md index 4f1b6c2c..fcba3926 100644 --- a/packages/preset-big-lib/README.md +++ b/packages/preset-big-lib/README.md @@ -1,6 +1,6 @@ # Size Limit Preset for Big Libraries -The preset for [Size Limit] for libraries > 10 KB. It uses +The preset for [Size Limit] for libraries > 10 kB. It uses webpack, file and time plugins to track the time of JS download and execution of library and all dependencies. diff --git a/packages/preset-small-lib/README.md b/packages/preset-small-lib/README.md index 631a11d6..e9327e73 100644 --- a/packages/preset-small-lib/README.md +++ b/packages/preset-small-lib/README.md @@ -1,6 +1,6 @@ # Size Limit Preset for Small Libraries -The preset for [Size Limit] for libraries < 10 KB. It uses +The preset for [Size Limit] for libraries < 10 kB. It uses webpack and file plugins to track the size of all files and dependencies. See Size Limit docs for more details. diff --git a/packages/size-limit/create-help.js b/packages/size-limit/create-help.js index c72cbc8b..641cef18 100644 --- a/packages/size-limit/create-help.js +++ b/packages/size-limit/create-help.js @@ -81,7 +81,7 @@ module.exports = process => { 'For frameworks, components and big libraries', ' ' + y(add + '@size-limit/preset-big-lib'), '', - 'For small (< 10 KB) libraries', + 'For small (< 10 kB) libraries', ' ' + y(add + '@size-limit/preset-small-lib'), '', 'Check out docs for more complicated cases', diff --git a/packages/size-limit/create-reporter.js b/packages/size-limit/create-reporter.js index 012d0d2b..ee9f7af6 100644 --- a/packages/size-limit/create-reporter.js +++ b/packages/size-limit/create-reporter.js @@ -9,7 +9,7 @@ let { yellow } = require('colorette') let { join } = require('path') -let bytes = require('bytes') +let bytes = require('bytes-iec') function createJsonReporter(process) { function print(data) { diff --git a/packages/size-limit/get-config.js b/packages/size-limit/get-config.js index 4493f92e..a328a8d8 100644 --- a/packages/size-limit/get-config.js +++ b/packages/size-limit/get-config.js @@ -1,7 +1,7 @@ let { isAbsolute, dirname, join, relative } = require('path') let { lilconfig } = require('lilconfig') let globby = require('globby') -let bytes = require('bytes') +let bytes = require('bytes-iec') let SizeLimitError = require('./size-limit-error') diff --git a/packages/size-limit/package.json b/packages/size-limit/package.json index 59ca36e3..4e16ef3d 100644 --- a/packages/size-limit/package.json +++ b/packages/size-limit/package.json @@ -18,7 +18,7 @@ "node": "^10 || ^11 || ^12 || >=13.7" }, "dependencies": { - "bytes": "^3.1.0", + "bytes-iec": "^3.1.1", "chokidar": "^3.5.1", "ci-job-number": "^1.2.2", "colorette": "^1.2.2", diff --git a/packages/size-limit/size-limit-error.js b/packages/size-limit/size-limit-error.js index 9aee7912..ba9f992d 100644 --- a/packages/size-limit/size-limit-error.js +++ b/packages/size-limit/size-limit-error.js @@ -57,7 +57,7 @@ class SizeLimitError extends Error { ' "size-limit": [\n' + ' {\n' + ' "path": "dist/bundle.js",\n' + - ' "limit": "10 KB"\n' + + ' "limit": "10 kB"\n' + ' }\n' + ' ]\n' } diff --git a/packages/size-limit/test/__snapshots__/create-reporter.test.js.snap b/packages/size-limit/test/__snapshots__/create-reporter.test.js.snap index 3f9c82bf..e60f1657 100644 --- a/packages/size-limit/test/__snapshots__/create-reporter.test.js.snap +++ b/packages/size-limit/test/__snapshots__/create-reporter.test.js.snap @@ -3,12 +3,12 @@ exports[`highlight passed results with --highlight-less flag 1`] = ` " ok - Size limit: 100 KB - Size: 100 KB gzipped + Size limit: 102.4 kB + Size: 102.4 kB gzipped good - Size limit: 100 KB - Size: 95 KB  gzipped + Size limit: 102.4 kB + Size: 97.28 kB gzipped fail Package size limit has exceeded by 1 B @@ -28,8 +28,8 @@ exports[`only renders failed results with --hide-passed flag 1`] = ` big fail Package size limit has exceeded by 100 B - Size limit: 100 KB - Size: 100.1 KB gzipped + Size limit: 102.4 kB + Size: 102.5 kB gzipped Try to reduce size or increase limit in \\"size-limit\\" section of package.json " @@ -62,7 +62,7 @@ exports[`renders config-less result 1`] = ` " Total time limit has exceeded Time limit: 500 ms - Size: 1000 B + Size: 1 kB Loading time: 200 ms on slow 3G Running time: 300 ms on Snapdragon 410 Total time: 500 ms @@ -74,8 +74,8 @@ exports[`renders config-less result 1`] = ` exports[`renders failed results 1`] = ` " ok - Size limit: 100 KB - Size: 100 KB gzipped + Size limit: 102.4 kB + Size: 102.4 kB gzipped small fail Package size limit has exceeded by 1 B @@ -84,8 +84,8 @@ exports[`renders failed results 1`] = ` big fail Package size limit has exceeded by 100 B - Size limit: 100 KB - Size: 100.1 KB gzipped + Size limit: 102.4 kB + Size: 102.5 kB gzipped Try to reduce size or increase limit in \\"size-limit\\" section of package.json " @@ -100,8 +100,8 @@ exports[`renders list of failed and success checks in silent mode 1`] = ` big fail Package size limit has exceeded by 100 B - Size limit: 100 KB - Size: 100.1 KB with all dependencies, minified and gzipped + Size limit: 102.4 kB + Size: 102.5 kB with all dependencies, minified and gzipped " `; @@ -115,8 +115,8 @@ exports[`renders list of failed checks in silent mode 1`] = ` big fail Package size limit has exceeded by 100 B - Size limit: 100 KB - Size: 100.1 KB with all dependencies, minified and gzipped + Size limit: 102.4 kB + Size: 102.5 kB with all dependencies, minified and gzipped " `; @@ -143,17 +143,17 @@ exports[`renders results 1`] = ` Total time: 600 ms size - Size limit: 100 KB - Size: 100 KB with all dependencies, minified and gzipped - Loading time: 1 s  on slow 3G - Running time: 2 s  on Snapdragon 410 + Size limit: 102.4 kB + Size: 102.4 kB with all dependencies, minified and gzipped + Loading time: 1 s  on slow 3G + Running time: 2 s  on Snapdragon 410 Total time: 3 s time Time limit: 4 s - Size: 100 KB with all dependencies and minified - Loading time: 1 s  on slow 3G - Running time: 2 s  on Snapdragon 410 + Size: 102.4 kB with all dependencies and minified + Loading time: 1 s  on slow 3G + Running time: 2 s  on Snapdragon 410 Total time: 3 s " diff --git a/packages/size-limit/test/__snapshots__/run.test.js.snap b/packages/size-limit/test/__snapshots__/run.test.js.snap index c6dbab09..c42f5337 100644 --- a/packages/size-limit/test/__snapshots__/run.test.js.snap +++ b/packages/size-limit/test/__snapshots__/run.test.js.snap @@ -2,14 +2,14 @@ exports[`run allows to use peer dependencies in import 1`] = ` " - Size: 2.44 KB with all dependencies, minified and gzipped + Size: 2.5 kB with all dependencies, minified and gzipped " `; exports[`run find plugins in parent package.json 1`] = ` " - Size limit: 1 KB + Size limit: 1 kB Size: 20 B gzipped " @@ -33,7 +33,7 @@ exports[`run returns zero bytes for empty file without gzip 1`] = ` exports[`run shows brotli text when brotli and gzip in config 1`] = ` " - Size limit: 1 KB + Size limit: 1 kB Size: -53 B with all dependencies, minified and brotli Loading time: 10 ms on slow 3G Running time: 1 s  on Snapdragon 410 @@ -44,7 +44,7 @@ exports[`run shows brotli text when brotli and gzip in config 1`] = ` exports[`run shows brotli text when only brotli in config 1`] = ` " - Size limit: 1 KB + Size limit: 1 kB Size: -53 B with all dependencies, minified and brotli Loading time: 10 ms on slow 3G Running time: 1 s  on Snapdragon 410 @@ -275,7 +275,7 @@ For application, where you send JS bundle directly to users For frameworks, components and big libraries npm install --save-dev @size-limit/preset-big-lib -For small (< 10 KB) libraries +For small (< 10 kB) libraries npm install --save-dev @size-limit/preset-small-lib Check out docs for more complicated cases @@ -292,7 +292,7 @@ For application, where you send JS bundle directly to users For frameworks, components and big libraries npm install --save-dev @size-limit/preset-big-lib -For small (< 10 KB) libraries +For small (< 10 kB) libraries npm install --save-dev @size-limit/preset-small-lib Check out docs for more complicated cases @@ -311,7 +311,7 @@ For application, where you send JS bundle directly to users For frameworks, components and big libraries yarn add --dev @size-limit/preset-big-lib -For small (< 10 KB) libraries +For small (< 10 kB) libraries yarn add --dev @size-limit/preset-small-lib Check out docs for more complicated cases @@ -388,7 +388,7 @@ exports[`run throws on empty config 1`] = ` \\"size-limit\\": [ { \\"path\\": \\"dist/bundle.js\\", - \\"limit\\": \\"10 KB\\" + \\"limit\\": \\"10 kB\\" } ] " @@ -405,7 +405,7 @@ exports[`run throws on no config 1`] = ` \\"size-limit\\": [ { \\"path\\": \\"dist/bundle.js\\", - \\"limit\\": \\"10 KB\\" + \\"limit\\": \\"10 kB\\" } ] " @@ -417,7 +417,7 @@ exports[`run throws on non-array config 1`] = ` \\"size-limit\\": [ { \\"path\\": \\"dist/bundle.js\\", - \\"limit\\": \\"10 KB\\" + \\"limit\\": \\"10 kB\\" } ] " @@ -429,7 +429,7 @@ exports[`run throws on non-object check 1`] = ` \\"size-limit\\": [ { \\"path\\": \\"dist/bundle.js\\", - \\"limit\\": \\"10 KB\\" + \\"limit\\": \\"10 kB\\" } ] " @@ -446,7 +446,7 @@ exports[`run throws on non-string path 1`] = ` \\"size-limit\\": [ { \\"path\\": \\"dist/bundle.js\\", - \\"limit\\": \\"10 KB\\" + \\"limit\\": \\"10 kB\\" } ] " diff --git a/packages/size-limit/test/create-reporter.test.js b/packages/size-limit/test/create-reporter.test.js index 13a39cef..3f121cd4 100644 --- a/packages/size-limit/test/create-reporter.test.js +++ b/packages/size-limit/test/create-reporter.test.js @@ -226,7 +226,7 @@ it('highlight passed results with --highlight-less flag', () => { }, { name: 'good', - size: 97280, // 5 KB less + size: 97280, // 5 KiB less sizeLimit: 102400, passed: true }, diff --git a/packages/size-limit/test/fixtures/brotli-with-gzip/package.json b/packages/size-limit/test/fixtures/brotli-with-gzip/package.json index dd02a751..c64772f5 100644 --- a/packages/size-limit/test/fixtures/brotli-with-gzip/package.json +++ b/packages/size-limit/test/fixtures/brotli-with-gzip/package.json @@ -8,7 +8,7 @@ "size-limit": [ { "path": "index.js", - "limit": "1 KB", + "limit": "1 kB", "brotli": true, "gzip": true } diff --git a/packages/size-limit/test/fixtures/brotli-without-webpack/package.json b/packages/size-limit/test/fixtures/brotli-without-webpack/package.json index 0f143e69..1f3e0f59 100644 --- a/packages/size-limit/test/fixtures/brotli-without-webpack/package.json +++ b/packages/size-limit/test/fixtures/brotli-without-webpack/package.json @@ -8,7 +8,7 @@ "size-limit": [ { "path": "index.js", - "limit": "1 KB", + "limit": "1 kB", "brotli": true } ] diff --git a/packages/size-limit/test/fixtures/brotli/package.json b/packages/size-limit/test/fixtures/brotli/package.json index 9de77c4c..33732e17 100644 --- a/packages/size-limit/test/fixtures/brotli/package.json +++ b/packages/size-limit/test/fixtures/brotli/package.json @@ -8,7 +8,7 @@ "size-limit": [ { "path": "index.js", - "limit": "1 KB", + "limit": "1 kB", "brotli": true } ] diff --git a/packages/size-limit/test/fixtures/file-not-found-json-config/.size-limit.json b/packages/size-limit/test/fixtures/file-not-found-json-config/.size-limit.json index d5d77621..73f2c2fa 100644 --- a/packages/size-limit/test/fixtures/file-not-found-json-config/.size-limit.json +++ b/packages/size-limit/test/fixtures/file-not-found-json-config/.size-limit.json @@ -1,6 +1,6 @@ [ { "path": "folder/index.js", - "limit": "100 KB" + "limit": "100 kB" } ] diff --git a/packages/size-limit/test/fixtures/file-not-found/package.json b/packages/size-limit/test/fixtures/file-not-found/package.json index 59e063e7..a0a88916 100644 --- a/packages/size-limit/test/fixtures/file-not-found/package.json +++ b/packages/size-limit/test/fixtures/file-not-found/package.json @@ -7,7 +7,7 @@ "size-limit": [ { "path": "folder/index.js", - "limit": "20 KB" + "limit": "20 kB" } ] } diff --git a/packages/size-limit/test/fixtures/globby/package.json b/packages/size-limit/test/fixtures/globby/package.json index 24fc1126..c06d10c2 100644 --- a/packages/size-limit/test/fixtures/globby/package.json +++ b/packages/size-limit/test/fixtures/globby/package.json @@ -11,7 +11,7 @@ "path": [ "a*.js" ], - "limit": "1 KB" + "limit": "1 kB" }, { "name": "b" diff --git a/packages/size-limit/test/fixtures/max-listeners/package.json b/packages/size-limit/test/fixtures/max-listeners/package.json index 565fb5d9..fc95c3a4 100644 --- a/packages/size-limit/test/fixtures/max-listeners/package.json +++ b/packages/size-limit/test/fixtures/max-listeners/package.json @@ -7,15 +7,15 @@ "size-limit": [ { "path": "index.js", - "limit": "1 KB" + "limit": "1 kB" }, { "path": "lib.js", - "limit": "1 KB" + "limit": "1 kB" }, { "path": "lib2.js", - "limit": "1 KB" + "limit": "1 kB" } ] } diff --git a/packages/size-limit/test/fixtures/nested/package/package.json b/packages/size-limit/test/fixtures/nested/package/package.json index ca28cb27..470be09b 100644 --- a/packages/size-limit/test/fixtures/nested/package/package.json +++ b/packages/size-limit/test/fixtures/nested/package/package.json @@ -4,7 +4,7 @@ "size-limit": [ { "name": "index", - "limit": "1 KB" + "limit": "1 kB" } ] } diff --git a/packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json b/packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json index d4c89939..7441f429 100644 --- a/packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json +++ b/packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json @@ -5,7 +5,7 @@ "size-limit": [ { "path": "index.js", - "limit": "1 KB", + "limit": "1 kB", "running": false } ] diff --git a/packages/size-limit/test/fixtures/simple/package.json b/packages/size-limit/test/fixtures/simple/package.json index 8a36bf4d..859d0e71 100644 --- a/packages/size-limit/test/fixtures/simple/package.json +++ b/packages/size-limit/test/fixtures/simple/package.json @@ -8,7 +8,7 @@ "size-limit": [ { "name": "index", - "limit": "1 KB" + "limit": "1 kB" } ] } diff --git a/packages/size-limit/test/fixtures/warn/package.json b/packages/size-limit/test/fixtures/warn/package.json index 8a36bf4d..859d0e71 100644 --- a/packages/size-limit/test/fixtures/warn/package.json +++ b/packages/size-limit/test/fixtures/warn/package.json @@ -8,7 +8,7 @@ "size-limit": [ { "name": "index", - "limit": "1 KB" + "limit": "1 kB" } ] } diff --git a/packages/size-limit/test/fixtures/yarn-without-dev-dep/package.json b/packages/size-limit/test/fixtures/yarn-without-dev-dep/package.json index 5d32dd63..4414791e 100644 --- a/packages/size-limit/test/fixtures/yarn-without-dev-dep/package.json +++ b/packages/size-limit/test/fixtures/yarn-without-dev-dep/package.json @@ -7,7 +7,7 @@ "size-limit": [ { "path": "index.js", - "limit": "1 KB", + "limit": "1 kB", "running": false } ] diff --git a/packages/size-limit/test/get-config.test.js b/packages/size-limit/test/get-config.test.js index 40c000e5..89916e65 100644 --- a/packages/size-limit/test/get-config.test.js +++ b/packages/size-limit/test/get-config.test.js @@ -57,8 +57,8 @@ it('supports globby and main field', async () => { { path: ['a*.js'], name: 'a', - limit: '1 KB', - sizeLimit: 1024, + limit: '1 kB', + sizeLimit: 1000, files: [fixture('globby', 'a1.js'), fixture('globby', 'a2.js')] }, { @@ -77,23 +77,23 @@ it('uses index.js by default', async () => { { name: 'index', files: [fixture('simple', 'index.js')], - limit: '1 KB', - sizeLimit: 1024 + limit: '1 kB', + sizeLimit: 1000 } ] }) }) it('overrides limit by CLI arg', async () => { - expect(await check('simple', ['--limit', '10 KB'])).toEqual({ + expect(await check('simple', ['--limit', '10 kB'])).toEqual({ configPath: 'package.json', cwd: fixture('simple'), checks: [ { name: 'index', files: [fixture('simple', 'index.js')], - limit: '10 KB', - sizeLimit: 10240 + limit: '10 kB', + sizeLimit: 10000 } ] }) diff --git a/yarn.lock b/yarn.lock index f01c8dd7..c25c7093 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1469,10 +1469,10 @@ builtin-status-codes@^3.0.0: resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= -bytes@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" - integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== +bytes-iec@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/bytes-iec/-/bytes-iec-3.1.1.tgz#94cd36bf95c2c22a82002c247df8772d1d591083" + integrity sha512-fey6+4jDK7TFtFg/klGSvNKJctyU7n2aQdnM+CO0ruLPbqqMOM8Tio0Pc+deqUeVKX1tL5DQep1zQ7+37aTAsA== cacache@^12.0.2: version "12.0.4"