compression-rspack-plugin 0.1.1 → 0.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/README.md +12 -12
- package/package.json +7 -8
- package/index.d.cts +0 -30
package/README.md
CHANGED
|
@@ -4,17 +4,6 @@ Rust-native parallel compression plugin for [Rspack](https://rspack.dev). Drop-i
|
|
|
4
4
|
|
|
5
5
|
Compresses assets **in parallel** across all CPU cores via Rust + [rayon](https://github.com/rayon-rs/rayon), instead of serially on the Node.js main thread.
|
|
6
6
|
|
|
7
|
-
## Benchmarks
|
|
8
|
-
|
|
9
|
-
Tested on a production Rspack build (~1,400 assets, Apple M3 Pro 14-core).
|
|
10
|
-
|
|
11
|
-
| | compression-webpack-plugin | compression-rspack-plugin |
|
|
12
|
-
|---|---|---|
|
|
13
|
-
| **Build time** (avg of 3) | 82.7s | **37.3s** (2.2x faster) |
|
|
14
|
-
| **Compression phase** (RsDoctor) | 61.1s | **20.3s** (3.0x faster) |
|
|
15
|
-
| .gz files | 1,410 | 1,411 |
|
|
16
|
-
| .br files | 1,444 | 1,444 |
|
|
17
|
-
|
|
18
7
|
## Install
|
|
19
8
|
|
|
20
9
|
```bash
|
|
@@ -56,6 +45,17 @@ Same interface as [compression-webpack-plugin](https://github.com/webpack/compre
|
|
|
56
45
|
| `minRatio` | `number` | `0.8` | Only emit if compressed/original < this |
|
|
57
46
|
| `deleteOriginalAssets` | `boolean \| "keep-source-map" \| Function` | `false` | Remove originals after compression |
|
|
58
47
|
|
|
48
|
+
## Benchmarks
|
|
49
|
+
|
|
50
|
+
Tested on a production Rspack build (~1,400 assets, Apple M3 Pro 14-core).
|
|
51
|
+
|
|
52
|
+
| | compression-webpack-plugin | compression-rspack-plugin |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| **Build time** (avg of 3) | 82.7s | **37.3s** (2.2x faster) |
|
|
55
|
+
| **Compression phase** (RsDoctor) | 61.1s | **20.3s** (3.0x faster) |
|
|
56
|
+
| .gz files | 1,410 | 1,411 |
|
|
57
|
+
| .br files | 1,444 | 1,444 |
|
|
58
|
+
|
|
59
59
|
## How it works
|
|
60
60
|
|
|
61
61
|
Built-in algorithms (`gzip`, `brotliCompress`, `deflate`, `deflateRaw`) are handled by [flate2](https://github.com/rust-lang/flate2-rs) and [brotli](https://github.com/dropbox/rust-brotli) in Rust via a single napi-rs FFI call. Custom algorithms fall back to Node.js `zlib`.
|
|
@@ -74,7 +74,7 @@ Built-in algorithms (`gzip`, `brotliCompress`, `deflate`, `deflateRaw`) are hand
|
|
|
74
74
|
```bash
|
|
75
75
|
pnpm install # install deps
|
|
76
76
|
pnpm build # native addon + TypeScript
|
|
77
|
-
pnpm test # JS tests (
|
|
77
|
+
pnpm test # JS tests (120 tests)
|
|
78
78
|
pnpm test:rust # Rust unit tests
|
|
79
79
|
pnpm lint # biome
|
|
80
80
|
pnpm lint:rs # cargo fmt + clippy
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compression-rspack-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rust-native parallel compression plugin for Rspack. Drop-in replacement for compression-webpack-plugin with gzip, brotli, deflate, and deflateRaw — all parallelized across CPU cores via Rust + rayon.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
"dist/helpers.*",
|
|
18
18
|
"dist/compressors/",
|
|
19
19
|
"dist/options.json",
|
|
20
|
-
"index.cjs"
|
|
21
|
-
"index.d.cts"
|
|
20
|
+
"index.cjs"
|
|
22
21
|
],
|
|
23
22
|
"napi": {
|
|
24
23
|
"binaryName": "compression-rspack-plugin",
|
|
@@ -71,11 +70,11 @@
|
|
|
71
70
|
"@rspack/core": ">=1.0.0"
|
|
72
71
|
},
|
|
73
72
|
"optionalDependencies": {
|
|
74
|
-
"compression-rspack-plugin-darwin-arm64": "0.1.
|
|
75
|
-
"compression-rspack-plugin-darwin-x64": "0.1.
|
|
76
|
-
"compression-rspack-plugin-linux-x64-gnu": "0.1.
|
|
77
|
-
"compression-rspack-plugin-linux-arm64-gnu": "0.1.
|
|
78
|
-
"compression-rspack-plugin-linux-x64-musl": "0.1.
|
|
73
|
+
"compression-rspack-plugin-darwin-arm64": "0.1.2",
|
|
74
|
+
"compression-rspack-plugin-darwin-x64": "0.1.2",
|
|
75
|
+
"compression-rspack-plugin-linux-x64-gnu": "0.1.2",
|
|
76
|
+
"compression-rspack-plugin-linux-arm64-gnu": "0.1.2",
|
|
77
|
+
"compression-rspack-plugin-linux-x64-musl": "0.1.2"
|
|
79
78
|
},
|
|
80
79
|
"dependencies": {
|
|
81
80
|
"p-limit": "7.3.0",
|
package/index.d.cts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* auto-generated by NAPI-RS */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export interface AssetInput {
|
|
4
|
-
filename: string
|
|
5
|
-
content: Buffer
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Compress multiple assets in parallel using Rust-native gzip and brotli.
|
|
10
|
-
*
|
|
11
|
-
* All assets are compressed concurrently across all available CPU cores via rayon.
|
|
12
|
-
* A single FFI boundary crossing: JS sends all assets in, Rust returns all compressed
|
|
13
|
-
* variants out.
|
|
14
|
-
*/
|
|
15
|
-
export declare function compressAssets(assets: Array<AssetInput>, options?: CompressOptions | undefined | null): Array<CompressedAsset>
|
|
16
|
-
|
|
17
|
-
export interface CompressedAsset {
|
|
18
|
-
filename: string
|
|
19
|
-
content: Buffer
|
|
20
|
-
algorithm: string
|
|
21
|
-
originalSize: number
|
|
22
|
-
compressedSize: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface CompressOptions {
|
|
26
|
-
gzip?: boolean
|
|
27
|
-
brotli?: boolean
|
|
28
|
-
gzipLevel?: number
|
|
29
|
-
brotliQuality?: number
|
|
30
|
-
}
|