Skip to content

Commit c30793c

Browse files
committed
perf: promise.all
1 parent a5e7855 commit c30793c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/vite/src/node/server/middlewares/indexHtml.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,18 @@ const devHtmlHook: IndexHtmlTransformHook = async (
188188
}
189189
})
190190

191-
for (let index = 0; index < styleUrl.length; index++) {
192-
const { start, end, code } = styleUrl[index]
193-
const url = filename + `?html-proxy&${index}.css`
191+
await Promise.all(
192+
styleUrl.map(async ({ start, end, code }, index) => {
193+
const url = filename + `?html-proxy&${index}.css`
194194

195-
// ensure module in graph after successful load
196-
const mod = await moduleGraph.ensureEntryFromUrl(url, false)
197-
ensureWatchedFile(watcher, mod.file, config.root)
195+
// ensure module in graph after successful load
196+
const mod = await moduleGraph.ensureEntryFromUrl(url, false)
197+
ensureWatchedFile(watcher, mod.file, config.root)
198198

199-
const result = await server!.pluginContainer.transform(code, url)
200-
s.overwrite(start, end, result?.code || '')
201-
}
199+
const result = await server!.pluginContainer.transform(code, url)
200+
s.overwrite(start, end, result?.code || '')
201+
})
202+
)
202203

203204
html = s.toString()
204205

0 commit comments

Comments
 (0)