Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Brotli by default #346

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on CI, calculates the real cost of your JS for end-users and throws an error
if the cost exceeds the limit.

* **ES modules** and **tree-shaking** support.
* Add Size Limit to **Travis CI**, **Circle CI**, **GitHub Actions**
or another CI system to know if a pull request adds a massive dependency.
* Add Size Limit to **GitHub Actions**, **Circle CI** or another CI system
to know if a pull request adds a massive dependency.
* **Modular** to fit different use cases: big JS applications
that use their own bundler or small npm libraries with many files.
* Can calculate **the time** it would take a browser
Expand Down Expand Up @@ -127,7 +127,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 brotlied
```

4. Now, let’s set the limit. Add 25% to the current total size and use that as
Expand All @@ -154,7 +154,7 @@ interactive elements, using React/Vue/Svelte lib or vanilla JS.
```

6. If you don’t have a continuous integration service running, don’t forget
to add one — start with [Travis CI].
to add one — start with Github Actions.

</details>

Expand Down Expand Up @@ -197,7 +197,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 brotlied
Loading time: 602 ms on slow 3G
Running time: 214 ms on Snapdragon 410
Total time: 815 ms
Expand Down Expand Up @@ -227,7 +227,7 @@ to track the time a browser takes to compile and execute your JS.
```

6. If you don’t have a continuous integration service running, don’t forget
to add one — start with [Travis CI].
to add one — start with Github Actions.

</details>

Expand Down Expand Up @@ -281,7 +281,7 @@ the size in bytes. Libraries like [React] are good examples 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 brotlied
Loading time: 602 ms on slow 3G
Running time: 214 ms on Snapdragon 410
Total time: 815 ms
Expand Down Expand Up @@ -311,7 +311,7 @@ the size in bytes. Libraries like [React] are good examples for this preset.
```

7. If you don’t have a continuous integration service running, don’t forget
to add one — start with [Travis CI].
to add one — start with Github Actions.
8. Add the library size to docs, it will help users to choose your project:

```diff
Expand All @@ -320,7 +320,7 @@ the size in bytes. Libraries like [React] are good examples for this preset.
Short project description

* **Fast.** 10% faster than competitor.
+ * **Small.** 15 kB (minified and gzipped).
+ * **Small.** 15 kB (minified and brotlied).
+ [Size Limit](https://github.com/ai/size-limit) controls the size.
```

Expand Down Expand Up @@ -363,7 +363,7 @@ for this preset.
```sh
$ npm run size

Package size: 177 B with all dependencies, minified and gzipped
Package size: 177 B with all dependencies, minified and brotlied
```

4. If your project size starts to look bloated, run `--why` for analysis:
Expand Down Expand Up @@ -398,7 +398,7 @@ for this preset.
```

7. If you don’t have a continuous integration service running, don’t forget
to add one — start with [Travis CI].
to add one — start with Github Actions.
8. Add the library size to docs, it will help users to choose your project:

```diff
Expand All @@ -407,14 +407,12 @@ for this preset.
Short project description

* **Fast.** 10% faster than competitor.
+ * **Small.** 500 bytes (minified and gzipped). No dependencies.
+ * **Small.** 500 bytes (minified and brotlied). No dependencies.
+ [Size Limit](https://github.com/ai/size-limit) controls the size.
```

</details>


[Travis CI]: https://github.com/dwyl/learn-travis
[Storeon]: https://github.com/ai/storeon/
[Nano ID]: https://github.com/ai/nanoid/
[React]: https://github.com/facebook/react/
Expand Down Expand Up @@ -458,7 +456,7 @@ For example, if you want to use `@size-limit/webpack`, you can just use

Plugins:

* `@size-limit/file` checks the size of files with Gzip, Brotli
* `@size-limit/file` checks the size of files with Brotli (default), Gzip
or without compression.
* `@size-limit/webpack` adds your library to empty webpack project
and prepares bundle file for `file` plugin.
Expand Down Expand Up @@ -552,9 +550,9 @@ Each section in the config can have these options:
By default, the total size of all entry points will be checked.
* **webpack**: with `false` it will disable webpack.
* **running**: with `false` it will disable calculating running time.
* **gzip**: with `false` it will disable gzip compression.
* **brotli**: with `true` it will use brotli compression and disable
gzip compression.
* **gzip**: with `true` it will use Brotli compression and disable
Brotli compression.
* **brotli**: with `false` it will disable any compression.
* **config**: a path to a custom webpack config.
* **ignore**: an array of files and dependencies to exclude from
the project size calculation.
Expand Down
1 change: 0 additions & 1 deletion fixtures/esbuild-why-missing/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "esbuild-why-missing",
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/esbuild-why/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "esbuild-why",
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/file/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "file",
"private": true,
"devDependencies": {
"@size-limit/file": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/globby/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "globby",
"private": true,
"devDependencies": {
"@size-limit/file": ">= 0.0.0",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "brotli-with-gzip",
"private": true,
"devDependencies": {
"@size-limit/preset-big-lib": ">= 0.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "brotli-without-file",
"private": true,
"devDependencies": {
"size-limit": ">= 0.0.0"
Expand All @@ -8,7 +7,7 @@
{
"path": "index.js",
"limit": "1 kB",
"brotli": true
"gzip": true
}
]
}
File renamed without changes.
3 changes: 1 addition & 2 deletions fixtures/brotli/package.json → fixtures/gzip/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "brotli",
"private": true,
"devDependencies": {
"@size-limit/preset-big-lib": ">= 0.0.0",
Expand All @@ -9,7 +8,7 @@
{
"path": "index.js",
"limit": "1 kB",
"brotli": true
"gzip": true
}
]
}
3 changes: 1 addition & 2 deletions fixtures/integration-esm/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "integration-esm",
"private": true,
"devDependencies": {
"@size-limit/preset-small-lib": ">= 0.0.0",
Expand All @@ -12,7 +11,7 @@
},
{
"name": "all",
"limit": "39 B"
"limit": "48 B"
}
]
}
1 change: 0 additions & 1 deletion fixtures/integration/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "integration",
"private": true,
"devDependencies": {
"@size-limit/preset-big-lib": ">=0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/internal-error/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "internal-error",
"private": true,
"devDependencies": {
"@size-limit/time": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/nested/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "nested",
"private": true,
"devDependencies": {
"@size-limit/file": ">=0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/nested/package/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "package",
"private": true,
"size-limit": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"size-limit": [
{
"gzip": false
"brotli": false
}
]
}
1 change: 0 additions & 1 deletion fixtures/npm-with-config-without-dev/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "npm-with-config-without-dev",
"private": true,
"devDependencies": {},
"size-limit": [
Expand Down
19 changes: 19 additions & 0 deletions fixtures/peer-esbuild-gzip/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
"@size-limit/file": ">= 0.0.0",
"cross-spawn": ">= 0.0.0",
"size-limit": ">= 0.0.0"
},
"peerDependencies": {
"cross-spawn": ">= 0.0.0"
},
"size-limit": [
{
"import": "{ test }",
"limit": "46 B",
"gzip": true
}
]
}
5 changes: 5 additions & 0 deletions fixtures/peer-esbuild-non-compression/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { spawn } from 'cross-spawn'

export function test() {
return spawn()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "peer-esbuild-non-gzip",
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
Expand All @@ -14,7 +13,7 @@
{
"import": "{ test }",
"limit": "5 B",
"gzip": false
"brotli": false
}
]
}
1 change: 0 additions & 1 deletion fixtures/peer-esbuild/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "peer-esbuild",
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/peer/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "peer",
"private": true,
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "size-limit-3rd-party-plugin",
"dependencies": {
"size-limit-node-esbuild": ">=0.0.0"
}
Expand Down
1 change: 0 additions & 1 deletion fixtures/relative/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "relative",
"private": true,
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion fixtures/simple/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "file",
"private": true,
"name": "simple",
"devDependencies": {
"@size-limit/file": ">= 0.0.0",
"size-limit": ">= 0.0.0"
Expand Down
1 change: 0 additions & 1 deletion fixtures/time/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "file",
"private": true,
"devDependencies": {
"@size-limit/time": ">= 0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion fixtures/ui-reports/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui-reports",
"private": true,
"name": "ui-reports",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/unknown/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "unknown",
"private": true,
"devDependencies": {
"@size-limit/file": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/warn/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "file",
"private": true,
"devDependencies": {
"@size-limit/file": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/webpack-no-files/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "webpack",
"private": true,
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion fixtures/webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpack",
"private": true,
"name": "webpack",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
Expand Down
1 change: 0 additions & 1 deletion fixtures/yarn-without-dev-dep/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "file",
"private": true,
"devDependencies": {
"@size-limit/preset-big-lib": ">= 0.0.0"
Expand Down
15 changes: 15 additions & 0 deletions fixtures/zero-esbuild-gzip/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
"@size-limit/file": ">= 0.0.0",
"@size-limit/webpack-css": ">= 10.0.1",
"size-limit": ">= 0.0.0"
},
"size-limit": [
{
"limit": "0 B",
"gzip": true
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "webpack",
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
Expand All @@ -9,7 +8,7 @@
"size-limit": [
{
"limit": "0 B",
"gzip": false
"brotli": false
}
]
}
1 change: 0 additions & 1 deletion fixtures/zero-esbuild/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "webpack",
"private": true,
"devDependencies": {
"@size-limit/esbuild": ">= 0.0.0",
Expand Down
Empty file.
Loading