Skip to content

Commit abe415d

Browse files
committed
test: add node 18
1 parent 92108d2 commit abe415d

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

.github/workflows/unit-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node-version: ['14.17', '16']
18+
node-version: ['14.17', 'lts/*', '18']
1919

2020
steps:
2121
- uses: actions/checkout@v3

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@types/sharp": "^0.30.2",
5959
"@vitest/ui": "^0.10.0",
6060
"bumpp": "^7.1.1",
61+
"compare-versions": "^4.1.3",
6162
"dayjs": "^1.11.1",
6263
"esbuild": "^0.14.38",
6364
"eslint": "^8.14.0",
@@ -67,6 +68,7 @@
6768
"ky": "^0.30.0",
6869
"md5": "^2.3.0",
6970
"node-fetch": "3.2.3",
71+
"rollup": "^2.70.2",
7072
"rollup-plugin-esbuild": "^4.9.1",
7173
"serve": "^13.0.2",
7274
"sharp": "^0.30.4",

pnpm-lock.yaml

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

vitest.config.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
import { defineConfig } from 'vitest/config'
22
import esbuild from 'rollup-plugin-esbuild'
3+
import compareVersions from 'compare-versions'
4+
import type { Plugin } from 'rollup'
5+
6+
const FetchPolyfill: Plugin = {
7+
name: 'FetchPloyfill',
8+
transform(code, id) {
9+
if (!id.endsWith('src/request.ts')) return
10+
return `import './node-shim'; ${code}`
11+
},
12+
}
13+
14+
const plugins: Plugin[] = [esbuild({ target: 'node14' })]
15+
16+
// Enable ployfill when node < 18
17+
if (compareVersions.compare(process.version, '18', '<'))
18+
plugins.push(FetchPolyfill)
319

420
export default defineConfig({
5-
plugins: [
6-
esbuild({ target: 'node14' }),
7-
{
8-
name: 'FetchPloyfill',
9-
transform(code, id) {
10-
if (!id.endsWith('src/request.ts')) return
11-
return `import './node-shim'; ${code}`
12-
},
13-
},
14-
],
21+
plugins,
1522
})

0 commit comments

Comments
 (0)