Skip to content

Commit f83d7af

Browse files
committed
chore: simplify deps
1 parent 219bd3d commit f83d7af

File tree

5 files changed

+107
-2486
lines changed

5 files changed

+107
-2486
lines changed

packages/vue/build/build.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import { rm } from 'node:fs/promises'
12
import path from 'node:path'
2-
import chalk from 'chalk'
33
import consola from 'consola'
44
import { build, type BuildOptions, type Format } from 'esbuild'
55
import GlobalsPlugin from 'esbuild-plugin-globals'
6-
import { emptyDir } from 'fs-extra'
76
import vue from 'unplugin-vue/esbuild'
87
import { version } from '../package.json'
9-
import { pathOutput, pathSrc } from './paths'
8+
9+
const pathSrc = path.resolve(import.meta.dirname, '../src')
10+
const pathOutput = path.resolve(import.meta.dirname, '../dist')
1011

1112
const buildBundle = () => {
1213
const getBuildOptions = (format: Format) => {
@@ -70,7 +71,7 @@ const buildBundle = () => {
7071
return Promise.all([doBuild(true), doBuild(false)])
7172
}
7273

73-
consola.info(chalk.blue('cleaning dist...'))
74-
await emptyDir(pathOutput)
75-
consola.info(chalk.blue('building...'))
74+
consola.info('cleaning dist...')
75+
await rm(pathOutput, { recursive: true, force: true })
76+
consola.info('building...')
7677
await buildBundle()

packages/vue/build/generate.ts

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
1-
import { readFile, writeFile } from 'node:fs/promises'
2-
import path from 'node:path'
3-
import process from 'node:process'
4-
import { findWorkspaceDir } from '@pnpm/find-workspace-dir'
5-
import { findWorkspacePackages } from '@pnpm/find-workspace-packages'
1+
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
2+
import { basename, resolve } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
64
import camelcase from 'camelcase'
7-
import chalk from 'chalk'
85
import consola from 'consola'
9-
import glob from 'fast-glob'
10-
import { emptyDir, ensureDir } from 'fs-extra'
116
import { format, type BuiltInParserName } from 'prettier'
12-
import { pathComponents } from './paths'
7+
import { glob } from 'tinyglobby'
138

14-
consola.info(chalk.blue('generating vue components'))
15-
await ensureDir(pathComponents)
16-
await emptyDir(pathComponents)
9+
consola.info('generating vue components')
10+
const pathComponents = resolve(import.meta.dirname, '../src/components')
11+
await rm(pathComponents, { recursive: true, force: true })
12+
await mkdir(pathComponents, { recursive: true })
1713
const files = await getSvgFiles()
1814

19-
consola.info(chalk.blue('generating vue files'))
15+
consola.info('generating vue files')
2016
await Promise.all(files.map((file) => transformToVueComponent(file)))
2117

22-
consola.info(chalk.blue('generating entry file'))
18+
consola.info('generating entry file')
2319
await generateEntry(files)
2420

25-
async function getSvgFiles() {
26-
const pkgs = await findWorkspacePackages(
27-
(await findWorkspaceDir(process.cwd()))!,
21+
function getSvgFiles() {
22+
const svgPackageJson = fileURLToPath(
23+
import.meta.resolve('@element-plus/icons-svg/package.json'),
2824
)
29-
const pkg = pkgs.find(
30-
(pkg) => pkg.manifest.name === '@element-plus/icons-svg',
31-
)!
32-
return glob('*.svg', { cwd: pkg.dir, absolute: true })
25+
return glob('*.svg', {
26+
cwd: resolve(svgPackageJson, '..'),
27+
absolute: true,
28+
})
3329
}
3430

3531
function getName(file: string) {
36-
const filename = path.basename(file).replace('.svg', '')
32+
const filename = basename(file).replace('.svg', '')
3733
const componentName = camelcase(filename, { pascalCase: true })
3834
return {
3935
filename,
@@ -64,7 +60,7 @@ defineOptions({
6460
</script>`,
6561
'vue',
6662
)
67-
writeFile(path.resolve(pathComponents, `${filename}.vue`), vue, 'utf8')
63+
writeFile(resolve(pathComponents, `${filename}.vue`), vue, 'utf8')
6864
}
6965

7066
async function generateEntry(files: string[]) {
@@ -76,5 +72,5 @@ async function generateEntry(files: string[]) {
7672
})
7773
.join('\n'),
7874
)
79-
await writeFile(path.resolve(pathComponents, 'index.ts'), code, 'utf8')
75+
await writeFile(resolve(pathComponents, 'index.ts'), code, 'utf8')
8076
}

packages/vue/build/paths.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/vue/package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,14 @@
6060
},
6161
"devDependencies": {
6262
"@element-plus/icons-svg": "workspace:*",
63-
"@pnpm/find-workspace-dir": "^1000.1.3",
64-
"@pnpm/find-workspace-packages": "^6.0.9",
65-
"@pnpm/logger": "^1001.0.1",
66-
"@types/fs-extra": "^11.0.4",
6763
"@types/node": "^25.0.10",
6864
"camelcase": "^9.0.0",
69-
"chalk": "^5.6.2",
7065
"consola": "^3.4.2",
7166
"esbuild": "^0.27.2",
7267
"esbuild-plugin-globals": "^0.2.0",
73-
"fast-glob": "^3.3.3",
74-
"fs-extra": "^11.3.3",
75-
"npm-run-all": "^4.1.5",
68+
"npm-run-all2": "^8.0.4",
7669
"prettier": "^3.8.1",
70+
"tinyglobby": "^0.2.15",
7771
"tsx": "^4.21.0",
7872
"typescript": "^5.9.3",
7973
"unplugin-vue": "^7.1.0",

0 commit comments

Comments
 (0)