@@ -113,11 +113,11 @@ export function analyzeScriptSetupScope(
113113 scopeManager : escopeTypes . ScopeManager ,
114114 templateBody : VElement | undefined ,
115115 df : VDocumentFragment ,
116- _parserOptions : ParserOptions ,
116+ parserOptions : ParserOptions ,
117117) : void {
118118 analyzeUsedInTemplateVariables ( scopeManager , templateBody , df )
119119
120- analyzeCompilerMacrosVariables ( scopeManager )
120+ analyzeCompilerMacrosVariables ( scopeManager , parserOptions )
121121}
122122
123123function extractVariables ( scopeManager : escopeTypes . ScopeManager ) {
@@ -290,11 +290,19 @@ function analyzeUsedInTemplateVariables(
290290 */
291291function analyzeCompilerMacrosVariables (
292292 scopeManager : escopeTypes . ScopeManager ,
293+ parserOptions : ParserOptions ,
293294) {
294295 const globalScope = scopeManager . globalScope
295296 if ( ! globalScope ) {
296297 return
297298 }
299+ const customMacros = new Set (
300+ parserOptions . vueFeatures ?. customMacros &&
301+ Array . isArray ( parserOptions . vueFeatures . customMacros )
302+ ? parserOptions . vueFeatures . customMacros
303+ : [ ] ,
304+ )
305+
298306 const compilerMacroVariables = new Map < string , escopeTypes . Variable > ( )
299307
300308 function addCompilerMacroVariable ( reference : escopeTypes . Reference ) {
@@ -315,7 +323,10 @@ function analyzeCompilerMacrosVariables(
315323
316324 const newThrough : escopeTypes . Reference [ ] = [ ]
317325 for ( const reference of globalScope . through ) {
318- if ( COMPILER_MACROS_AT_ROOT . has ( reference . identifier . name ) ) {
326+ if (
327+ COMPILER_MACROS_AT_ROOT . has ( reference . identifier . name ) ||
328+ customMacros . has ( reference . identifier . name )
329+ ) {
319330 if (
320331 reference . from . type === "global" ||
321332 reference . from . type === "module"
0 commit comments