@medicomind/rolldown-compression 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +24 -24
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/index.d.ts +3 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @medicomind/rolldown-compression
|
|
2
2
|
|
|
3
|
+
## 2.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6e0b693`](https://github.com/Medico-Mind/rolldown-compression/commit/6e0b693fd24338102876ecb4bb605ed37e1a3804) Thanks [@Mnwa](https://github.com/Mnwa)! - Default brotli `sectionSize` to one window (`2^windowBits` bytes) instead of a fixed 4 MiB, so a custom `windowBits` gets a matching section size. Unchanged at the default window of 22, where both are 4 MiB.
|
|
8
|
+
|
|
9
|
+
## 2.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`2fa931e`](https://github.com/Medico-Mind/rolldown-compression/commit/2fa931efef1b6e58e48c0782aeed83aee6b9d26b) Thanks [@Mnwa](https://github.com/Mnwa)! - Fix windows warning and up deps
|
|
14
|
+
|
|
3
15
|
## 2.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Fast, native compression plugin for [Rolldown](https://rolldown.rs) and [Vite 8+](#usage-with-vite): compresses emitted assets with **gzip**, **brotli** and **zstd** at build time. The compression core is written in Rust (napi-rs + rayon) — one batched FFI call per build, fanned out across all CPU cores, without ever blocking the JS event loop.
|
|
10
10
|
|
|
11
|
-
**3x faster builds in a real project**: switching a production app from `node:zlib`-based (node v26.4.0) compression to this plugin cut total build time from 3:50 to 1:
|
|
11
|
+
**3x faster builds in a real project**: switching a production app from `node:zlib`-based (node v26.4.0) compression to this plugin cut total build time from 3:50 to 1:13 (740% → 688% CPU utilization) — see [real-world results](#real-world-results).
|
|
12
12
|
|
|
13
13
|
API ergonomics mirror [`vite-plugin-compression2`](https://github.com/nonzzz/vite-plugin-compression); see [differences](#differences-from-vite-plugin-compression2).
|
|
14
14
|
|
|
@@ -80,32 +80,32 @@ export default defineConfig({
|
|
|
80
80
|
|
|
81
81
|
## Options
|
|
82
82
|
|
|
83
|
-
| option
|
|
84
|
-
|
|
85
|
-
| `include`
|
|
86
|
-
| `exclude`
|
|
87
|
-
| `threshold`
|
|
88
|
-
| `algorithms`
|
|
89
|
-
| `filename`
|
|
90
|
-
| `deleteOriginalAssets` | `boolean`
|
|
91
|
-
| `skipIfLargerOrEqual`
|
|
92
|
-
| `concurrency`
|
|
93
|
-
| `chunkSize`
|
|
94
|
-
| `stream`
|
|
95
|
-
| `logLevel`
|
|
96
|
-
| `enableInWatchMode`
|
|
83
|
+
| option | type | default | description |
|
|
84
|
+
|------------------------|-------------------------------------------------|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
85
|
+
| `include` | `string \| RegExp \| Array<string \| RegExp>` | `/\.(html\|xml\|css\|json\|js\|mjs\|svg\|yaml\|yml\|toml\|txt\|wasm)$/` | Files to compress. Strings are [picomatch](https://github.com/micromatch/picomatch) globs, matched against bundle-relative file names ([`@rollup/pluginutils` `createFilter`](https://github.com/rollup/plugins/tree/master/packages/pluginutils#createfilter) semantics). |
|
|
86
|
+
| `exclude` | `string \| RegExp \| Array<string \| RegExp>` | — | Files to skip. **Wins over `include`.** |
|
|
87
|
+
| `threshold` | `number` | `0` | Minimum original size in bytes for a file to be compressed. |
|
|
88
|
+
| `algorithms` | `Array<AlgorithmName \| DefineAlgorithmResult>` | `['gzip', 'brotli']` | Algorithms to run. Aliases `gz`, `br`, `brotliCompress`, `zstandard` normalize to `gzip` / `brotli` / `zstd`. |
|
|
89
|
+
| `filename` | `string \| (fileName, algorithm) => string` | `'[path][base]' + ext` | Name of the emitted artifact. Tokens: `[path]` (directory incl. trailing `/`), `[base]`, `[name]`, `[ext]` (with dot), `[hash]` (8-char sha256 of the content). Default extensions: `.gz`, `.br`, `.zst`. |
|
|
90
|
+
| `deleteOriginalAssets` | `boolean` | `false` | Remove the original from the bundle after all algorithms processed it. Errors if `filename` resolves to the source name. |
|
|
91
|
+
| `skipIfLargerOrEqual` | `boolean` | `true` | Don't emit artifacts whose compressed size is `>=` the original. |
|
|
92
|
+
| `concurrency` | `number` | `0` | Native worker threads. `0` = number of logical CPUs. |
|
|
93
|
+
| `chunkSize` | `number` | `0` | Max source bytes buffered per native compression batch. `0` = one batch for the whole build. A positive value (e.g. `64 * 1024 * 1024`) caps the plugin's peak memory overhead at roughly one batch of source copies plus its compressed outputs; a single file larger than `chunkSize` still forms its own batch. The bundler keeps the original bundle in memory regardless. In [stream mode](#stream-mode) `0` falls back to a 4 MB batch instead of one big batch. |
|
|
94
|
+
| `stream` | `boolean` | `false` | Compress from disk in `writeBundle` (order `post`) instead of in memory in `generateBundle`: files are read on demand in bounded batches (`chunkSize` bytes, default 4 MB), and assets written to disk by other plugins' `writeBundle` hooks are compressed too (see [stream mode](#stream-mode)). |
|
|
95
|
+
| `logLevel` | `'silent' \| 'error' \| 'warn' \| 'info'` | `'info'` | Plugin log verbosity; `info` prints a per-algorithm summary at build end. |
|
|
96
|
+
| `enableInWatchMode` | `boolean` | `false` | The plugin is a no-op in watch/dev mode unless enabled (see [watch mode](#watch--dev-mode)). |
|
|
97
97
|
|
|
98
98
|
All options are validated when `compression()` is called — invalid levels (e.g. brotli quality 12), unknown algorithm names or malformed filters throw immediately, not mid-build.
|
|
99
99
|
|
|
100
100
|
### Per-algorithm options
|
|
101
101
|
|
|
102
|
-
| algorithm | option
|
|
103
|
-
|
|
104
|
-
| `gzip`
|
|
105
|
-
| `brotli`
|
|
106
|
-
| `brotli`
|
|
107
|
-
| `brotli`
|
|
108
|
-
| `zstd`
|
|
102
|
+
| algorithm | option | range | default |
|
|
103
|
+
|-----------|---------------|-------------|---------|
|
|
104
|
+
| `gzip` | `level` | 0–9 | 6 |
|
|
105
|
+
| `brotli` | `quality` | 0–11 | 11 |
|
|
106
|
+
| `brotli` | `windowBits` | 10–24 | 22 |
|
|
107
|
+
| `brotli` | `sectionSize` | ≥ 1 (bytes) | `2^windowBits` B |
|
|
108
|
+
| `zstd` | `level` | 1–22 | 19 |
|
|
109
109
|
|
|
110
110
|
```ts
|
|
111
111
|
defineAlgorithm('gzip', { level: 9 })
|
|
@@ -113,7 +113,7 @@ defineAlgorithm('brotli', { quality: 7, windowBits: 22 })
|
|
|
113
113
|
defineAlgorithm('zstd', { level: 12 })
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
`sectionSize` is the target number of bytes each brotli worker thread compresses when a large input is split across the native worker pool; inputs at least four times `sectionSize` take the multithreaded path
|
|
116
|
+
`sectionSize` is the target number of bytes each brotli worker thread compresses when a large input is split across the native worker pool; inputs at least four times `sectionSize` take the multithreaded path. It defaults to one window (`2^windowBits` bytes) — 4 MiB and multithreading from 16 MiB at the default window — because sections much smaller than the window lose too many cross-section matches. Smaller sections finish large files faster at a slight cost in compression ratio.
|
|
117
117
|
|
|
118
118
|
## How it works
|
|
119
119
|
|
|
@@ -176,7 +176,7 @@ Switching a production app's build from `node:zlib`-based compression to this pl
|
|
|
176
176
|
|
|
177
177
|
```
|
|
178
178
|
before: npm run build 675.82s user 4.63s system 294% cpu 3:50.92 total
|
|
179
|
-
after: npm run build
|
|
179
|
+
after: npm run build 537.24s user 5.59s system 740% cpu 1:13.29 total
|
|
180
180
|
```
|
|
181
181
|
|
|
182
182
|
**4.03x faster wall clock.** Compression stops being serialized behind the libuv thread pool (default `UV_THREADPOOL_SIZE=4`) and runs on all cores instead — CPU utilization jumps from 235% to 784%.
|
package/dist/index.d.cts
CHANGED
|
@@ -12,9 +12,9 @@ interface GzipOptions {
|
|
|
12
12
|
* Brotli options. `quality`: 0-11, default 11. `windowBits`: 10-24, default 22.
|
|
13
13
|
* `sectionSize`: target bytes per worker thread when large inputs are split
|
|
14
14
|
* across the native brotli worker pool; inputs at least four times this size
|
|
15
|
-
* take the multithreaded path.
|
|
16
|
-
*
|
|
17
|
-
* ratio.
|
|
15
|
+
* take the multithreaded path. Defaults to one window (`2^windowBits` bytes),
|
|
16
|
+
* i.e. 4 MiB and multithreading from 16 MiB at the default window. Smaller
|
|
17
|
+
* sections finish large files faster at a slight cost in compression ratio.
|
|
18
18
|
*/
|
|
19
19
|
interface BrotliOptions {
|
|
20
20
|
quality?: number;
|
package/dist/index.d.mts
CHANGED
|
@@ -12,9 +12,9 @@ interface GzipOptions {
|
|
|
12
12
|
* Brotli options. `quality`: 0-11, default 11. `windowBits`: 10-24, default 22.
|
|
13
13
|
* `sectionSize`: target bytes per worker thread when large inputs are split
|
|
14
14
|
* across the native brotli worker pool; inputs at least four times this size
|
|
15
|
-
* take the multithreaded path.
|
|
16
|
-
*
|
|
17
|
-
* ratio.
|
|
15
|
+
* take the multithreaded path. Defaults to one window (`2^windowBits` bytes),
|
|
16
|
+
* i.e. 4 MiB and multithreading from 16 MiB at the default window. Smaller
|
|
17
|
+
* sections finish large files faster at a slight cost in compression ratio.
|
|
18
18
|
*/
|
|
19
19
|
interface BrotliOptions {
|
|
20
20
|
quality?: number;
|
package/index.d.ts
CHANGED
|
@@ -56,8 +56,9 @@ export interface CompressTask {
|
|
|
56
56
|
/**
|
|
57
57
|
* Brotli only: target section size in bytes per worker thread when
|
|
58
58
|
* large inputs are split across the brotli worker pool; inputs at
|
|
59
|
-
* least four times this size take the multithreaded path
|
|
60
|
-
* (
|
|
59
|
+
* least four times this size take the multithreaded path. Defaults
|
|
60
|
+
* to one window (`2^windowBits` bytes), i.e. 4 MiB and
|
|
61
|
+
* multithreading from 16 MiB at the default window.
|
|
61
62
|
*/
|
|
62
63
|
sectionSize?: number
|
|
63
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medicomind/rolldown-compression",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Fast native (Rust) gzip / brotli / zstd compression plugin for Rolldown, powered by napi-rs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rolldown",
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
"rolldown": "^1.0.0"
|
|
92
92
|
},
|
|
93
93
|
"optionalDependencies": {
|
|
94
|
-
"@medicomind/rolldown-compression-darwin-arm64": "2.1.
|
|
95
|
-
"@medicomind/rolldown-compression-darwin-x64": "2.1.
|
|
96
|
-
"@medicomind/rolldown-compression-linux-arm64-gnu": "2.1.
|
|
97
|
-
"@medicomind/rolldown-compression-linux-x64-gnu": "2.1.
|
|
98
|
-
"@medicomind/rolldown-compression-linux-x64-musl": "2.1.
|
|
99
|
-
"@medicomind/rolldown-compression-wasm32-wasi": "2.1.
|
|
100
|
-
"@medicomind/rolldown-compression-win32-x64-msvc": "2.1.
|
|
94
|
+
"@medicomind/rolldown-compression-darwin-arm64": "2.1.2",
|
|
95
|
+
"@medicomind/rolldown-compression-darwin-x64": "2.1.2",
|
|
96
|
+
"@medicomind/rolldown-compression-linux-arm64-gnu": "2.1.2",
|
|
97
|
+
"@medicomind/rolldown-compression-linux-x64-gnu": "2.1.2",
|
|
98
|
+
"@medicomind/rolldown-compression-linux-x64-musl": "2.1.2",
|
|
99
|
+
"@medicomind/rolldown-compression-wasm32-wasi": "2.1.2",
|
|
100
|
+
"@medicomind/rolldown-compression-win32-x64-msvc": "2.1.2"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@biomejs/biome": "^2.5.3",
|