@@ -110,11 +110,11 @@ export function analyzeScriptSetupScope(
110110 scopeManager : escopeTypes . ScopeManager ,
111111 templateBody : VElement | undefined ,
112112 df : VDocumentFragment ,
113- _parserOptions : ParserOptions ,
113+ parserOptions : ParserOptions ,
114114) : void {
115115 analyzeUsedInTemplateVariables ( scopeManager , templateBody , df )
116116
117- analyzeCompilerMacrosVariables ( scopeManager )
117+ analyzeCompilerMacrosVariables ( scopeManager , parserOptions )
118118}
119119
120120function extractVariables ( scopeManager : escopeTypes . ScopeManager ) {
@@ -287,11 +287,19 @@ function analyzeUsedInTemplateVariables(
287287 */
288288function analyzeCompilerMacrosVariables (
289289 scopeManager : escopeTypes . ScopeManager ,
290+ parserOptions : ParserOptions ,
290291) {
291292 const globalScope = scopeManager . globalScope
292293 if ( ! globalScope ) {
293294 return
294295 }
296+ const customMacros = new Set (
297+ parserOptions . vueFeatures ?. customMacros &&
298+ Array . isArray ( parserOptions . vueFeatures . customMacros )
299+ ? parserOptions . vueFeatures . customMacros
300+ : [ ] ,
301+ )
302+
295303 const compilerMacroVariables = new Map < string , escopeTypes . Variable > ( )
296304
297305 function addCompilerMacroVariable ( reference : escopeTypes . Reference ) {
@@ -312,7 +320,10 @@ function analyzeCompilerMacrosVariables(
312320
313321 const newThrough : escopeTypes . Reference [ ] = [ ]
314322 for ( const reference of globalScope . through ) {
315- if ( COMPILER_MACROS_AT_ROOT . has ( reference . identifier . name ) ) {
323+ if (
324+ COMPILER_MACROS_AT_ROOT . has ( reference . identifier . name ) ||
325+ customMacros . has ( reference . identifier . name )
326+ ) {
316327 if (
317328 reference . from . type === "global" ||
318329 reference . from . type === "module"
0 commit comments