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
This commit is contained in:
Kevin Deng 2025-11-03 17:52:18 +08:00 committed by GitHub
parent 213829882e
commit ffc1e55446
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 190 additions and 312 deletions

View File

@ -10,55 +10,8 @@ on:
- main
- 'v*'
permissions: {}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup node
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: lts/*
cache: pnpm
- run: pnpm install
- run: pnpm run lint
- run: pnpm run typecheck
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [18, 20, 22, 24]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Set node version to ${{ matrix.node }}
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Install
run: pnpm install
- name: Build
run: pnpm run build
- name: Test
run: pnpm run test
unit-test:
uses: sxzz/workflows/.github/workflows/unit-test.yml@v1

View File

@ -1,11 +1,11 @@
import type { Repository } from './repository.data'
import type { Repository } from './repository.data.ts'
import { writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { env } from 'node:process'
import { fileURLToPath } from 'node:url'
import { consola } from 'consola'
import { $fetch } from 'ofetch'
import { repositoryMeta } from './meta'
import { repositoryMeta } from './meta.ts'
import 'dotenv/config'
const GITHUB_TOKEN = env.GITHUB_TOKEN
@ -35,6 +35,47 @@ query repositoryQuery($owner: String!, $name: String!, $readme: String!) {
}
}`
if (!GITHUB_TOKEN) {
consola.error('GITHUB_TOKEN is missing, please refer to https://github.com/unjs/unplugin/blob/main/docs/README.md#development')
process.exit(1)
}
const fetchs = repositoryMeta.map((repository) => {
return fetchRepo({
name: repository.name,
owner: repository.owner,
readme: repository.defaultBranch ? `${repository.defaultBranch}:README.md` : 'main:README.md',
})
})
Promise.allSettled(fetchs).then((res) => {
const repoMeta = res?.map((item) => {
if (item.status === 'fulfilled') {
return {
name: item.value?.name,
stargazers: item.value?.stargazers,
owner: item.value?.owner,
description: item.value?.description,
url: item.value?.url,
isTemplate: item.value?.isTemplate,
primaryLanguage: item.value?.primaryLanguage,
forkCount: item.value?.forkCount,
}
}
return null
})?.filter(item => item && item.name)
writeFileSync(
join(dirname(fileURLToPath(import.meta.url)), './repository.json'),
JSON.stringify(repoMeta, null, 2),
)
consola.success('[repository.json] generate success!')
consola.success('All files generate done!')
}).catch((error) => {
consola.error(error)
})
async function fetchRepo(meta: {
owner: string
name: string
@ -88,48 +129,3 @@ outline: deep
consola.error(`[${name}.md]: generate failed: ${error}`)
}
}
function main() {
if (!GITHUB_TOKEN) {
consola.error('GITHUB_TOKEN is missing, please refer to https://github.com/unjs/unplugin/blob/main/docs/README.md#development')
return false
}
const fetchs = repositoryMeta.map((repository) => {
return fetchRepo({
name: repository.name,
owner: repository.owner,
readme: repository.defaultBranch ? `${repository.defaultBranch}:README.md` : 'main:README.md',
})
})
Promise.allSettled(fetchs).then((res) => {
const repoMeta = res?.map((item) => {
if (item.status === 'fulfilled') {
return {
name: item.value?.name,
stargazers: item.value?.stargazers,
owner: item.value?.owner,
description: item.value?.description,
url: item.value?.url,
isTemplate: item.value?.isTemplate,
primaryLanguage: item.value?.primaryLanguage,
forkCount: item.value?.forkCount,
}
}
return null
})?.filter(item => item && item.name)
writeFileSync(
join(dirname(fileURLToPath(import.meta.url)), './repository.json'),
JSON.stringify(repoMeta, null, 2),
)
consola.success('[repository.json] generate success!')
consola.success('All files generate done!')
}).catch((error) => {
consola.error(error)
})
}
main()

View File

@ -6,7 +6,7 @@
"node": ">=18.19.0"
},
"scripts": {
"gen-files": "tsx ./.vitepress/data/gen-files.ts",
"gen-files": "node ./.vitepress/data/gen-files.ts",
"dev": "vitepress dev --open",
"build": "pnpm gen-files && vitepress build",
"lint": "case-police '**/*.md'",
@ -21,7 +21,6 @@
"markdown-it": "catalog:docs",
"markdown-it-github-alerts": "catalog:docs",
"ofetch": "catalog:docs",
"tsx": "catalog:docs",
"unocss": "catalog:docs",
"unplugin": "workspace:*",
"unplugin-icons": "catalog:docs",

View File

@ -12,21 +12,21 @@
},
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./dist/webpack/loaders/*": "./dist/webpack/loaders/*.cjs",
"./dist/rspack/loaders/*": "./dist/rspack/loaders/*.cjs"
".": "./dist/index.mjs",
"./rspack/loaders/load": "./dist/rspack/loaders/load.mjs",
"./rspack/loaders/transform": "./dist/rspack/loaders/transform.mjs",
"./webpack/loaders/load": "./dist/webpack/loaders/load.mjs",
"./webpack/loaders/transform": "./dist/webpack/loaders/transform.mjs",
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"files": [
"dist"
],
"engines": {
"node": ">=18.12.0"
"node": "^20.19.0 || >=22.12.0"
},
"scripts": {
"build": "tsdown",
@ -39,7 +39,7 @@
"docs:gen-files": "pnpm -C docs run gen-files",
"prepublishOnly": "nr build",
"release": "bumpp",
"test": "nr test:build && vitest run --pool=forks",
"test": "nr test:build && vitest run",
"test:build": "jiti scripts/buildFixtures.ts"
},
"dependencies": {
@ -51,42 +51,38 @@
"devDependencies": {
"@antfu/eslint-config": "catalog:",
"@antfu/ni": "catalog:",
"@farmfe/cli": "catalog:",
"@farmfe/core": "catalog:",
"@rspack/cli": "catalog:",
"@rspack/core": "catalog:",
"@types/fs-extra": "catalog:",
"@farmfe/cli": "catalog:test",
"@farmfe/core": "catalog:peer",
"@rspack/cli": "catalog:test",
"@rspack/core": "catalog:peer",
"@types/node": "catalog:",
"@types/picomatch": "catalog:",
"ansis": "catalog:",
"bumpp": "catalog:",
"esbuild": "catalog:",
"esbuild-plugin-copy": "catalog:",
"eslint": "catalog:",
"eslint-plugin-format": "catalog:",
"fast-glob": "catalog:",
"fs-extra": "catalog:",
"jiti": "catalog:",
"jiti": "catalog:default",
"lint-staged": "catalog:",
"magic-string": "catalog:",
"rolldown": "catalog:",
"rollup": "catalog:",
"magic-string": "catalog:test",
"rolldown": "catalog:peer",
"rollup": "catalog:peer",
"simple-git-hooks": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:",
"unloader": "catalog:",
"unloader": "catalog:peer",
"unplugin": "workspace:*",
"unplugin-unused": "catalog:",
"vite": "catalog:",
"vitest": "catalog:",
"webpack": "catalog:",
"webpack-cli": "catalog:"
"vite": "catalog:peer",
"vitest": "catalog:test",
"webpack": "catalog:peer",
"webpack-cli": "catalog:test"
},
"resolutions": {
"esbuild": "catalog:"
},
"simple-git-hooks": {
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && pnpm exec lint-staged"
},
"lint-staged": {
"*": "eslint --fix"

169
pnpm-lock.yaml generated
View File

@ -12,21 +12,6 @@ catalogs:
'@antfu/ni':
specifier: ^27.0.1
version: 27.0.1
'@farmfe/cli':
specifier: ^1.0.5
version: 1.0.5
'@farmfe/core':
specifier: ^1.7.11
version: 1.7.11
'@rspack/cli':
specifier: ^1.6.0
version: 1.6.0
'@rspack/core':
specifier: ^1.6.0
version: 1.6.0
'@types/fs-extra':
specifier: ^11.0.4
version: 11.0.4
'@types/node':
specifier: ^24.10.0
version: 24.10.0
@ -39,36 +24,18 @@ catalogs:
bumpp:
specifier: ^10.3.1
version: 10.3.1
esbuild-plugin-copy:
specifier: ^2.1.1
version: 2.1.1
eslint:
specifier: ^9.39.0
version: 9.39.0
eslint-plugin-format:
specifier: ^1.0.2
version: 1.0.2
fast-glob:
specifier: ^3.3.3
version: 3.3.3
fs-extra:
specifier: ^11.3.2
version: 11.3.2
jiti:
specifier: ^2.6.1
version: 2.6.1
lint-staged:
specifier: ^16.2.6
version: 16.2.6
magic-string:
specifier: ^0.30.21
version: 0.30.21
rolldown:
specifier: ^1.0.0-beta.46
version: 1.0.0-beta.46
rollup:
specifier: ^4.52.5
version: 4.52.5
simple-git-hooks:
specifier: ^2.13.1
version: 2.13.1
@ -78,24 +45,9 @@ catalogs:
typescript:
specifier: ~5.9.3
version: 5.9.3
unloader:
specifier: ^0.5.0
version: 0.5.0
unplugin-unused:
specifier: ^0.5.5
version: 0.5.5
vite:
specifier: ^7.1.12
version: 7.1.12
vitest:
specifier: ^4.0.6
version: 4.0.6
webpack:
specifier: ^5.102.1
version: 5.102.1
webpack-cli:
specifier: ^6.0.1
version: 6.0.1
docs:
'@iconify-json/ri':
specifier: ^1.2.6
@ -121,9 +73,6 @@ catalogs:
ofetch:
specifier: ^1.5.1
version: 1.5.1
tsx:
specifier: ^4.20.6
version: 4.20.6
unocss:
specifier: ^66.5.4
version: 66.5.4
@ -145,6 +94,28 @@ catalogs:
vue-tsc:
specifier: ^3.1.3
version: 3.1.3
peer:
'@farmfe/core':
specifier: ^1.7.11
version: 1.7.11
'@rspack/core':
specifier: ^1.6.0
version: 1.6.0
rolldown:
specifier: ^1.0.0-beta.46
version: 1.0.0-beta.46
rollup:
specifier: ^4.52.5
version: 4.52.5
unloader:
specifier: ^0.5.0
version: 0.5.0
vite:
specifier: ^7.1.12
version: 7.1.12
webpack:
specifier: ^5.102.1
version: 5.102.1
prod:
'@jridgewell/remapping':
specifier: ^2.3.5
@ -158,6 +129,22 @@ catalogs:
webpack-virtual-modules:
specifier: ^0.6.2
version: 0.6.2
test:
'@farmfe/cli':
specifier: ^1.0.5
version: 1.0.5
'@rspack/cli':
specifier: ^1.6.0
version: 1.6.0
magic-string:
specifier: ^0.30.21
version: 0.30.21
vitest:
specifier: ^4.0.6
version: 4.0.6
webpack-cli:
specifier: ^6.0.1
version: 6.0.1
overrides:
esbuild: ^0.25.12
@ -186,20 +173,17 @@ importers:
specifier: 'catalog:'
version: 27.0.1
'@farmfe/cli':
specifier: 'catalog:'
specifier: catalog:test
version: 1.0.5
'@farmfe/core':
specifier: 'catalog:'
specifier: catalog:peer
version: 1.7.11(@types/node@24.10.0)
'@rspack/cli':
specifier: 'catalog:'
specifier: catalog:test
version: 1.6.0(@rspack/core@1.6.0(@swc/helpers@0.5.17))(@types/express@4.17.25)(webpack-cli@6.0.1)(webpack@5.102.1)
'@rspack/core':
specifier: 'catalog:'
specifier: catalog:peer
version: 1.6.0(@swc/helpers@0.5.17)
'@types/fs-extra':
specifier: 'catalog:'
version: 11.0.4
'@types/node':
specifier: 'catalog:'
version: 24.10.0
@ -215,35 +199,26 @@ importers:
esbuild:
specifier: ^0.25.12
version: 0.25.12
esbuild-plugin-copy:
specifier: 'catalog:'
version: 2.1.1(esbuild@0.25.12)
eslint:
specifier: 'catalog:'
version: 9.39.0(jiti@2.6.1)
eslint-plugin-format:
specifier: 'catalog:'
version: 1.0.2(eslint@9.39.0(jiti@2.6.1))
fast-glob:
specifier: 'catalog:'
version: 3.3.3
fs-extra:
specifier: 'catalog:'
version: 11.3.2
jiti:
specifier: 'catalog:'
specifier: catalog:default
version: 2.6.1
lint-staged:
specifier: 'catalog:'
version: 16.2.6
magic-string:
specifier: 'catalog:'
specifier: catalog:test
version: 0.30.21
rolldown:
specifier: 'catalog:'
specifier: catalog:peer
version: 1.0.0-beta.46
rollup:
specifier: 'catalog:'
specifier: catalog:peer
version: 4.52.5
simple-git-hooks:
specifier: 'catalog:'
@ -255,7 +230,7 @@ importers:
specifier: 'catalog:'
version: 5.9.3
unloader:
specifier: 'catalog:'
specifier: catalog:peer
version: 0.5.0
unplugin:
specifier: workspace:*
@ -264,16 +239,16 @@ importers:
specifier: 'catalog:'
version: 0.5.5
vite:
specifier: 'catalog:'
specifier: catalog:peer
version: 7.1.12(@types/node@24.10.0)(jiti@2.6.1)(terser@5.44.0)(tsx@4.20.6)(yaml@2.8.1)
vitest:
specifier: 'catalog:'
specifier: catalog:test
version: 4.0.6(@types/debug@4.1.12)(@types/node@24.10.0)(jiti@2.6.1)(terser@5.44.0)(tsx@4.20.6)(yaml@2.8.1)
webpack:
specifier: 'catalog:'
specifier: catalog:peer
version: 5.102.1(esbuild@0.25.12)(webpack-cli@6.0.1)
webpack-cli:
specifier: 'catalog:'
specifier: catalog:test
version: 6.0.1(webpack@5.102.1)
docs:
@ -302,9 +277,6 @@ importers:
ofetch:
specifier: catalog:docs
version: 1.5.1
tsx:
specifier: catalog:docs
version: 4.20.6
unocss:
specifier: catalog:docs
version: 66.5.4(postcss@8.5.6)(vite@7.1.12(@types/node@24.10.0)(jiti@2.6.1)(terser@5.44.0)(tsx@4.20.6)(yaml@2.8.1))
@ -1473,9 +1445,6 @@ packages:
'@types/express@4.17.25':
resolution: {integrity: sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw==}
'@types/fs-extra@11.0.4':
resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==}
'@types/hast@3.0.4':
resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==}
@ -1488,9 +1457,6 @@ packages:
'@types/json-schema@7.0.15':
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
'@types/jsonfile@6.1.4':
resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==}
'@types/linkify-it@5.0.0':
resolution: {integrity: sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==}
@ -2596,11 +2562,6 @@ packages:
resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
engines: {node: '>= 0.4'}
esbuild-plugin-copy@2.1.1:
resolution: {integrity: sha512-Bk66jpevTcV8KMFzZI1P7MZKZ+uDcrZm2G2egZ2jNIvVnivDpodZI+/KnpL3Jnap0PBdIHU7HwFGB8r+vV5CVw==}
peerDependencies:
esbuild: ^0.25.12
esbuild@0.25.12:
resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==}
engines: {node: '>=18'}
@ -3070,10 +3031,6 @@ packages:
resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==}
engines: {node: '>= 0.6'}
fs-extra@10.1.0:
resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==}
engines: {node: '>=12'}
fs-extra@11.3.2:
resolution: {integrity: sha512-Xr9F6z6up6Ws+NjzMCZc6WXg2YFRlrLP9NQDO3VQrWrfiojdhS56TzueT88ze0uBdCTwEIhQ3ptnmKeWGFAe0A==}
engines: {node: '>=14.14'}
@ -6435,11 +6392,6 @@ snapshots:
'@types/qs': 6.14.0
'@types/serve-static': 1.15.10
'@types/fs-extra@11.0.4':
dependencies:
'@types/jsonfile': 6.1.4
'@types/node': 24.10.0
'@types/hast@3.0.4':
dependencies:
'@types/unist': 3.0.3
@ -6452,10 +6404,6 @@ snapshots:
'@types/json-schema@7.0.15': {}
'@types/jsonfile@6.1.4':
dependencies:
'@types/node': 24.10.0
'@types/linkify-it@5.0.0': {}
'@types/markdown-it@14.1.2':
@ -7610,14 +7558,6 @@ snapshots:
dependencies:
es-errors: 1.3.0
esbuild-plugin-copy@2.1.1(esbuild@0.25.12):
dependencies:
chalk: 4.1.2
chokidar: 3.6.0
esbuild: 0.25.12
fs-extra: 10.1.0
globby: 11.1.0
esbuild@0.25.12:
optionalDependencies:
'@esbuild/aix-ppc64': 0.25.12
@ -8211,12 +8151,6 @@ snapshots:
fresh@0.5.2: {}
fs-extra@10.1.0:
dependencies:
graceful-fs: 4.2.11
jsonfile: 6.2.0
universalify: 2.0.1
fs-extra@11.3.2:
dependencies:
graceful-fs: 4.2.11
@ -10169,6 +10103,7 @@ snapshots:
get-tsconfig: 4.13.0
optionalDependencies:
fsevents: 2.3.3
optional: true
twoslash-protocol@0.3.4: {}

View File

@ -7,35 +7,19 @@ shellEmulator: true
catalog:
'@antfu/eslint-config': ^6.2.0
'@antfu/ni': ^27.0.1
'@farmfe/cli': ^1.0.5
'@farmfe/core': ^1.7.11
'@rspack/cli': ^1.6.0
'@rspack/core': ^1.6.0
'@types/fs-extra': ^11.0.4
'@types/node': ^24.10.0
'@types/picomatch': ^4.0.2
ansis: ^4.2.0
bumpp: ^10.3.1
esbuild: ^0.25.12
esbuild-plugin-copy: ^2.1.1
eslint: ^9.39.0
eslint-plugin-format: ^1.0.2
fast-glob: ^3.3.3
fs-extra: ^11.3.2
jiti: ^2.6.1
lint-staged: ^16.2.6
magic-string: ^0.30.21
rolldown: ^1.0.0-beta.46
rollup: ^4.52.5
simple-git-hooks: ^2.13.1
tsdown: ^0.15.12
typescript: ~5.9.3
unloader: ^0.5.0
unplugin-unused: ^0.5.5
vite: ^7.1.12
vitest: ^4.0.6
webpack: ^5.102.1
webpack-cli: ^6.0.1
catalogs:
docs:
@ -47,7 +31,6 @@ catalogs:
markdown-it: ^14.1.0
markdown-it-github-alerts: ^1.0.0
ofetch: ^1.5.1
tsx: ^4.20.6
unocss: ^66.5.4
unplugin-icons: ^22.5.0
unplugin-vue-components: ^30.0.0
@ -55,12 +38,29 @@ catalogs:
vitepress-plugin-group-icons: ^1.6.5
vue: ^3.5.22
vue-tsc: ^3.1.3
peer:
'@farmfe/core': ^1.7.11
'@rspack/core': ^1.6.0
rolldown: ^1.0.0-beta.46
rollup: ^4.52.5
unloader: ^0.5.0
vite: ^7.1.12
webpack: ^5.102.1
prod:
'@jridgewell/remapping': ^2.3.5
acorn: ^8.15.0
picomatch: ^4.0.3
webpack-virtual-modules: ^0.6.2
test:
'@farmfe/cli': ^1.0.5
'@rspack/cli': ^1.6.0
magic-string: ^0.30.21
vitest: ^4.0.6
webpack-cli: ^6.0.1
onlyBuiltDependencies:
- core-js
- esbuild

View File

@ -1,45 +1,42 @@
import { execSync } from 'node:child_process'
import { existsSync } from 'node:fs'
import { readdir, rm } from 'node:fs/promises'
import { join, resolve } from 'node:path'
import process from 'node:process'
import c from 'ansis'
import fs from 'fs-extra'
async function run() {
const dir = resolve(__dirname, '../test/fixtures')
let fixtures = await fs.readdir(dir)
const dir = resolve(import.meta.dirname, '../test/fixtures')
let fixtures = await readdir(dir)
if (process.argv[2])
fixtures = fixtures.filter(i => i.includes(process.argv[2]))
if (process.argv[2])
fixtures = fixtures.filter(i => i.includes(process.argv[2]))
for (const name of fixtures) {
const path = join(dir, name)
if (fs.existsSync(join(path, 'dist')))
await fs.remove(join(path, 'dist'))
for (const name of fixtures) {
const path = join(dir, name)
if (existsSync(join(path, 'dist')))
await rm(join(path, 'dist')).catch(() => {})
console.log(c.yellow.inverse.bold`\n Vite `, name, '\n')
execSync('npx vite --version', { cwd: path, stdio: 'inherit' })
execSync('npx vite build', { cwd: path, stdio: 'inherit' })
console.log(c.yellow.inverse.bold`\n Vite `, name, '\n')
execSync('npx vite --version', { cwd: path, stdio: 'inherit' })
execSync('npx vite build', { cwd: path, stdio: 'inherit' })
console.log(c.red.inverse.bold`\n Rollup `, name, '\n')
execSync('npx rollup --version', { cwd: path, stdio: 'inherit' })
execSync('npx rollup --bundleConfigAsCjs -c', { cwd: path, stdio: 'inherit' })
console.log(c.red.inverse.bold`\n Rollup `, name, '\n')
execSync('npx rollup --version', { cwd: path, stdio: 'inherit' })
execSync('npx rollup --bundleConfigAsCjs -c', { cwd: path, stdio: 'inherit' })
console.log(c.blue.inverse.bold`\n Webpack `, name, '\n')
execSync('npx webpack --version', { cwd: path, stdio: 'inherit' })
execSync('npx webpack', { cwd: path, stdio: 'inherit' })
console.log(c.blue.inverse.bold`\n Webpack `, name, '\n')
execSync('npx webpack --version', { cwd: path, stdio: 'inherit' })
execSync('npx webpack', { cwd: path, stdio: 'inherit' })
console.log(c.yellow.inverse.bold`\n Esbuild `, name, '\n')
execSync('npx esbuild --version', { cwd: path, stdio: 'inherit' })
execSync('node esbuild.config.js', { cwd: path, stdio: 'inherit' })
console.log(c.yellow.inverse.bold`\n Esbuild `, name, '\n')
execSync('npx esbuild --version', { cwd: path, stdio: 'inherit' })
execSync('node esbuild.config.js', { cwd: path, stdio: 'inherit' })
console.log(c.cyan.inverse.bold`\n Rspack `, name, '\n')
execSync('npx rspack --version', { cwd: path, stdio: 'inherit' })
execSync('npx rspack', { cwd: path, stdio: 'inherit' })
console.log(c.cyan.inverse.bold`\n Rspack `, name, '\n')
execSync('npx rspack --version', { cwd: path, stdio: 'inherit' })
execSync('npx rspack', { cwd: path, stdio: 'inherit' })
console.log(c.magenta.inverse.bold`\n Farm `, name, '\n')
execSync('npx farm --version', { cwd: path, stdio: 'inherit' })
execSync('npx farm build', { cwd: path, stdio: 'inherit' })
}
console.log(c.magenta.inverse.bold`\n Farm `, name, '\n')
execSync('npx farm --version', { cwd: path, stdio: 'inherit' })
execSync('npx farm build', { cwd: path, stdio: 'inherit' })
}
run()

View File

@ -15,13 +15,15 @@ import { createBuildContext, normalizeMessage } from './context'
import { decodeVirtualModuleId, encodeVirtualModuleId, FakeVirtualModulesPlugin, isVirtualModuleId } from './utils'
const TRANSFORM_LOADER = resolve(
__dirname,
__DEV__ ? '../../dist/rspack/loaders/transform.js' : 'rspack/loaders/transform',
// eslint-disable-next-line node/no-unsupported-features/node-builtins
import.meta.dirname,
__DEV__ ? '../../dist/rspack/loaders/transform.mjs' : 'rspack/loaders/transform.mjs',
)
const LOAD_LOADER = resolve(
__dirname,
__DEV__ ? '../../dist/rspack/loaders/load.js' : 'rspack/loaders/load',
// eslint-disable-next-line node/no-unsupported-features/node-builtins
import.meta.dirname,
__DEV__ ? '../../dist/rspack/loaders/load.mjs' : 'rspack/loaders/load.mjs',
)
export function getRspackPlugin<UserOptions = Record<string, never>>(

View File

@ -10,13 +10,15 @@ import { normalizeAbsolutePath, transformUse } from '../utils/webpack-like'
import { contextOptionsFromCompilation, createBuildContext, normalizeMessage } from './context'
const TRANSFORM_LOADER = resolve(
__dirname,
__DEV__ ? '../../dist/webpack/loaders/transform' : 'webpack/loaders/transform',
// eslint-disable-next-line node/no-unsupported-features/node-builtins
import.meta.dirname,
__DEV__ ? '../../dist/webpack/loaders/transform.mjs' : 'webpack/loaders/transform.mjs',
)
const LOAD_LOADER = resolve(
__dirname,
__DEV__ ? '../../dist/webpack/loaders/load' : 'webpack/loaders/load',
// eslint-disable-next-line node/no-unsupported-features/node-builtins
import.meta.dirname,
__DEV__ ? '../../dist/webpack/loaders/load.mjs' : 'webpack/loaders/load.mjs',
)
export function getWebpackPlugin<UserOptions = Record<string, never>>(
factory: UnpluginFactory<UserOptions>,

View File

@ -1,5 +1,5 @@
import fs from 'node:fs/promises'
import { resolve } from 'node:path'
import fs from 'fs-extra'
import { describe, expect, it } from 'vitest'
const r = (...args: string[]) => resolve(__dirname, '../dist', ...args)

View File

@ -1,5 +1,5 @@
import fs from 'node:fs/promises'
import { resolve } from 'node:path'
import fs from 'fs-extra'
import { describe, expect, it } from 'vitest'
const r = (...args: string[]) => resolve(__dirname, '../dist', ...args)

View File

@ -1,5 +1,5 @@
import fs from 'node:fs/promises'
import { resolve } from 'node:path'
import fs from 'fs-extra'
import { describe, expect, it } from 'vitest'
const r = (...args: string[]) => resolve(__dirname, '../dist', ...args)

View File

@ -1,16 +1,14 @@
import { defineConfig } from 'tsdown'
export default defineConfig({
entry: ['src/index.ts', 'src/webpack/loaders/*', 'src/rspack/loaders/*'],
format: ['cjs', 'esm'],
clean: true,
target: 'node18.12',
dts: true,
sourcemap: false,
entry: ['src/index.ts', 'src/{webpack,rspack}/loaders/*'],
define: {
__DEV__: 'false',
},
shims: true,
// peer dependencies
external: ['vite', 'webpack', 'rollup', 'esbuild', '@farmfe/core'],
unused: { level: 'error' },
fixedExtension: true,
inlineOnly: [],
exports: true,
})