@@ -86,10 +86,12 @@ export default function vueNestedSFC(): PluginOption {
8686 }
8787 return {
8888 code : genExportsCode ( request . filename , exportedComponents , code ) ,
89- // eslint-disable-next-line unicorn/no-null
9089 map : null ,
9190 } ;
92- } else if ( request . query . type === "component" && request . query . name ) {
91+ } else if ( request . query . type === "component" ) {
92+ if ( typeof request . query . name !== "string" ) {
93+ throw new TypeError ( "Component blocks require a name attribute." ) ;
94+ }
9395 const componentName = pascalCase ( request . query . name ) ;
9496 cache . registerNestedComponent ( request . filename , componentName ) ;
9597 return {
@@ -112,11 +114,12 @@ export default function vueNestedSFC(): PluginOption {
112114 cache . updateFileCache ( file , await read ( ) ) ;
113115 const nextDescriptor = cache . getDescriptor ( file ) ;
114116
117+ const mainModule = server . moduleGraph . getModuleById ( file ) ;
118+
115119 if (
116120 prevDescriptor . customBlocks . length !==
117121 nextDescriptor . customBlocks . length
118122 ) {
119- const mainModule = server . moduleGraph . getModuleById ( file ) ;
120123 if ( mainModule ) {
121124 affectedModules . add ( mainModule ) ;
122125 }
@@ -127,6 +130,9 @@ export default function vueNestedSFC(): PluginOption {
127130 continue ;
128131 }
129132 if ( typeof block . attrs . name !== "string" ) {
133+ if ( mainModule ) {
134+ affectedModules . add ( mainModule ) ;
135+ }
130136 continue ;
131137 }
132138 const name = pascalCase ( block . attrs . name ) ;
@@ -136,8 +142,11 @@ export default function vueNestedSFC(): PluginOption {
136142 typeof nextBlock . attrs . name === "string" &&
137143 pascalCase ( nextBlock . attrs . name ) === name
138144 ) ;
139- if ( ! nextBlock || nextBlock . attrs . name !== block . attrs . name ) {
140- const mainModule = server . moduleGraph . getModuleById ( file ) ;
145+ if (
146+ ! nextBlock ||
147+ nextBlock . attrs . name !== block . attrs . name ||
148+ nextBlock . attrs . export !== block . attrs . export
149+ ) {
141150 if ( mainModule ) {
142151 affectedModules . add ( mainModule ) ;
143152 }
0 commit comments