@@ -13,7 +13,8 @@ type ModEntry = {
1313
1414type Info = {
1515 ast : Program
16- imports : Set < string >
16+ imports : string [ ]
17+ contextMods : string [ ]
1718 isMacro : boolean
1819}
1920
@@ -86,15 +87,17 @@ export class Registry {
8687 this . info [ module ] ??= Promise . resolve ( ) . then ( async ( ) => {
8788 const source = await this . hooks . import ( module )
8889 const ast = parse ( source )
89- const { imports, ...info } = analyze ( ast )
90- let isMacro = info . hasUnboundSelector
91- for ( const [ mod , unbound ] of info . modifiers ) {
92- if ( unbound && ! isMacro ) {
93- const entry = await this . importMod ( mod )
94- isMacro = entry ?. useContext || false
90+ const info = analyze ( ast )
91+ const imports = [ ...info . imports ]
92+ const contextMods : string [ ] = [ ]
93+ for ( const mod of info . modifiers ) {
94+ const entry = await this . importMod ( mod )
95+ if ( entry ?. useContext ?? true ) {
96+ contextMods . push ( mod )
9597 }
9698 }
97- return { ast, imports, isMacro }
99+ const isMacro = info . hasUnboundSelector || contextMods . length > 0
100+ return { ast, imports, contextMods, isMacro }
98101 } )
99102 return this . info [ module ]
100103 }
@@ -106,15 +109,15 @@ export class Registry {
106109 }
107110 const key = buildImportKey ( module , contextType )
108111 this . entries [ key ] ??= Promise . resolve ( ) . then ( async ( ) => {
109- const { ast, imports } = await this . getInfo ( module )
110- const macros : string [ ] = [ ]
112+ const { ast, imports, contextMods } = await this . getInfo ( module )
113+ const contextual = [ ... contextMods ]
111114 for ( const i of imports ) {
112115 const depInfo = await this . getInfo ( i )
113116 if ( depInfo . isMacro ) {
114- macros . push ( i )
117+ contextual . push ( i )
115118 }
116119 }
117- const simplified = desugar ( ast , macros )
120+ const simplified = desugar ( ast , contextual )
118121 const { inputs, calls, modifiers } = analyze ( simplified )
119122
120123 const returnTypes : Record < string , TypeInfo > = { }
0 commit comments