@@ -86,10 +86,12 @@ export default function vueNestedSFC(): PluginOption {
86
86
}
87
87
return {
88
88
code : genExportsCode ( request . filename , exportedComponents , code ) ,
89
- // eslint-disable-next-line unicorn/no-null
90
89
map : null ,
91
90
} ;
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
+ }
93
95
const componentName = pascalCase ( request . query . name ) ;
94
96
cache . registerNestedComponent ( request . filename , componentName ) ;
95
97
return {
@@ -112,11 +114,12 @@ export default function vueNestedSFC(): PluginOption {
112
114
cache . updateFileCache ( file , await read ( ) ) ;
113
115
const nextDescriptor = cache . getDescriptor ( file ) ;
114
116
117
+ const mainModule = server . moduleGraph . getModuleById ( file ) ;
118
+
115
119
if (
116
120
prevDescriptor . customBlocks . length !==
117
121
nextDescriptor . customBlocks . length
118
122
) {
119
- const mainModule = server . moduleGraph . getModuleById ( file ) ;
120
123
if ( mainModule ) {
121
124
affectedModules . add ( mainModule ) ;
122
125
}
@@ -127,6 +130,9 @@ export default function vueNestedSFC(): PluginOption {
127
130
continue ;
128
131
}
129
132
if ( typeof block . attrs . name !== "string" ) {
133
+ if ( mainModule ) {
134
+ affectedModules . add ( mainModule ) ;
135
+ }
130
136
continue ;
131
137
}
132
138
const name = pascalCase ( block . attrs . name ) ;
@@ -136,8 +142,11 @@ export default function vueNestedSFC(): PluginOption {
136
142
typeof nextBlock . attrs . name === "string" &&
137
143
pascalCase ( nextBlock . attrs . name ) === name
138
144
) ;
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
+ ) {
141
150
if ( mainModule ) {
142
151
affectedModules . add ( mainModule ) ;
143
152
}
0 commit comments