@@ -21,7 +21,7 @@ import { resolvePlugin } from './core/plugin'
21
21
import VueBetterDefine from '@vue-macros/better-define'
22
22
import VueBooleanProp from '@vue-macros/boolean-prop'
23
23
import VueChainCall from '@vue-macros/chain-call'
24
- import { resolveOptions , type Options } from '@vue-macros/config'
24
+ import { resolveOptionsAsync , type Options } from '@vue-macros/config'
25
25
import VueDefineEmit from '@vue-macros/define-emit'
26
26
import VueDefineModels from '@vue-macros/define-models'
27
27
import VueDefineProp from '@vue-macros/define-prop'
@@ -47,104 +47,111 @@ import VueShortEmits from '@vue-macros/short-emits'
47
47
import VueShortVmodel from '@vue-macros/short-vmodel'
48
48
import VueDefineOptions from 'unplugin-vue-define-options'
49
49
50
- export { defineConfig , resolveOptions , type Options } from '@vue-macros/config'
50
+ export {
51
+ defineConfig ,
52
+ resolveOptions ,
53
+ resolveOptionsAsync ,
54
+ type Options ,
55
+ } from '@vue-macros/config'
51
56
52
57
const name = generatePluginName ( )
53
58
const plugin : UnpluginCombineInstance < Options | undefined > =
54
59
createCombinePlugin < Options | undefined > ( ( userOptions = { } , meta ) => {
55
- const options = resolveOptions ( userOptions )
60
+ return {
61
+ name,
62
+ plugins : ( async ( ) => {
63
+ const options = await resolveOptionsAsync ( userOptions )
56
64
57
- const framework = meta . framework !
58
- const setupComponentPlugins = resolvePlugin (
59
- VueSetupComponent ,
60
- framework ,
61
- options . setupComponent ,
62
- )
63
- const namedTemplatePlugins = resolvePlugin (
64
- VueNamedTemplate ,
65
- framework ,
66
- options . namedTemplate ,
67
- )
65
+ const framework = meta . framework !
66
+ const setupComponentPlugins = resolvePlugin (
67
+ VueSetupComponent ,
68
+ framework ,
69
+ options . setupComponent ,
70
+ )
71
+ const namedTemplatePlugins = resolvePlugin (
72
+ VueNamedTemplate ,
73
+ framework ,
74
+ options . namedTemplate ,
75
+ )
68
76
69
- const plugins : OptionsPlugin [ ] = [
70
- resolvePlugin ( VueSetupSFC , framework , options . setupSFC ) ,
71
- setupComponentPlugins ?. [ 0 ] ,
72
- resolvePlugin ( VueSetupBlock , framework , options . setupBlock ) ,
73
- resolvePlugin ( VueScriptLang , framework , options . scriptLang ) ,
74
- options . plugins . vueRouter ,
75
- namedTemplatePlugins ?. [ 0 ] ,
77
+ const plugins : OptionsPlugin [ ] = [
78
+ resolvePlugin ( VueSetupSFC , framework , options . setupSFC ) ,
79
+ setupComponentPlugins ?. [ 0 ] ,
80
+ resolvePlugin ( VueSetupBlock , framework , options . setupBlock ) ,
81
+ resolvePlugin ( VueScriptLang , framework , options . scriptLang ) ,
82
+ options . plugins . vueRouter ,
83
+ namedTemplatePlugins ?. [ 0 ] ,
76
84
77
- // props
78
- resolvePlugin ( VueChainCall , framework , options . chainCall ) ,
79
- resolvePlugin ( VueDefineProps , framework , options . defineProps ) ,
80
- resolvePlugin ( VueDefinePropsRefs , framework , options . definePropsRefs ) ,
81
- resolvePlugin ( VueExportProps , framework , options . exportProps ) ,
85
+ // props
86
+ resolvePlugin ( VueChainCall , framework , options . chainCall ) ,
87
+ resolvePlugin ( VueDefineProps , framework , options . defineProps ) ,
88
+ resolvePlugin ( VueDefinePropsRefs , framework , options . definePropsRefs ) ,
89
+ resolvePlugin ( VueExportProps , framework , options . exportProps ) ,
82
90
83
- // emits
84
- resolvePlugin ( VueDefineEmit , framework , options . defineEmit ) ,
85
- resolvePlugin ( VueShortEmits , framework , options . shortEmits ) ,
91
+ // emits
92
+ resolvePlugin ( VueDefineEmit , framework , options . defineEmit ) ,
93
+ resolvePlugin ( VueShortEmits , framework , options . shortEmits ) ,
86
94
87
- // both props & emits
88
- resolvePlugin ( VueDefineModels , framework , options . defineModels ) ,
95
+ // both props & emits
96
+ resolvePlugin ( VueDefineModels , framework , options . defineModels ) ,
89
97
90
- // convert to runtime props & emits
91
- resolvePlugin ( VueBetterDefine , framework , options . betterDefine ) ,
98
+ // convert to runtime props & emits
99
+ resolvePlugin ( VueBetterDefine , framework , options . betterDefine ) ,
92
100
93
- // runtime props
94
- resolvePlugin ( VueDefineProp , framework , options . defineProp ) ,
101
+ // runtime props
102
+ resolvePlugin ( VueDefineProp , framework , options . defineProp ) ,
95
103
96
- resolvePlugin ( VueDefineSlots , framework , options . defineSlots ) ,
97
- resolvePlugin ( VueDefineStyleX , framework , options . defineStyleX ) ,
98
- resolvePlugin ( VueExportRender , framework , options . exportRender ) ,
99
- resolvePlugin ( VueExportExpose , framework , options . exportExpose ) ,
100
- resolvePlugin ( VueJsxDirective , framework , options . jsxDirective ) ,
101
- resolvePlugin (
102
- VueReactivityTransform ,
103
- framework ,
104
- options . reactivityTransform ,
105
- ) ,
106
- resolvePlugin ( VueHoistStatic , framework , options . hoistStatic ) ,
107
- resolvePlugin ( VueDefineOptions , framework , options . defineOptions ) ,
104
+ resolvePlugin ( VueDefineSlots , framework , options . defineSlots ) ,
105
+ resolvePlugin ( VueDefineStyleX , framework , options . defineStyleX ) ,
106
+ resolvePlugin ( VueExportRender , framework , options . exportRender ) ,
107
+ resolvePlugin ( VueExportExpose , framework , options . exportExpose ) ,
108
+ resolvePlugin ( VueJsxDirective , framework , options . jsxDirective ) ,
109
+ resolvePlugin (
110
+ VueReactivityTransform ,
111
+ framework ,
112
+ options . reactivityTransform ,
113
+ ) ,
114
+ resolvePlugin ( VueHoistStatic , framework , options . hoistStatic ) ,
115
+ resolvePlugin ( VueDefineOptions , framework , options . defineOptions ) ,
108
116
109
- ...( framework === 'vite' ||
110
- framework === 'rollup' ||
111
- framework === 'rolldown'
112
- ? [
113
- resolvePlugin (
114
- // VueBooleanProp is not an unplugin, by now
115
- VueBooleanProp as any ,
116
- framework ,
117
- options . booleanProp ,
118
- ) ,
119
- resolvePlugin (
120
- // VueShortBind is not an unplugin, by now
121
- VueShortBind as any ,
122
- framework ,
123
- options . shortBind ,
124
- ) ,
125
- resolvePlugin (
126
- // VueShortVmodel is not an unplugin, by now
127
- VueShortVmodel as any ,
128
- framework ,
129
- options . shortVmodel ,
130
- ) ,
131
- ]
132
- : [ ] ) ,
117
+ ...( framework === 'vite' ||
118
+ framework === 'rollup' ||
119
+ framework === 'rolldown'
120
+ ? [
121
+ resolvePlugin (
122
+ // VueBooleanProp is not an unplugin, by now
123
+ VueBooleanProp as any ,
124
+ framework ,
125
+ options . booleanProp ,
126
+ ) ,
127
+ resolvePlugin (
128
+ // VueShortBind is not an unplugin, by now
129
+ VueShortBind as any ,
130
+ framework ,
131
+ options . shortBind ,
132
+ ) ,
133
+ resolvePlugin (
134
+ // VueShortVmodel is not an unplugin, by now
135
+ VueShortVmodel as any ,
136
+ framework ,
137
+ options . shortVmodel ,
138
+ ) ,
139
+ ]
140
+ : [ ] ) ,
133
141
134
- options . plugins . vue ,
135
- options . plugins . vueJsx ,
136
- resolvePlugin ( VueDefineRender , framework , options . defineRender ) ,
137
- setupComponentPlugins ?. [ 1 ] ,
138
- namedTemplatePlugins ?. [ 1 ] ,
139
- framework === 'vite'
140
- ? Devtools ( { nuxtContext : options . nuxtContext } )
141
- : undefined ,
142
- framework === 'vite' ? excludeDepOptimize ( ) : undefined ,
143
- ] . filter ( Boolean )
142
+ options . plugins . vue ,
143
+ options . plugins . vueJsx ,
144
+ resolvePlugin ( VueDefineRender , framework , options . defineRender ) ,
145
+ setupComponentPlugins ?. [ 1 ] ,
146
+ namedTemplatePlugins ?. [ 1 ] ,
147
+ framework === 'vite'
148
+ ? Devtools ( { nuxtContext : options . nuxtContext } )
149
+ : undefined ,
150
+ framework === 'vite' ? excludeDepOptimize ( ) : undefined ,
151
+ ] . filter ( Boolean )
144
152
145
- return {
146
- name,
147
- plugins,
153
+ return plugins
154
+ } ) ( ) ,
148
155
}
149
156
} )
150
157
export default plugin
0 commit comments