@@ -107,7 +107,10 @@ function useCodegen(
107107 return newNames ;
108108 }
109109 for ( const { range } of scriptSetupRanges . bindings ) {
110- newNames . add ( sfc . scriptSetup . content . slice ( range . start , range . end ) ) ;
110+ const name = sfc . scriptSetup . content . slice ( range . start , range . end ) ;
111+ if ( ! getImportComponentNames ( ) . has ( name ) ) {
112+ newNames . add ( name ) ;
113+ }
111114 }
112115 const scriptRanges = getScriptRanges ( ) ;
113116 if ( sfc . script && scriptRanges ) {
@@ -118,31 +121,34 @@ function useCodegen(
118121 return newNames ;
119122 } ) ;
120123
121- const getSetupImportComponentNames = computedSet ( ( ) => {
122- const newNames = new Set < string > ( ) ;
123- const bindings = getScriptSetupRanges ( ) ?. bindings ;
124- if ( sfc . scriptSetup && bindings ) {
125- for ( const { range, moduleName, isDefaultImport, isNamespace } of bindings ) {
124+ const getImportComponentNames = computedSet ( ( ) => {
125+ const names = new Set < string > ( ) ;
126+ const scriptSetupRanges = getScriptSetupRanges ( ) ;
127+ if ( sfc . scriptSetup && scriptSetupRanges ) {
128+ for ( const { range, moduleName, isDefaultImport, isNamespace } of scriptSetupRanges . bindings ) {
126129 if (
127130 moduleName
128131 && isDefaultImport
129132 && ! isNamespace
130133 && ctx . vueCompilerOptions . extensions . some ( ext => moduleName . endsWith ( ext ) )
131134 ) {
132- newNames . add ( sfc . scriptSetup . content . slice ( range . start , range . end ) ) ;
135+ names . add ( sfc . scriptSetup . content . slice ( range . start , range . end ) ) ;
133136 }
134137 }
135138 }
136- return newNames ;
139+ return names ;
137140 } ) ;
138141
139142 const getDestructuredPropNames = computedSet ( ( ) => {
140- const newNames = new Set ( getScriptSetupRanges ( ) ?. defineProps ?. destructured ?. keys ( ) ) ;
143+ const names = new Set ( [
144+ ...getScriptSetupRanges ( ) ?. defineProps ?. destructured ?. keys ( ) ?? [ ] ,
145+ ...getImportComponentNames ( ) ,
146+ ] ) ;
141147 const rest = getScriptSetupRanges ( ) ?. defineProps ?. destructuredRest ;
142148 if ( rest ) {
143- newNames . add ( rest ) ;
149+ names . add ( rest ) ;
144150 }
145- return newNames ;
151+ return names ;
146152 } ) ;
147153
148154 const getSetupTemplateRefNames = computedSet ( ( ) => {
@@ -197,10 +203,9 @@ function useCodegen(
197203 compilerOptions : ctx . compilerOptions ,
198204 vueCompilerOptions : getResolvedOptions ( ) ,
199205 template : sfc . template ,
200- destructuredPropNames : getDestructuredPropNames ( ) ,
206+ rawBindingNames : getDestructuredPropNames ( ) ,
201207 setupBindingNames : getSetupBindingNames ( ) ,
202208 templateRefNames : getSetupTemplateRefNames ( ) ,
203- scriptSetupImportComponentNames : getSetupImportComponentNames ( ) ,
204209 hasDefineSlots : setupHasDefineSlots ( ) ,
205210 propsAssignName : getSetupPropsAssignName ( ) ,
206211 slotsAssignName : getSetupSlotsAssignName ( ) ,
@@ -248,7 +253,7 @@ function useCodegen(
248253 vueCompilerOptions : getResolvedOptions ( ) ,
249254 usedCssModule : usedCssModule ( ) ,
250255 styles : sfc . styles ,
251- destructuredPropNames : getDestructuredPropNames ( ) ,
256+ rawBindingNames : getDestructuredPropNames ( ) ,
252257 templateRefNames : getSetupTemplateRefNames ( ) ,
253258 setupBindingNames : getSetupBindingNames ( ) ,
254259 } ) ;
0 commit comments