Skip to content

Commit a6ac4f3

Browse files
committed
feat: support zstd
1 parent 810e167 commit a6ac4f3

File tree

9 files changed

+106
-54
lines changed

9 files changed

+106
-54
lines changed

.github/workflows/test.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
version: [22.3, 23.8, 24.0]
10+
os: [ubuntu-latest, macos-latest, windows-latest]
11+
runs-on: ${{ matrix.os }}
812
steps:
913
- uses: actions/checkout@v4
1014
- uses: actions/setup-node@v4
1115
with:
12-
node-version: 22.3
16+
node-version: ${{ matrix.version }}
1317
- name: Build Library
1418
run: make bootstrap
1519
- name: Run Test

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.3.0
1+
v24.2.0

__tests__/major.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,18 @@ describe('compression plugin', () => {
172172
assert(result1.length === result2.length)
173173
})
174174
})
175+
it('zstd version v23.8.0 and v22.15.0', async () => {
176+
const p = compression({ include: /\.(js)$/, algorithms: ['zstd'] })
177+
const [major, minor] = process.versions.node.split('.').map((s) => +s)
178+
if ((+major === 23 && +minor < 8) || (+major < 22 || (+major === 22 && +minor < 15))) {
179+
expect(() => p).toThrowError(
180+
`Node.js ${process.versions.node} does not support zstd compression. ` +
181+
`Requires Node.js >= 22.15.0 or >= 23.8.0`
182+
)
183+
} else {
184+
expect(defineAlgorithm('zstd')).toHaveLength(2)
185+
const { output } = await mockBuild('normal', root, { plugins: [p] })
186+
expect((await readAll(output)).filter((s) => s.endsWith('.zst')).length).toBe(1)
187+
}
188+
})
175189
})

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vite-plugin-compression2",
33
"version": "2.0.1",
4-
"packageManager": "pnpm@9.4.0",
4+
"packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac",
55
"description": "a fast vite compression plugin",
66
"main": "dist/index.js",
77
"types": "dist/index.d.ts",
@@ -41,7 +41,7 @@
4141
"@rollup/plugin-esm-shim": "^0.1.8",
4242
"@rollup/plugin-node-resolve": "^16.0.1",
4343
"@swc/core": "^1.11.31",
44-
"@types/node": "^20.14.9",
44+
"@types/node": "^24.0.3",
4545
"@vitest/coverage-v8": "^2.0.3",
4646
"ansis": "^4.0.0",
4747
"dprint": "^0.46.3",

pnpm-lock.yaml

Lines changed: 43 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
packages:
22
- examples/**/*
33
- e2e/**/*
4+
5+
onlyBuiltDependencies:
6+
- "@swc/core"
7+
- "dprint"
8+
- "esbuild"

0 commit comments

Comments
 (0)