Skip to content

Commit

Permalink
perf: Improve performance by running async tasks concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaiyan-dev authored Dec 26, 2024
1 parent ac32751 commit 705e085
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions build-system/tasks/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,17 @@ function buildLoginDone(version) {
async function buildWebPushPublisherFiles() {
const distDir = 'dist/v0';
for (const version of WEB_PUSH_PUBLISHER_VERSIONS) {
for (const fileName of WEB_PUSH_PUBLISHER_FILES) {
await Promise.all(WEB_PUSH_PUBLISHER_FILES.map((fileName) => {
const tempBuildDir = `build/all/amp-web-push-${version}`;
const builtName = `${fileName}.js`;
const minifiedName = maybeToEsmName(builtName);
await compileJs(`./${tempBuildDir}`, builtName, `./${distDir}`, {
return compileJs(`./${tempBuildDir}`, builtName, `./${distDir}`, {
watch: argv.watch,
includePolyfills: true,
minify: true,
minifiedName,
});
}
}));
}
await postBuildWebPushPublisherFilesVersion();
}
Expand Down Expand Up @@ -284,8 +284,10 @@ async function postBuildWebPushPublisherFilesVersion() {
}

// Build Helper Frame HTML
const html = await fs.readFile(`${basePath}/${fileName}.html`, 'utf8');
const js = await fs.readFile(minifiedFile, 'utf8');
const [html, js] = await Promise.all([
fs.readFile(`${basePath}/${fileName}.html`, 'utf8'),
fs.readFile(minifiedFile, 'utf8')
]);
const minifiedHtml = html.replace(
`<!-- [REPLACE-SENTINEL ${fileName}.js] -->`,
`<script>${js}</script>`
Expand Down

0 comments on commit 705e085

Please sign in to comment.