cdk-booster 1.1.0-alpha.1 → 1.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,8 +98,8 @@ async function bundle(lambdasEsBuildCommands) {
98
98
  const build = async () => {
99
99
  parallelCount++;
100
100
  try {
101
- const buildOptions = buildBatch[0].buildOptions;
102
- const entryPoints = buildBatch.map((b) => b.entryPoint);
101
+ const buildOptions = buildBatch.buildOptions;
102
+ const entryPoints = buildBatch.entryPoints;
103
103
  const normalizedEsbuildArgs = normalizeEsbuildArgs(buildOptions.esbuildArgs);
104
104
  const esBuildOpt = {
105
105
  entryPoints,
@@ -246,15 +246,24 @@ function createBuildCombinations(lambdasEsBuildCommands) {
246
246
  const uniqueBuildHashes = new Set(buildCombinations.map((b) => b.buildOptionsHash));
247
247
  for (const buildHash of uniqueBuildHashes) {
248
248
  const buildBatch = buildCombinations.filter((b) => b.buildOptionsHash === buildHash);
249
+ let entryPoints = buildBatch.map((b) => b.entryPoint);
250
+ // unique entry points
251
+ entryPoints = Array.from(new Set(entryPoints));
249
252
  // if batch size is set and if each buildOptionsHash has more than batchSize entries, split them
250
- if (batchSize && buildBatch.length > batchSize) {
251
- for (let i = 0; i < buildBatch.length; i += batchSize) {
252
- const chunk = buildBatch.slice(i, i + batchSize);
253
- buildBatches.push(chunk);
253
+ if (batchSize && entryPoints.length > batchSize) {
254
+ for (let i = 0; i < entryPoints.length; i += batchSize) {
255
+ const chunk = entryPoints.slice(i, i + batchSize);
256
+ buildBatches.push({
257
+ entryPoints: chunk,
258
+ buildOptions: buildBatch[0].buildOptions,
259
+ });
254
260
  }
255
261
  }
256
262
  else {
257
- buildBatches.push(buildBatch);
263
+ buildBatches.push({
264
+ entryPoints,
265
+ buildOptions: buildBatch[0].buildOptions,
266
+ });
258
267
  }
259
268
  }
260
269
  return buildBatches;
@@ -1,4 +1,4 @@
1
- import { Command } from 'commander';
1
+ import { Command, InvalidArgumentError } from 'commander';
2
2
  import { getVersion } from './version.mjs';
3
3
  /**
4
4
  * Get configuration from CLI arguments
@@ -10,8 +10,8 @@ export async function getConfigFromCliArgs() {
10
10
  const program = new Command();
11
11
  program.name('cdk-booster').description('CDK Booster').version(version);
12
12
  program.option('-v, --verbose', 'Verbose logging');
13
- program.option('-b, --batch <number>', 'Number of Lambdas bundled in a batch with ESBuild');
14
- program.option('-p, --parallel <number>', 'Number of parallel ESBuild processes. You usually do not need to change this.');
13
+ program.option('-b, --batch <number>', 'Number of Lambdas bundled in a batch with ESBuild', parseInteger);
14
+ program.option('-p, --parallel <number>', 'Number of parallel ESBuild processes. You usually do not need to change this.', parseInteger);
15
15
  program.arguments('<string>');
16
16
  program.parse(process.argv);
17
17
  const args = program.opts();
@@ -23,3 +23,10 @@ export async function getConfigFromCliArgs() {
23
23
  args.entryFile = entryFile;
24
24
  return args;
25
25
  }
26
+ function parseInteger(value) {
27
+ const parsedValue = parseInt(value, 10);
28
+ if (isNaN(parsedValue)) {
29
+ throw new InvalidArgumentError('Not a number.');
30
+ }
31
+ return parsedValue;
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdk-booster",
3
- "version": "1.1.0-alpha.1",
3
+ "version": "1.1.0-alpha.2",
4
4
  "type": "module",
5
5
  "description": "Speed up AWS CDK's bundling of TypeScript/JavaScript Lambda handlers",
6
6
  "homepage": "https://www.cdkbooster.com",
@@ -1,5 +0,0 @@
1
- import { BundleSettings } from './bundleSettings.js';
2
- export type BuildTask = {
3
- buildOptions: BundleSettings;
4
- entryPoint: string;
5
- };
@@ -1 +0,0 @@
1
- export {};