@@ -21,7 +21,7 @@ import { resolvePlugin } from './core/plugin'
2121import VueBetterDefine from '@vue-macros/better-define'
2222import VueBooleanProp from '@vue-macros/boolean-prop'
2323import VueChainCall from '@vue-macros/chain-call'
24- import { resolveOptions , type Options } from '@vue-macros/config'
24+ import { resolveOptionsAsync , type Options } from '@vue-macros/config'
2525import VueDefineEmit from '@vue-macros/define-emit'
2626import VueDefineModels from '@vue-macros/define-models'
2727import VueDefineProp from '@vue-macros/define-prop'
@@ -47,104 +47,111 @@ import VueShortEmits from '@vue-macros/short-emits'
4747import VueShortVmodel from '@vue-macros/short-vmodel'
4848import VueDefineOptions from 'unplugin-vue-define-options'
4949
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'
5156
5257const name = generatePluginName ( )
5358const plugin :UnpluginCombineInstance < Options | undefined > =
5459createCombinePlugin < Options | undefined > ( ( userOptions = { } , meta ) => {
55- const options = resolveOptions ( userOptions )
60+ return {
61+ name,
62+ plugins :( async ( ) => {
63+ const options = await resolveOptionsAsync ( userOptions )
5664
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+ )
6876
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 ] ,
7684
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 ) ,
8290
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 ) ,
8694
87- // both props & emits
88- resolvePlugin ( VueDefineModels , framework , options . defineModels ) ,
95+ // both props & emits
96+ resolvePlugin ( VueDefineModels , framework , options . defineModels ) ,
8997
90- // convert to runtime props & emits
91- resolvePlugin ( VueBetterDefine , framework , options . betterDefine ) ,
98+ // convert to runtime props & emits
99+ resolvePlugin ( VueBetterDefine , framework , options . betterDefine ) ,
92100
93- // runtime props
94- resolvePlugin ( VueDefineProp , framework , options . defineProp ) ,
101+ // runtime props
102+ resolvePlugin ( VueDefineProp , framework , options . defineProp ) ,
95103
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 ) ,
108116
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+ :[ ] ) ,
133141
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 )
144152
145- return {
146- name,
147- plugins,
153+ return plugins
154+ } ) ( ) ,
148155}
149156} )
150157export default plugin