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

Improve performance by compressing in parallel ✈️ #2000

Open
wants to merge 3 commits into
base: master
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
16 changes: 7 additions & 9 deletions docgen/post-process.js
Original file line number Diff line number Diff line change
@@ -20,9 +20,11 @@ const path = require('path');
const readline = require('readline');

async function main() {
await applyExtras();
await fixHomePage();
await fixTitles();
await Promise.all([
applyExtras(),
fixHomePage(),
fixTitles(),
]);
}

/**
@@ -32,9 +34,7 @@ async function main() {
*/
async function applyExtras() {
const extras = await getExtraFiles();
for (const source of extras) {
await applyExtraContentFrom(source);
}
await Promise.all(extras.map(applyExtraContentFrom));
}

/**
@@ -60,9 +60,7 @@ async function fixHomePage() {
async function fixTitles() {
const markdownDir = path.join(__dirname, 'markdown');
const files = await fs.readdir(markdownDir);
for (const file of files) {
await fixTitleOf(path.join(markdownDir, file));
}
await Promise.all(files.map((file) => fixTitleOf(path.join(markdownDir, file))));

const tocFile = path.join(markdownDir, 'toc.yaml');
await fixTocTitles(tocFile);
6 changes: 4 additions & 2 deletions generate-esm-wrapper.js
Original file line number Diff line number Diff line change
@@ -35,8 +35,10 @@ async function generateEsmWrapper(entryPoint, source) {
const target = getTarget(entryPoint);
const output = getEsmOutput(source, target);
await fs.mkdir(path.dirname(target), { recursive: true });
await fs.writeFile(target, output);
await fs.writeFile('./lib/esm/package.json', JSON.stringify({type: 'module'}));
await Promise.all([
fs.writeFile(target, output),
fs.writeFile('./lib/esm/package.json', JSON.stringify({type: 'module'}))
]);
}

function getTarget(entryPoint) {
6 changes: 3 additions & 3 deletions generate-reports.js
Original file line number Diff line number Diff line change
@@ -35,10 +35,10 @@ const tempConfigFile = 'api-extractor.tmp';

async function generateReports() {
const entryPoints = require('./entrypoints.json');
for (const entryPoint in entryPoints) {
await Promise.all(entryPoints.map((entryPoint) => {
const filePath = entryPoints[entryPoint].typings;
await generateReportForEntryPoint(entryPoint, filePath);
}
return generateReportForEntryPoint(entryPoint, filePath);
}));
}

async function generateReportForEntryPoint(entryPoint, filePath) {