@@ -110,11 +110,11 @@ export function analyzeScriptSetupScope(
110
110
scopeManager : escopeTypes . ScopeManager ,
111
111
templateBody : VElement | undefined ,
112
112
df : VDocumentFragment ,
113
- _parserOptions : ParserOptions ,
113
+ parserOptions : ParserOptions ,
114
114
) : void {
115
115
analyzeUsedInTemplateVariables ( scopeManager , templateBody , df )
116
116
117
- analyzeCompilerMacrosVariables ( scopeManager )
117
+ analyzeCompilerMacrosVariables ( scopeManager , parserOptions )
118
118
}
119
119
120
120
function extractVariables ( scopeManager : escopeTypes . ScopeManager ) {
@@ -287,11 +287,19 @@ function analyzeUsedInTemplateVariables(
287
287
*/
288
288
function analyzeCompilerMacrosVariables (
289
289
scopeManager : escopeTypes . ScopeManager ,
290
+ parserOptions : ParserOptions ,
290
291
) {
291
292
const globalScope = scopeManager . globalScope
292
293
if ( ! globalScope ) {
293
294
return
294
295
}
296
+ const customMacros = new Set (
297
+ parserOptions . vueFeatures ?. customMacros &&
298
+ Array . isArray ( parserOptions . vueFeatures . customMacros )
299
+ ? parserOptions . vueFeatures . customMacros
300
+ : [ ] ,
301
+ )
302
+
295
303
const compilerMacroVariables = new Map < string , escopeTypes . Variable > ( )
296
304
297
305
function addCompilerMacroVariable ( reference : escopeTypes . Reference ) {
@@ -312,7 +320,10 @@ function analyzeCompilerMacrosVariables(
312
320
313
321
const newThrough : escopeTypes . Reference [ ] = [ ]
314
322
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
+ ) {
316
327
if (
317
328
reference . from . type === "global" ||
318
329
reference . from . type === "module"
0 commit comments