Skip to content

Commit

Permalink
chore(benchmark-size): update current size of credential-provider-ini…
Browse files Browse the repository at this point in the history
… package (#3299)

* chore(benchmark-size): update logs with benchmarksize script

* chore(benchmark-size): update current size of credential-provider-ini package
  • Loading branch information
AllanZhengYP authored Feb 10, 2022
1 parent 778ad0e commit e2b7b25
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion benchmark/size/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
|@aws-sdk/credential-provider-cognito-identity|3.49.0|118.3 KB|✅(5.62.1)|✅(2.59.0)|✅(0.13.12)|
|@aws-sdk/credential-provider-env|3.49.0|47.1 KB|N/A|N/A|N/A|
|@aws-sdk/credential-provider-imds|3.49.0|79 KB|N/A|N/A|N/A|
|@aws-sdk/credential-provider-ini|3.49.0|61.4 KB|N/A|N/A|N/A|
|@aws-sdk/credential-provider-ini|3.49.0|69.7 KB|N/A|N/A|N/A|
|@aws-sdk/credential-provider-node|3.49.0|61.5 KB|N/A|N/A|N/A|
|@aws-sdk/credential-provider-process|3.49.0|48.1 KB|N/A|N/A|N/A|
|@aws-sdk/credential-provider-sso|3.49.0|36.3 KB|N/A|N/A|N/A|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ export const generateProject = async (projectDir: string, options: PackageSizeRe
...options.packageContext,
dependencies: [...peerDependencies, ...(options.packageContext?.dependencies ?? [])],
};
// console.error("CONTEXT||||||||", contextWithPeerDep);
for (const [name, template] of Object.entries(options.templates)) {
const filePath = join(projectDir, name);
const file = prettier.format(template(contextWithPeerDep), {
filepath: filePath,
});
// console.error("FILE|||||||, ", file);
await fsPromise.writeFile(filePath, file);
}

Expand Down
67 changes: 35 additions & 32 deletions scripts/benchmark-size/runner/calculate-size/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,46 @@ export interface PackageSizeReportOutput {

export const getPackageSizeReportRunner =
(options: PackageSizeReportOptions) => async (context: ListrContext, task: ListrTaskWrapper<ListrContext, any>) => {
task.output = "preparing...";
const projectDir = join(options.tmpDir, options.packageName.replace("/", "_"));
await fsPromise.rmdir(projectDir, { recursive: true });
await fsPromise.mkdir(projectDir);
const entryPoint = join(projectDir, "index.js");
const bundlersContext = { ...options, entryPoint, projectDir };
try {
task.output = "preparing...";
const projectDir = join(options.tmpDir, options.packageName.replace("/", "_"));
await fsPromise.mkdir(projectDir);
const entryPoint = join(projectDir, "index.js");
const bundlersContext = { ...options, entryPoint, projectDir };

task.output = "generating project and installing dependencies";
await generateProject(projectDir, options);
task.output = "generating project and installing dependencies";
await generateProject(projectDir, options);

task.output = "calculating npm size";
const npmSizeResult = calculateNpmSize(projectDir, options.packageName);
task.output = "calculating npm size";
const npmSizeResult = calculateNpmSize(projectDir, options.packageName);

const skipBundlerTests = bundlersContext.packageContext.skipBundlerTests;
const skipBundlerTests = bundlersContext.packageContext.skipBundlerTests;

task.output = "calculating webpack 5 full bundle size";
const webpackSize = skipBundlerTests ? undefined : await getWebpackSize(bundlersContext);
task.output = "calculating webpack 5 full bundle size";
const webpackSize = skipBundlerTests ? undefined : await getWebpackSize(bundlersContext);

task.output = "calculating rollup full bundle size";
const rollupSize = skipBundlerTests ? undefined : await getRollupSize(bundlersContext);
task.output = "calculating rollup full bundle size";
const rollupSize = skipBundlerTests ? undefined : await getRollupSize(bundlersContext);

task.output = "calculating esbuild full bundle size";
const esbuildSize = skipBundlerTests ? undefined : await getEsbuildSize(bundlersContext);
task.output = "calculating esbuild full bundle size";
const esbuildSize = skipBundlerTests ? undefined : await getEsbuildSize(bundlersContext);

task.output = "output results";
const packageVersion = JSON.parse(
await fsPromise.readFile(
join(options.workspacePackages.filter((pkg) => pkg.name === options.packageName)[0].location, "package.json"),
"utf8"
)
).version;
options.output.push({
name: options.packageName,
version: packageVersion,
...npmSizeResult,
webpackSize,
esbuildSize,
rollupSize,
});
task.output = "output results";
const packageVersion = JSON.parse(
await fsPromise.readFile(
join(options.workspacePackages.filter((pkg) => pkg.name === options.packageName)[0].location, "package.json"),
"utf8"
)
).version;
options.output.push({
name: options.packageName,
version: packageVersion,
...npmSizeResult,
webpackSize,
esbuildSize,
rollupSize,
});
} catch (e) {
e.message = `[${options.packageName}]` + e.message;
}
};
11 changes: 5 additions & 6 deletions scripts/benchmark-size/runner/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ export const validatePackagesAlreadyBuilt = async (packages: WorkspacePackage[])
return true;
};

const notBuilt: string[] = [];
for (const pkg of packages) {
if (!(await isBuilt(pkg.location))) {
notBuilt.push(pkg.name);
}
}
const notBuilt: string[] = await (
await Promise.all(packages.map(async (pkg) => ({ ...pkg, isBuilt: await isBuilt(pkg.location) })))
)
.filter((pkg) => !pkg.isBuilt)
.map((pkg) => pkg.name);
if (notBuilt.length > 0) {
throw new Error(`Please make sure these packages are fully built: ${notBuilt.join(", ")}`);
}
Expand Down

0 comments on commit e2b7b25

Please sign in to comment.