@medicomind/rolldown-compression 0.3.1 → 0.3.4
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 +22 -0
- package/README.md +24 -8
- package/dist/index.cjs +50 -38
- package/dist/index.d.cts +10 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +50 -38
- package/index.js +52 -52
- package/package.json +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @medicomind/rolldown-compression
|
|
2
2
|
|
|
3
|
+
## 0.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0d8f332`](https://github.com/Medico-Mind/rolldown-compression/commit/0d8f332e30b182dfffbc68b2a912e4a892b3fe0e) Thanks [@Mnwa](https://github.com/Mnwa)! - Add multicompress and threaded compress for zstd and brotli
|
|
8
|
+
|
|
9
|
+
- [`25f3f8e`](https://github.com/Medico-Mind/rolldown-compression/commit/25f3f8eec15e6838ec64a2cb7eef4915f9e6a0c3) Thanks [@Mnwa](https://github.com/Mnwa)! - Add chunkSize option. It will reduce memory usage but increase time to compress.
|
|
10
|
+
|
|
11
|
+
- [`ad7ce4b`](https://github.com/Medico-Mind/rolldown-compression/commit/ad7ce4b26e4809c40e8286a9f9a66957e03d9bcd) Thanks [@Mnwa](https://github.com/Mnwa)! - Add random buffers and big files to train corpus
|
|
12
|
+
|
|
13
|
+
## 0.3.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`09e6051`](https://github.com/Medico-Mind/rolldown-compression/commit/09e60515347263107017b720300bbddba7d6fa3f) Thanks [@Mnwa](https://github.com/Mnwa)! - Inject optional deps on a release time
|
|
18
|
+
|
|
19
|
+
## 0.3.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`1def850`](https://github.com/Medico-Mind/rolldown-compression/commit/1def8503a2ffd8fc06c3a8bf394fad7e256734a5) Thanks [@Mnwa](https://github.com/Mnwa)! - Declare the platform binary packages in `optionalDependencies` so npm actually installs the native binding. 0.3.1 shipped without them, causing "Cannot find native binding" on import.
|
|
24
|
+
|
|
3
25
|
## 0.3.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
Fast, native compression plugin for [Rolldown](https://rolldown.rs): 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
|
+
Since v0.3.3 we are using PGO and Bolt optimizations in our native binaries. It reduce around 5-10% build compression time in some cases (see benchmarks).
|
|
12
|
+
|
|
11
13
|
API ergonomics mirror [`vite-plugin-compression2`](https://github.com/nonzzz/vite-plugin-compression); see [differences](#differences-from-vite-plugin-compression2).
|
|
12
14
|
|
|
13
15
|
## Install
|
|
@@ -52,6 +54,7 @@ compression({
|
|
|
52
54
|
deleteOriginalAssets: false,
|
|
53
55
|
skipIfLargerOrEqual: true,
|
|
54
56
|
concurrency: 0, // 0 = number of logical CPUs
|
|
57
|
+
chunkSize: 0, // 0 = compress everything in one batch
|
|
55
58
|
logLevel: 'info',
|
|
56
59
|
})
|
|
57
60
|
```
|
|
@@ -68,6 +71,7 @@ compression({
|
|
|
68
71
|
| `deleteOriginalAssets` | `boolean` | `false` | Remove the original from the bundle after all algorithms processed it. Errors if `filename` resolves to the source name. |
|
|
69
72
|
| `skipIfLargerOrEqual` | `boolean` | `true` | Don't emit artifacts whose compressed size is `>=` the original. |
|
|
70
73
|
| `concurrency` | `number` | `0` | Native worker threads. `0` = number of logical CPUs. |
|
|
74
|
+
| `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. |
|
|
71
75
|
| `logLevel` | `'silent' \| 'error' \| 'warn' \| 'info'` | `'info'` | Plugin log verbosity; `info` prints a per-algorithm summary at build end. |
|
|
72
76
|
| `enableInWatchMode` | `boolean` | `false` | The plugin is a no-op in watch/dev mode unless enabled (see [watch mode](#watch--dev-mode)). |
|
|
73
77
|
|
|
@@ -131,13 +135,25 @@ example.com {
|
|
|
131
135
|
|
|
132
136
|
Results on an Apple M1 Pro (10 cores), Node 26, default `UV_THREADPOOL_SIZE`:
|
|
133
137
|
|
|
134
|
-
|
|
135
|
-
|
|
|
136
|
-
|
|
137
|
-
| gzip (
|
|
138
|
-
| gzip (level
|
|
139
|
-
|
|
|
140
|
-
|
|
|
138
|
+
### With PGO
|
|
139
|
+
| scenario | output | native (rust) | node:zlib | speedup |
|
|
140
|
+
|-----------------------------------|---------|---------------|-----------|---------|
|
|
141
|
+
| gzip+brotli (ref. defaults: 9/11) | 8.71 MB | 10.90s | 15.55s | 1.43x |
|
|
142
|
+
| gzip (level 9) | 5.51 MB | 0.09s | 0.33s | 3.61x |
|
|
143
|
+
| gzip (level 6) | 5.64 MB | 0.06s | 0.16s | 2.60x |
|
|
144
|
+
| brotli (quality 11) | 3.21 MB | 9.74s | 14.98s | 1.54x |
|
|
145
|
+
| brotli (quality 6) | 5.70 MB | 0.13s | 0.16s | 1.29x |
|
|
146
|
+
| zstd (level 19) | 3.28 MB | 2.32s | 6.83s | 2.94x |
|
|
147
|
+
|
|
148
|
+
### Without PGO
|
|
149
|
+
| scenario | output | native (rust) | node:zlib | speedup |
|
|
150
|
+
|-----------------------------------|---------|---------------|-----------|---------|
|
|
151
|
+
| gzip+brotli (ref. defaults: 9/11) | 8.71 MB | 10.41s | 15.36s | 1.48x |
|
|
152
|
+
| gzip (level 9) | 5.51 MB | 0.10s | 0.34s | 3.38x |
|
|
153
|
+
| gzip (level 6) | 5.64 MB | 0.07s | 0.16s | 2.17x |
|
|
154
|
+
| brotli (quality 11) | 3.21 MB | 10.31s | 15.00s | 1.45x |
|
|
155
|
+
| brotli (quality 6) | 5.70 MB | 0.13s | 0.17s | 1.28x |
|
|
156
|
+
| zstd (level 19) | 3.28 MB | 2.97s | 6.95s | 2.34x |
|
|
141
157
|
|
|
142
158
|
Reading these numbers honestly:
|
|
143
159
|
|
|
@@ -189,7 +205,7 @@ Node.js >= 18.
|
|
|
189
205
|
- **No tarball plugin**: out of scope.
|
|
190
206
|
- **gzip default level is 6** (zlib default), not 9 — measurably faster for a ~1% size difference. Pass `defineAlgorithm('gzip', { level: 9 })` to match the reference.
|
|
191
207
|
- **zstd everywhere**: zstd is compiled in, with no dependency on the Node runtime's zstd support (node >= 22.15).
|
|
192
|
-
- Extra options: `concurrency` (native thread cap) and `enableInWatchMode`.
|
|
208
|
+
- Extra options: `concurrency` (native thread cap), `chunkSize` (memory cap per compression batch) and `enableInWatchMode`.
|
|
193
209
|
|
|
194
210
|
## Implementation decisions
|
|
195
211
|
|
package/dist/index.cjs
CHANGED
|
@@ -127,9 +127,10 @@ function validateDefined(entry) {
|
|
|
127
127
|
/** Validate and normalize user options. Throws at `compression()` call time. */
|
|
128
128
|
function resolveOptions(options = {}) {
|
|
129
129
|
if (options === null || typeof options !== "object") throw new OptionValidationError("options must be an object");
|
|
130
|
-
const { include = DEFAULT_INCLUDE, exclude, threshold = 0, algorithms = ["gzip", "brotli"], filename, deleteOriginalAssets = false, skipIfLargerOrEqual = true, concurrency = 0, logLevel = "info", enableInWatchMode = false } = options;
|
|
130
|
+
const { include = DEFAULT_INCLUDE, exclude, threshold = 0, algorithms = ["gzip", "brotli"], filename, deleteOriginalAssets = false, skipIfLargerOrEqual = true, concurrency = 0, chunkSize = 0, logLevel = "info", enableInWatchMode = false } = options;
|
|
131
131
|
if (typeof threshold !== "number" || Number.isNaN(threshold) || threshold < 0) throw new OptionValidationError(`invalid threshold: expected a non-negative number, got ${JSON.stringify(threshold)}`);
|
|
132
132
|
if (!Number.isInteger(concurrency) || concurrency < 0) throw new OptionValidationError(`invalid concurrency: expected a non-negative integer, got ${JSON.stringify(concurrency)}`);
|
|
133
|
+
if (!Number.isInteger(chunkSize) || chunkSize < 0) throw new OptionValidationError(`invalid chunkSize: expected a non-negative integer number of bytes, got ${JSON.stringify(chunkSize)}`);
|
|
133
134
|
if (!LOG_LEVELS.includes(logLevel)) throw new OptionValidationError(`invalid logLevel ${JSON.stringify(logLevel)}: expected one of ${LOG_LEVELS.join(", ")}`);
|
|
134
135
|
if (filename !== void 0 && typeof filename !== "string" && typeof filename !== "function") throw new OptionValidationError("invalid filename: expected a string pattern or a function");
|
|
135
136
|
if (!Array.isArray(algorithms) || algorithms.length === 0) throw new OptionValidationError("invalid algorithms: expected a non-empty array");
|
|
@@ -141,6 +142,7 @@ function resolveOptions(options = {}) {
|
|
|
141
142
|
deleteOriginalAssets: Boolean(deleteOriginalAssets),
|
|
142
143
|
skipIfLargerOrEqual: Boolean(skipIfLargerOrEqual),
|
|
143
144
|
concurrency,
|
|
145
|
+
chunkSize,
|
|
144
146
|
logLevel,
|
|
145
147
|
enableInWatchMode: Boolean(enableInWatchMode)
|
|
146
148
|
};
|
|
@@ -206,8 +208,50 @@ function createCompressionPlugin(options) {
|
|
|
206
208
|
return;
|
|
207
209
|
}
|
|
208
210
|
const startedAt = performance.now();
|
|
209
|
-
const pending = [];
|
|
210
211
|
const processedSources = /* @__PURE__ */ new Set();
|
|
212
|
+
const failures = [];
|
|
213
|
+
const emittedBySource = /* @__PURE__ */ new Map();
|
|
214
|
+
const stats = /* @__PURE__ */ new Map();
|
|
215
|
+
let pending = [];
|
|
216
|
+
let pendingSourceBytes = 0;
|
|
217
|
+
const flush = async () => {
|
|
218
|
+
if (pending.length === 0) return;
|
|
219
|
+
const batch = pending;
|
|
220
|
+
pending = [];
|
|
221
|
+
pendingSourceBytes = 0;
|
|
222
|
+
const results = await compressBuffers(batch.map((artifact) => artifact.task), batch.map((artifact) => artifact.buffer), {
|
|
223
|
+
concurrency: options.concurrency,
|
|
224
|
+
skipIfLargerOrEqual: options.skipIfLargerOrEqual
|
|
225
|
+
});
|
|
226
|
+
for (const [index, result] of results.entries()) {
|
|
227
|
+
const artifact = batch[index];
|
|
228
|
+
if (artifact === void 0) continue;
|
|
229
|
+
if (result.error !== void 0 && result.error !== null) {
|
|
230
|
+
failures.push(`${result.fileName} (${result.algorithm}): ${result.error}`);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (result.skipped) {
|
|
234
|
+
logger.info(`skipped ${artifact.outputFileName}: ${result.algorithm} output would not be smaller than the original`);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
this.emitFile({
|
|
238
|
+
type: "asset",
|
|
239
|
+
fileName: artifact.outputFileName,
|
|
240
|
+
source: result.data
|
|
241
|
+
});
|
|
242
|
+
emittedNames.add(artifact.outputFileName);
|
|
243
|
+
emittedBySource.set(artifact.sourceFileName, (emittedBySource.get(artifact.sourceFileName) ?? 0) + 1);
|
|
244
|
+
const stat = stats.get(result.algorithm) ?? {
|
|
245
|
+
count: 0,
|
|
246
|
+
originalBytes: 0,
|
|
247
|
+
outputBytes: 0
|
|
248
|
+
};
|
|
249
|
+
stat.count += 1;
|
|
250
|
+
stat.originalBytes += result.originalSize;
|
|
251
|
+
stat.outputBytes += result.compressedSize;
|
|
252
|
+
stats.set(result.algorithm, stat);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
211
255
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
212
256
|
if (!options.filter(fileName)) continue;
|
|
213
257
|
if (COMPRESSED_EXTENSION_RE.test(fileName) || emittedNames.has(fileName)) continue;
|
|
@@ -229,43 +273,11 @@ function createCompressionPlugin(options) {
|
|
|
229
273
|
});
|
|
230
274
|
}
|
|
231
275
|
processedSources.add(fileName);
|
|
276
|
+
pendingSourceBytes += buffer.byteLength;
|
|
277
|
+
if (options.chunkSize > 0 && pendingSourceBytes >= options.chunkSize) await flush();
|
|
232
278
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
concurrency: options.concurrency,
|
|
236
|
-
skipIfLargerOrEqual: options.skipIfLargerOrEqual
|
|
237
|
-
});
|
|
238
|
-
const failures = [];
|
|
239
|
-
const emittedBySource = /* @__PURE__ */ new Map();
|
|
240
|
-
const stats = /* @__PURE__ */ new Map();
|
|
241
|
-
for (const [index, result] of results.entries()) {
|
|
242
|
-
const artifact = pending[index];
|
|
243
|
-
if (artifact === void 0) continue;
|
|
244
|
-
if (result.error !== void 0 && result.error !== null) {
|
|
245
|
-
failures.push(`${result.fileName} (${result.algorithm}): ${result.error}`);
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
if (result.skipped) {
|
|
249
|
-
logger.info(`skipped ${artifact.outputFileName}: ${result.algorithm} output would not be smaller than the original`);
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
this.emitFile({
|
|
253
|
-
type: "asset",
|
|
254
|
-
fileName: artifact.outputFileName,
|
|
255
|
-
source: result.data
|
|
256
|
-
});
|
|
257
|
-
emittedNames.add(artifact.outputFileName);
|
|
258
|
-
emittedBySource.set(artifact.sourceFileName, (emittedBySource.get(artifact.sourceFileName) ?? 0) + 1);
|
|
259
|
-
const stat = stats.get(result.algorithm) ?? {
|
|
260
|
-
count: 0,
|
|
261
|
-
originalBytes: 0,
|
|
262
|
-
outputBytes: 0
|
|
263
|
-
};
|
|
264
|
-
stat.count += 1;
|
|
265
|
-
stat.originalBytes += result.originalSize;
|
|
266
|
-
stat.outputBytes += result.compressedSize;
|
|
267
|
-
stats.set(result.algorithm, stat);
|
|
268
|
-
}
|
|
279
|
+
await flush();
|
|
280
|
+
if (processedSources.size === 0) return;
|
|
269
281
|
if (failures.length > 0) this.error(/* @__PURE__ */ new Error(`[${PLUGIN_NAME}] ${failures.length} compression task(s) failed:\n${failures.join("\n")}`));
|
|
270
282
|
if (options.deleteOriginalAssets) for (const fileName of processedSources) {
|
|
271
283
|
if ((emittedBySource.get(fileName) ?? 0) === 0) logger.warn(`deleteOriginalAssets removed "${fileName}" even though no compressed variant was emitted for it`);
|
package/dist/index.d.cts
CHANGED
|
@@ -69,6 +69,16 @@ interface CompressionOptions {
|
|
|
69
69
|
* @default 0
|
|
70
70
|
*/
|
|
71
71
|
concurrency?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Maximum number of source bytes buffered per native compression batch.
|
|
74
|
+
* `0` batches every asset into a single call. A positive value bounds the
|
|
75
|
+
* plugin's peak memory overhead to roughly one batch of source copies plus
|
|
76
|
+
* its compressed outputs; a single asset larger than `chunkSize` still
|
|
77
|
+
* forms its own batch. Note the bundler keeps the original bundle in
|
|
78
|
+
* memory regardless.
|
|
79
|
+
* @default 0
|
|
80
|
+
*/
|
|
81
|
+
chunkSize?: number;
|
|
72
82
|
/** @default 'info' */
|
|
73
83
|
logLevel?: LogLevel;
|
|
74
84
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -69,6 +69,16 @@ interface CompressionOptions {
|
|
|
69
69
|
* @default 0
|
|
70
70
|
*/
|
|
71
71
|
concurrency?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Maximum number of source bytes buffered per native compression batch.
|
|
74
|
+
* `0` batches every asset into a single call. A positive value bounds the
|
|
75
|
+
* plugin's peak memory overhead to roughly one batch of source copies plus
|
|
76
|
+
* its compressed outputs; a single asset larger than `chunkSize` still
|
|
77
|
+
* forms its own batch. Note the bundler keeps the original bundle in
|
|
78
|
+
* memory regardless.
|
|
79
|
+
* @default 0
|
|
80
|
+
*/
|
|
81
|
+
chunkSize?: number;
|
|
72
82
|
/** @default 'info' */
|
|
73
83
|
logLevel?: LogLevel;
|
|
74
84
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -103,9 +103,10 @@ function validateDefined(entry) {
|
|
|
103
103
|
/** Validate and normalize user options. Throws at `compression()` call time. */
|
|
104
104
|
function resolveOptions(options = {}) {
|
|
105
105
|
if (options === null || typeof options !== "object") throw new OptionValidationError("options must be an object");
|
|
106
|
-
const { include = DEFAULT_INCLUDE, exclude, threshold = 0, algorithms = ["gzip", "brotli"], filename, deleteOriginalAssets = false, skipIfLargerOrEqual = true, concurrency = 0, logLevel = "info", enableInWatchMode = false } = options;
|
|
106
|
+
const { include = DEFAULT_INCLUDE, exclude, threshold = 0, algorithms = ["gzip", "brotli"], filename, deleteOriginalAssets = false, skipIfLargerOrEqual = true, concurrency = 0, chunkSize = 0, logLevel = "info", enableInWatchMode = false } = options;
|
|
107
107
|
if (typeof threshold !== "number" || Number.isNaN(threshold) || threshold < 0) throw new OptionValidationError(`invalid threshold: expected a non-negative number, got ${JSON.stringify(threshold)}`);
|
|
108
108
|
if (!Number.isInteger(concurrency) || concurrency < 0) throw new OptionValidationError(`invalid concurrency: expected a non-negative integer, got ${JSON.stringify(concurrency)}`);
|
|
109
|
+
if (!Number.isInteger(chunkSize) || chunkSize < 0) throw new OptionValidationError(`invalid chunkSize: expected a non-negative integer number of bytes, got ${JSON.stringify(chunkSize)}`);
|
|
109
110
|
if (!LOG_LEVELS.includes(logLevel)) throw new OptionValidationError(`invalid logLevel ${JSON.stringify(logLevel)}: expected one of ${LOG_LEVELS.join(", ")}`);
|
|
110
111
|
if (filename !== void 0 && typeof filename !== "string" && typeof filename !== "function") throw new OptionValidationError("invalid filename: expected a string pattern or a function");
|
|
111
112
|
if (!Array.isArray(algorithms) || algorithms.length === 0) throw new OptionValidationError("invalid algorithms: expected a non-empty array");
|
|
@@ -117,6 +118,7 @@ function resolveOptions(options = {}) {
|
|
|
117
118
|
deleteOriginalAssets: Boolean(deleteOriginalAssets),
|
|
118
119
|
skipIfLargerOrEqual: Boolean(skipIfLargerOrEqual),
|
|
119
120
|
concurrency,
|
|
121
|
+
chunkSize,
|
|
120
122
|
logLevel,
|
|
121
123
|
enableInWatchMode: Boolean(enableInWatchMode)
|
|
122
124
|
};
|
|
@@ -182,8 +184,50 @@ function createCompressionPlugin(options) {
|
|
|
182
184
|
return;
|
|
183
185
|
}
|
|
184
186
|
const startedAt = performance.now();
|
|
185
|
-
const pending = [];
|
|
186
187
|
const processedSources = /* @__PURE__ */ new Set();
|
|
188
|
+
const failures = [];
|
|
189
|
+
const emittedBySource = /* @__PURE__ */ new Map();
|
|
190
|
+
const stats = /* @__PURE__ */ new Map();
|
|
191
|
+
let pending = [];
|
|
192
|
+
let pendingSourceBytes = 0;
|
|
193
|
+
const flush = async () => {
|
|
194
|
+
if (pending.length === 0) return;
|
|
195
|
+
const batch = pending;
|
|
196
|
+
pending = [];
|
|
197
|
+
pendingSourceBytes = 0;
|
|
198
|
+
const results = await compressBuffers(batch.map((artifact) => artifact.task), batch.map((artifact) => artifact.buffer), {
|
|
199
|
+
concurrency: options.concurrency,
|
|
200
|
+
skipIfLargerOrEqual: options.skipIfLargerOrEqual
|
|
201
|
+
});
|
|
202
|
+
for (const [index, result] of results.entries()) {
|
|
203
|
+
const artifact = batch[index];
|
|
204
|
+
if (artifact === void 0) continue;
|
|
205
|
+
if (result.error !== void 0 && result.error !== null) {
|
|
206
|
+
failures.push(`${result.fileName} (${result.algorithm}): ${result.error}`);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (result.skipped) {
|
|
210
|
+
logger.info(`skipped ${artifact.outputFileName}: ${result.algorithm} output would not be smaller than the original`);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
this.emitFile({
|
|
214
|
+
type: "asset",
|
|
215
|
+
fileName: artifact.outputFileName,
|
|
216
|
+
source: result.data
|
|
217
|
+
});
|
|
218
|
+
emittedNames.add(artifact.outputFileName);
|
|
219
|
+
emittedBySource.set(artifact.sourceFileName, (emittedBySource.get(artifact.sourceFileName) ?? 0) + 1);
|
|
220
|
+
const stat = stats.get(result.algorithm) ?? {
|
|
221
|
+
count: 0,
|
|
222
|
+
originalBytes: 0,
|
|
223
|
+
outputBytes: 0
|
|
224
|
+
};
|
|
225
|
+
stat.count += 1;
|
|
226
|
+
stat.originalBytes += result.originalSize;
|
|
227
|
+
stat.outputBytes += result.compressedSize;
|
|
228
|
+
stats.set(result.algorithm, stat);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
187
231
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
188
232
|
if (!options.filter(fileName)) continue;
|
|
189
233
|
if (COMPRESSED_EXTENSION_RE.test(fileName) || emittedNames.has(fileName)) continue;
|
|
@@ -205,43 +249,11 @@ function createCompressionPlugin(options) {
|
|
|
205
249
|
});
|
|
206
250
|
}
|
|
207
251
|
processedSources.add(fileName);
|
|
252
|
+
pendingSourceBytes += buffer.byteLength;
|
|
253
|
+
if (options.chunkSize > 0 && pendingSourceBytes >= options.chunkSize) await flush();
|
|
208
254
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
concurrency: options.concurrency,
|
|
212
|
-
skipIfLargerOrEqual: options.skipIfLargerOrEqual
|
|
213
|
-
});
|
|
214
|
-
const failures = [];
|
|
215
|
-
const emittedBySource = /* @__PURE__ */ new Map();
|
|
216
|
-
const stats = /* @__PURE__ */ new Map();
|
|
217
|
-
for (const [index, result] of results.entries()) {
|
|
218
|
-
const artifact = pending[index];
|
|
219
|
-
if (artifact === void 0) continue;
|
|
220
|
-
if (result.error !== void 0 && result.error !== null) {
|
|
221
|
-
failures.push(`${result.fileName} (${result.algorithm}): ${result.error}`);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (result.skipped) {
|
|
225
|
-
logger.info(`skipped ${artifact.outputFileName}: ${result.algorithm} output would not be smaller than the original`);
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
this.emitFile({
|
|
229
|
-
type: "asset",
|
|
230
|
-
fileName: artifact.outputFileName,
|
|
231
|
-
source: result.data
|
|
232
|
-
});
|
|
233
|
-
emittedNames.add(artifact.outputFileName);
|
|
234
|
-
emittedBySource.set(artifact.sourceFileName, (emittedBySource.get(artifact.sourceFileName) ?? 0) + 1);
|
|
235
|
-
const stat = stats.get(result.algorithm) ?? {
|
|
236
|
-
count: 0,
|
|
237
|
-
originalBytes: 0,
|
|
238
|
-
outputBytes: 0
|
|
239
|
-
};
|
|
240
|
-
stat.count += 1;
|
|
241
|
-
stat.originalBytes += result.originalSize;
|
|
242
|
-
stat.outputBytes += result.compressedSize;
|
|
243
|
-
stats.set(result.algorithm, stat);
|
|
244
|
-
}
|
|
255
|
+
await flush();
|
|
256
|
+
if (processedSources.size === 0) return;
|
|
245
257
|
if (failures.length > 0) this.error(/* @__PURE__ */ new Error(`[${PLUGIN_NAME}] ${failures.length} compression task(s) failed:\n${failures.join("\n")}`));
|
|
246
258
|
if (options.deleteOriginalAssets) for (const fileName of processedSources) {
|
|
247
259
|
if ((emittedBySource.get(fileName) ?? 0) === 0) logger.warn(`deleteOriginalAssets removed "${fileName}" even though no compressed variant was emitted for it`);
|
package/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('@medicomind/rolldown-compression-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
80
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('@medicomind/rolldown-compression-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
96
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('@medicomind/rolldown-compression-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
117
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('@medicomind/rolldown-compression-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
133
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('@medicomind/rolldown-compression-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
150
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('@medicomind/rolldown-compression-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
166
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('@medicomind/rolldown-compression-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
185
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('@medicomind/rolldown-compression-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
201
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('@medicomind/rolldown-compression-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
217
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('@medicomind/rolldown-compression-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
237
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('@medicomind/rolldown-compression-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
253
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('@medicomind/rolldown-compression-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
274
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('@medicomind/rolldown-compression-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
290
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('@medicomind/rolldown-compression-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
308
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('@medicomind/rolldown-compression-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
324
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('@medicomind/rolldown-compression-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
342
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('@medicomind/rolldown-compression-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
358
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('@medicomind/rolldown-compression-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
376
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('@medicomind/rolldown-compression-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
392
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('@medicomind/rolldown-compression-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
410
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('@medicomind/rolldown-compression-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
426
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('@medicomind/rolldown-compression-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
443
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('@medicomind/rolldown-compression-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
459
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('@medicomind/rolldown-compression-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
479
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('@medicomind/rolldown-compression-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
495
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('@medicomind/rolldown-compression-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('@medicomind/rolldown-compression-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
511
|
+
if (bindingPackageVersion !== '0.3.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medicomind/rolldown-compression",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Fast native (Rust) gzip / brotli / zstd compression plugin for Rolldown, powered by napi-rs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rolldown",
|
|
@@ -82,6 +82,14 @@
|
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"rolldown": "^1.0.0"
|
|
84
84
|
},
|
|
85
|
+
"optionalDependencies": {
|
|
86
|
+
"@medicomind/rolldown-compression-darwin-arm64": "0.3.4",
|
|
87
|
+
"@medicomind/rolldown-compression-darwin-x64": "0.3.4",
|
|
88
|
+
"@medicomind/rolldown-compression-linux-arm64-gnu": "0.3.4",
|
|
89
|
+
"@medicomind/rolldown-compression-linux-x64-gnu": "0.3.4",
|
|
90
|
+
"@medicomind/rolldown-compression-linux-x64-musl": "0.3.4",
|
|
91
|
+
"@medicomind/rolldown-compression-win32-x64-msvc": "0.3.4"
|
|
92
|
+
},
|
|
85
93
|
"devDependencies": {
|
|
86
94
|
"@biomejs/biome": "^2.5.3",
|
|
87
95
|
"@changesets/changelog-github": "^0.7.0",
|