Skip to content

Commit ab10191

Browse files
committed
build(lodash): 重构构建流程并移除 tsdown
- 移除 tsdown 依赖,改用 Vite 完成构建任务 - 新增 fs 和 path 模块以支持文件操作 - 实现目录递归复制功能,用于复制类型定义文件 - 在 Vite 配置中添加插件,处理构建后任务
1 parent 1c70921 commit ab10191

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

packages/lodash/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"README.md"
2424
],
2525
"scripts": {
26-
"build": "vite build && tsdown",
26+
"build": "vite build",
2727
"sync": "curl -X PUT \"https://registry-direct.npmmirror.com/-/package/@candriajs/lodash/syncs\""
2828
},
2929
"engines": {

packages/lodash/tsdown.config.ts

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

packages/lodash/vite.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { defineConfig } from 'vite'
22
import { builtinModules } from 'node:module'
3+
import fs from 'node:fs'
4+
import path from 'node:path'
35

46
export default defineConfig({
57
build: {
@@ -28,5 +30,33 @@ export default defineConfig({
2830
transformMixedEsModules: true,
2931
defaultIsModuleExports: true
3032
},
33+
},
34+
plugins: [
35+
{
36+
name: 'lodash-plugin',
37+
closeBundle () {
38+
const sourceDir = './node_modules/@types/lodash'
39+
const targetDir = './dist/types'
40+
41+
const copyRecursiveSync = (src: string, dest: string) => {
42+
const stat = fs.statSync(src)
43+
44+
if (stat.isDirectory()) {
45+
fs.mkdirSync(dest, { recursive: true })
46+
fs.readdirSync(src).forEach(item => {
47+
copyRecursiveSync(
48+
path.join(src, item),
49+
path.join(dest, item)
50+
)
51+
})
52+
} else {
53+
fs.copyFileSync(src, dest)
54+
}
3155
}
56+
57+
copyRecursiveSync(sourceDir, targetDir)
58+
console.log('构建 lodash 成功!')
59+
}
60+
}
61+
]
3262
})

0 commit comments

Comments
 (0)