-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathdefine.ts
More file actions
101 lines (91 loc) · 3.11 KB
/
define.ts
File metadata and controls
101 lines (91 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import type { UnpluginFactory, UnpluginInstance } from './types'
import { getBunPlugin } from './bun'
import { getEsbuildPlugin } from './esbuild'
import { getFarmPlugin } from './farm'
import { getRolldownPlugin } from './rolldown'
import { getRollupPlugin } from './rollup'
import { getRspackPlugin } from './rspack'
import { getUnloaderPlugin } from './unloader'
import { getVitePlugin } from './vite'
import { getWebpackPlugin } from './webpack'
export function createUnplugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions, Nested> {
return {
get esbuild() {
return getEsbuildPlugin(factory)
},
get rollup() {
return getRollupPlugin(factory)
},
get vite() {
return getVitePlugin(factory)
},
get rolldown() {
return getRolldownPlugin(factory)
},
get webpack() {
return getWebpackPlugin(factory)
},
get rspack() {
return getRspackPlugin(factory)
},
get farm() {
return getFarmPlugin(factory)
},
get unloader() {
return getUnloaderPlugin(factory)
},
get bun() {
return getBunPlugin(factory)
},
get raw() {
return factory
},
}
}
export function createEsbuildPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['esbuild'] {
return getEsbuildPlugin(factory)
}
export function createRollupPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['rollup'] {
return getRollupPlugin(factory)
}
export function createVitePlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['vite'] {
return getVitePlugin(factory)
}
export function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['rolldown'] {
return getRolldownPlugin(factory)
}
export function createWebpackPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['webpack'] {
return getWebpackPlugin(factory)
}
export function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['rspack'] {
return getRspackPlugin(factory)
}
export function createFarmPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['farm'] {
return getFarmPlugin(factory)
}
export function createUnloaderPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['unloader'] {
return getUnloaderPlugin(factory)
}
export function createBunPlugin<UserOptions, Nested extends boolean = boolean>(
factory: UnpluginFactory<UserOptions, Nested>,
): UnpluginInstance<UserOptions>['bun'] {
return getBunPlugin(factory)
}