Skip to content

Commit ffc1e55

Browse files
authored
feat!: drop node 18 support, drop CJS build (#558)
* feat!: drop node 18 support, drop CJS build Requires Node.js version 20.19.0, 22.12.0, or later. * fix
1 parent 2138298 commit ffc1e55

File tree

13 files changed

+190
-312
lines changed

13 files changed

+190
-312
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,8 @@ on:
1010
- main
1111
- 'v*'
1212

13-
jobs:
14-
lint:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19-
20-
- name: Install pnpm
21-
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
22-
23-
- name: Setup node
24-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
25-
with:
26-
node-version: lts/*
27-
cache: pnpm
28-
29-
- run: pnpm install
30-
- run: pnpm run lint
31-
- run: pnpm run typecheck
32-
33-
ci:
34-
runs-on: ${{ matrix.os }}
35-
36-
strategy:
37-
matrix:
38-
os: [ubuntu-latest, macos-latest, windows-latest]
39-
node: [18, 20, 22, 24]
40-
fail-fast: false
13+
permissions: {}
4114

42-
steps:
43-
- name: Checkout
44-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
45-
with:
46-
persist-credentials: false
47-
48-
- name: Install pnpm
49-
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
50-
51-
- name: Set node version to ${{ matrix.node }}
52-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
53-
with:
54-
node-version: ${{ matrix.node }}
55-
cache: pnpm
56-
57-
- name: Install
58-
run: pnpm install
59-
60-
- name: Build
61-
run: pnpm run build
62-
63-
- name: Test
64-
run: pnpm run test
15+
jobs:
16+
unit-test:
17+
uses: sxzz/workflows/.github/workflows/unit-test.yml@v1

docs/.vitepress/data/gen-files.ts

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Repository } from './repository.data'
1+
import type { Repository } from './repository.data.ts'
22
import { writeFileSync } from 'node:fs'
33
import { dirname, join } from 'node:path'
44
import { env } from 'node:process'
55
import { fileURLToPath } from 'node:url'
66
import { consola } from 'consola'
77
import { $fetch } from 'ofetch'
8-
import { repositoryMeta } from './meta'
8+
import { repositoryMeta } from './meta.ts'
99
import 'dotenv/config'
1010

1111
const GITHUB_TOKEN = env.GITHUB_TOKEN
@@ -35,6 +35,47 @@ query repositoryQuery($owner: String!, $name: String!, $readme: String!) {
3535
}
3636
}`
3737

38+
if (!GITHUB_TOKEN) {
39+
consola.error('GITHUB_TOKEN is missing, please refer to https://github.com/unjs/unplugin/blob/main/docs/README.md#development')
40+
process.exit(1)
41+
}
42+
43+
const fetchs = repositoryMeta.map((repository) => {
44+
return fetchRepo({
45+
name: repository.name,
46+
owner: repository.owner,
47+
readme: repository.defaultBranch ? `${repository.defaultBranch}:README.md` : 'main:README.md',
48+
})
49+
})
50+
51+
Promise.allSettled(fetchs).then((res) => {
52+
const repoMeta = res?.map((item) => {
53+
if (item.status === 'fulfilled') {
54+
return {
55+
name: item.value?.name,
56+
stargazers: item.value?.stargazers,
57+
owner: item.value?.owner,
58+
description: item.value?.description,
59+
url: item.value?.url,
60+
isTemplate: item.value?.isTemplate,
61+
primaryLanguage: item.value?.primaryLanguage,
62+
forkCount: item.value?.forkCount,
63+
}
64+
}
65+
66+
return null
67+
})?.filter(item => item && item.name)
68+
69+
writeFileSync(
70+
join(dirname(fileURLToPath(import.meta.url)), './repository.json'),
71+
JSON.stringify(repoMeta, null, 2),
72+
)
73+
consola.success('[repository.json] generate success!')
74+
consola.success('All files generate done!')
75+
}).catch((error) => {
76+
consola.error(error)
77+
})
78+
3879
async function fetchRepo(meta: {
3980
owner: string
4081
name: string
@@ -88,48 +129,3 @@ outline: deep
88129
consola.error(`[${name}.md]: generate failed: ${error}`)
89130
}
90131
}
91-
92-
function main() {
93-
if (!GITHUB_TOKEN) {
94-
consola.error('GITHUB_TOKEN is missing, please refer to https://github.com/unjs/unplugin/blob/main/docs/README.md#development')
95-
return false
96-
}
97-
98-
const fetchs = repositoryMeta.map((repository) => {
99-
return fetchRepo({
100-
name: repository.name,
101-
owner: repository.owner,
102-
readme: repository.defaultBranch ? `${repository.defaultBranch}:README.md` : 'main:README.md',
103-
})
104-
})
105-
106-
Promise.allSettled(fetchs).then((res) => {
107-
const repoMeta = res?.map((item) => {
108-
if (item.status === 'fulfilled') {
109-
return {
110-
name: item.value?.name,
111-
stargazers: item.value?.stargazers,
112-
owner: item.value?.owner,
113-
description: item.value?.description,
114-
url: item.value?.url,
115-
isTemplate: item.value?.isTemplate,
116-
primaryLanguage: item.value?.primaryLanguage,
117-
forkCount: item.value?.forkCount,
118-
}
119-
}
120-
121-
return null
122-
})?.filter(item => item && item.name)
123-
124-
writeFileSync(
125-
join(dirname(fileURLToPath(import.meta.url)), './repository.json'),
126-
JSON.stringify(repoMeta, null, 2),
127-
)
128-
consola.success('[repository.json] generate success!')
129-
consola.success('All files generate done!')
130-
}).catch((error) => {
131-
consola.error(error)
132-
})
133-
}
134-
135-
main()

docs/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"node": ">=18.19.0"
77
},
88
"scripts": {
9-
"gen-files": "tsx ./.vitepress/data/gen-files.ts",
9+
"gen-files": "node ./.vitepress/data/gen-files.ts",
1010
"dev": "vitepress dev --open",
1111
"build": "pnpm gen-files && vitepress build",
1212
"lint": "case-police '**/*.md'",
@@ -21,7 +21,6 @@
2121
"markdown-it": "catalog:docs",
2222
"markdown-it-github-alerts": "catalog:docs",
2323
"ofetch": "catalog:docs",
24-
"tsx": "catalog:docs",
2524
"unocss": "catalog:docs",
2625
"unplugin": "workspace:*",
2726
"unplugin-icons": "catalog:docs",

package.json

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
},
1313
"sideEffects": false,
1414
"exports": {
15-
".": {
16-
"import": "./dist/index.js",
17-
"require": "./dist/index.cjs"
18-
},
19-
"./dist/webpack/loaders/*": "./dist/webpack/loaders/*.cjs",
20-
"./dist/rspack/loaders/*": "./dist/rspack/loaders/*.cjs"
15+
".": "./dist/index.mjs",
16+
"./rspack/loaders/load": "./dist/rspack/loaders/load.mjs",
17+
"./rspack/loaders/transform": "./dist/rspack/loaders/transform.mjs",
18+
"./webpack/loaders/load": "./dist/webpack/loaders/load.mjs",
19+
"./webpack/loaders/transform": "./dist/webpack/loaders/transform.mjs",
20+
"./package.json": "./package.json"
2121
},
22-
"main": "dist/index.js",
23-
"module": "dist/index.js",
24-
"types": "dist/index.d.ts",
22+
"main": "./dist/index.mjs",
23+
"module": "./dist/index.mjs",
24+
"types": "./dist/index.d.mts",
2525
"files": [
2626
"dist"
2727
],
2828
"engines": {
29-
"node": ">=18.12.0"
29+
"node": "^20.19.0 || >=22.12.0"
3030
},
3131
"scripts": {
3232
"build": "tsdown",
@@ -39,7 +39,7 @@
3939
"docs:gen-files": "pnpm -C docs run gen-files",
4040
"prepublishOnly": "nr build",
4141
"release": "bumpp",
42-
"test": "nr test:build && vitest run --pool=forks",
42+
"test": "nr test:build && vitest run",
4343
"test:build": "jiti scripts/buildFixtures.ts"
4444
},
4545
"dependencies": {
@@ -51,42 +51,38 @@
5151
"devDependencies": {
5252
"@antfu/eslint-config": "catalog:",
5353
"@antfu/ni": "catalog:",
54-
"@farmfe/cli": "catalog:",
55-
"@farmfe/core": "catalog:",
56-
"@rspack/cli": "catalog:",
57-
"@rspack/core": "catalog:",
58-
"@types/fs-extra": "catalog:",
54+
"@farmfe/cli": "catalog:test",
55+
"@farmfe/core": "catalog:peer",
56+
"@rspack/cli": "catalog:test",
57+
"@rspack/core": "catalog:peer",
5958
"@types/node": "catalog:",
6059
"@types/picomatch": "catalog:",
6160
"ansis": "catalog:",
6261
"bumpp": "catalog:",
6362
"esbuild": "catalog:",
64-
"esbuild-plugin-copy": "catalog:",
6563
"eslint": "catalog:",
6664
"eslint-plugin-format": "catalog:",
67-
"fast-glob": "catalog:",
68-
"fs-extra": "catalog:",
69-
"jiti": "catalog:",
65+
"jiti": "catalog:default",
7066
"lint-staged": "catalog:",
71-
"magic-string": "catalog:",
72-
"rolldown": "catalog:",
73-
"rollup": "catalog:",
67+
"magic-string": "catalog:test",
68+
"rolldown": "catalog:peer",
69+
"rollup": "catalog:peer",
7470
"simple-git-hooks": "catalog:",
7571
"tsdown": "catalog:",
7672
"typescript": "catalog:",
77-
"unloader": "catalog:",
73+
"unloader": "catalog:peer",
7874
"unplugin": "workspace:*",
7975
"unplugin-unused": "catalog:",
80-
"vite": "catalog:",
81-
"vitest": "catalog:",
82-
"webpack": "catalog:",
83-
"webpack-cli": "catalog:"
76+
"vite": "catalog:peer",
77+
"vitest": "catalog:test",
78+
"webpack": "catalog:peer",
79+
"webpack-cli": "catalog:test"
8480
},
8581
"resolutions": {
8682
"esbuild": "catalog:"
8783
},
8884
"simple-git-hooks": {
89-
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
85+
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && pnpm exec lint-staged"
9086
},
9187
"lint-staged": {
9288
"*": "eslint --fix"

0 commit comments

Comments
 (0)