@@ -113,11 +113,11 @@ export function analyzeScriptSetupScope(
113
113
scopeManager : escopeTypes . ScopeManager ,
114
114
templateBody : VElement | undefined ,
115
115
df : VDocumentFragment ,
116
- _parserOptions : ParserOptions ,
116
+ parserOptions : ParserOptions ,
117
117
) : void {
118
118
analyzeUsedInTemplateVariables ( scopeManager , templateBody , df )
119
119
120
- analyzeCompilerMacrosVariables ( scopeManager )
120
+ analyzeCompilerMacrosVariables ( scopeManager , parserOptions )
121
121
}
122
122
123
123
function extractVariables ( scopeManager : escopeTypes . ScopeManager ) {
@@ -290,11 +290,19 @@ function analyzeUsedInTemplateVariables(
290
290
*/
291
291
function analyzeCompilerMacrosVariables (
292
292
scopeManager : escopeTypes . ScopeManager ,
293
+ parserOptions : ParserOptions ,
293
294
) {
294
295
const globalScope = scopeManager . globalScope
295
296
if ( ! globalScope ) {
296
297
return
297
298
}
299
+ const customMacros = new Set (
300
+ parserOptions . vueFeatures ?. customMacros &&
301
+ Array . isArray ( parserOptions . vueFeatures . customMacros )
302
+ ? parserOptions . vueFeatures . customMacros
303
+ : [ ] ,
304
+ )
305
+
298
306
const compilerMacroVariables = new Map < string , escopeTypes . Variable > ( )
299
307
300
308
function addCompilerMacroVariable ( reference : escopeTypes . Reference ) {
@@ -315,7 +323,10 @@ function analyzeCompilerMacrosVariables(
315
323
316
324
const newThrough : escopeTypes . Reference [ ] = [ ]
317
325
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
+ ) {
319
330
if (
320
331
reference . from . type === "global" ||
321
332
reference . from . type === "module"
0 commit comments