Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Performance boost with Promise.all concurrency 🚀 #40212

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading