@@ -63,7 +63,7 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi
63
63
}
64
64
return null
65
65
} ,
66
- async load ( id ) {
66
+ load ( id ) {
67
67
if ( ! viteCompilerContext ) return
68
68
const { taroConfig, cwd : appPath , app, loaderMeta } = viteCompilerContext
69
69
const appConfig = app . config
@@ -100,9 +100,28 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi
100
100
code : parse . parse ( tabbarId , tabbarPages as TaroHarmonyPageMeta [ ] , name , this . resolve ) ,
101
101
exports : [ 'default' ] ,
102
102
} )
103
- await Promise . all ( tabbarPages . map ( async page => {
104
- await viteCompilerContext . collectedDeps ( this , escapePath ( page . scriptPath ) , filter )
105
- } ) )
103
+ tabbarPages . forEach ( async page => {
104
+ const deps = await viteCompilerContext . collectedDeps ( this , escapePath ( page . scriptPath ) , filter )
105
+ const ncObj : Record < string , [ string , string ] > = { }
106
+ deps . forEach ( dep => {
107
+ Object . entries ( nCompCache . get ( dep ) || { } ) . forEach ( ( [ key , value ] ) => {
108
+ const absPath = value [ 0 ]
109
+ const ext = path . extname ( absPath )
110
+ const basename = path . basename ( absPath , ext )
111
+ ncObj [ key ] = [ path . join ( path . dirname ( path . relative ( path . dirname ( rawId ) , absPath ) ) , basename ) , value [ 1 ] ]
112
+ } )
113
+ } )
114
+ if ( ! page . isNative ) {
115
+ page . config . usingComponents = {
116
+ ...page . config . usingComponents ,
117
+ ...ncObj ,
118
+ }
119
+ }
120
+ const nativeComps = viteCompilerContext . collectNativeComponents ( page )
121
+ nativeComps . forEach ( comp => {
122
+ viteCompilerContext . generateNativeComponent ( this , comp , [ rawId ] )
123
+ } )
124
+ } )
106
125
}
107
126
} else {
108
127
const list : string [ ] = [ ]
@@ -118,7 +137,7 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi
118
137
list . push ( page . name )
119
138
}
120
139
121
- await Promise . all ( list . map ( async pageName => {
140
+ list . forEach ( pageName => {
122
141
pageName = removeHeadSlash ( pageName )
123
142
if ( ! pageName ) {
124
143
pageName = 'index'
@@ -135,29 +154,33 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi
135
154
code : parse . parse ( path . resolve ( appRoot , pageName ) , page_ , name , this . resolve ) ,
136
155
exports : [ 'default' ] ,
137
156
} )
138
- const deps : Set < string > = await viteCompilerContext . collectedDeps ( this , escapePath ( rawId ) , filter )
139
- const ncObj : Record < string , [ string , string ] > = { }
140
- deps . forEach ( dep => {
141
- Object . entries ( nCompCache . get ( dep ) || { } ) . forEach ( ( [ key , value ] ) => {
142
- const absPath = value [ 0 ]
143
- const ext = path . extname ( absPath )
144
- const basename = path . basename ( absPath , ext )
145
- ncObj [ key ] = [ path . join ( path . dirname ( path . relative ( path . dirname ( rawId ) , absPath ) ) , basename ) , value [ 1 ] ]
157
+ viteCompilerContext . collectedDeps ( this , escapePath ( rawId ) , filter ) . then ( deps => {
158
+ const ncObj : Record < string , [ string , string ] > = { }
159
+ deps . forEach ( dep => {
160
+ Object . entries ( nCompCache . get ( dep ) || { } ) . forEach ( ( [ key , value ] ) => {
161
+ const absPath = value [ 0 ]
162
+ const ext = path . extname ( absPath )
163
+ const basename = path . basename ( absPath , ext )
164
+ ncObj [ key ] = [ path . join ( path . dirname ( path . relative ( path . dirname ( rawId ) , absPath ) ) , basename ) , value [ 1 ] ]
165
+ } )
146
166
} )
147
- } )
148
- if ( ! page . isNative ) {
149
- page . config . usingComponents = {
150
- ...page . config . usingComponents ,
151
- ... ncObj ,
167
+ if ( ! page . isNative ) {
168
+ page . config . usingComponents = {
169
+ ... page . config . usingComponents ,
170
+ ...ncObj ,
171
+ }
152
172
}
153
- }
154
- viteCompilerContext . collectNativeComponents ( page )
155
- } ) )
173
+ const nativeComps = viteCompilerContext . collectNativeComponents ( page )
174
+ nativeComps . forEach ( comp => {
175
+ viteCompilerContext . generateNativeComponent ( this , comp , [ rawId ] )
176
+ } )
177
+ } )
178
+ } )
156
179
}
157
180
return parse . parseEntry ( rawId , page as TaroHarmonyPageMeta )
158
181
}
159
182
} ,
160
- async transform ( code , id ) {
183
+ transform ( code , id ) {
161
184
if ( / \. m ? [ j t ] s x ? $ / . test ( id ) && filter ( id ) ) {
162
185
const scopeNativeComp = new Map < string , [ string , string ] > ( )
163
186
let enableImportComponent = true
0 commit comments