diff --git a/packages/grafana-toolkit/src/config/webpack.plugin.config.ts b/packages/grafana-toolkit/src/config/webpack.plugin.config.ts index ca6bdc0eb12..570b380a231 100644 --- a/packages/grafana-toolkit/src/config/webpack.plugin.config.ts +++ b/packages/grafana-toolkit/src/config/webpack.plugin.config.ts @@ -29,18 +29,20 @@ export const findModuleFiles = async (base: string, files?: string[], result?: s result = result || []; if (files) { - files.forEach(async file => { - const newbase = path.join(base, file); - if (fs.statSync(newbase).isDirectory()) { - result = await findModuleFiles(newbase, await readdirPromise(newbase), result); - } else { - const filename = path.basename(file); - if (/^module.(t|j)sx?$/.exec(filename)) { - // @ts-ignore - result.push(newbase); + await Promise.all( + files.map(async file => { + const newbase = path.join(base, file); + if (fs.statSync(newbase).isDirectory()) { + result = await findModuleFiles(newbase, await readdirPromise(newbase), result); + } else { + const filename = path.basename(file); + if (/^module.(t|j)sx?$/.exec(filename)) { + // @ts-ignore + result.push(newbase); + } } - } - }); + }) + ); } return result; };