cdk-booster 1.1.3 → 1.2.0
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.
- package/README.md +20 -0
- package/dist/cdk-booster.mjs +25 -18
- package/dist/cdkFrameworkWorker.mjs +8 -8
- package/dist/getConfigFromCliArgs.mjs +1 -0
- package/dist/types/cbConfig.d.ts +4 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -73,6 +73,26 @@ To enable verbose logging for debugging purposes, add the `-v` parameter:
|
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
#### TypeScript Configuration (`--tsconfig`)
|
|
77
|
+
|
|
78
|
+
Specifies the path to a custom `tsconfig.json` file for bundling CDK code.
|
|
79
|
+
|
|
80
|
+
**Default:** Uses the default TypeScript configuration discovery
|
|
81
|
+
|
|
82
|
+
**When to use:**
|
|
83
|
+
|
|
84
|
+
- When your project uses a custom tsconfig location
|
|
85
|
+
- When you need specific TypeScript compiler options for CDK code
|
|
86
|
+
|
|
87
|
+
**Example:**
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"app": "npx cdk-booster bin/your_app.ts --tsconfig tsconfig.build.json",
|
|
92
|
+
...
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
76
96
|
#### Batch Size (`-b`, `--batch`)
|
|
77
97
|
|
|
78
98
|
Controls the number of Lambda functions bundled together in a single ESBuild batch. This is particularly useful for large projects with many Lambda functions (100+).
|
package/dist/cdk-booster.mjs
CHANGED
|
@@ -41,6 +41,7 @@ async function run() {
|
|
|
41
41
|
const compileCodeFile = await compileCdk({
|
|
42
42
|
rootDir,
|
|
43
43
|
entryFile: config.entryFile,
|
|
44
|
+
tsconfig: config.tsconfig,
|
|
44
45
|
});
|
|
45
46
|
Logger.verbose(` Running the CDK code ${compileCodeFile} to extract Lambda functions.`);
|
|
46
47
|
const secondRun = await isSecondRun();
|
|
@@ -56,24 +57,29 @@ async function run() {
|
|
|
56
57
|
let lambdasEsBuildCommands = lambdas;
|
|
57
58
|
// skip all lambdas that have SKIP_CDK_BOOSTER env var set to true in their bundling environment
|
|
58
59
|
lambdasEsBuildCommands = lambdasEsBuildCommands.filter((lambda) => lambda.environment?.SKIP_CDK_BOOSTER !== 'true');
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
if (lambdasEsBuildCommands.length === 0) {
|
|
61
|
+
Logger.log(`No Lambda functions found by the CDK Booster. Skipping bundling.`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Prepare bundling temp folders for each Lambda function
|
|
65
|
+
await recreateBundlingTempFolders(lambdasEsBuildCommands);
|
|
66
|
+
// Execute pre-bundling commands
|
|
67
|
+
await executeCommands(lambdasEsBuildCommands, 'commandBeforeBundling');
|
|
68
|
+
const outputs = await bundle(lambdasEsBuildCommands);
|
|
69
|
+
// move files to the output folder
|
|
70
|
+
await copyFilesToOutput(lambdasEsBuildCommands, outputs);
|
|
71
|
+
// Execute post-bundling commands
|
|
72
|
+
await executeCommands(lambdasEsBuildCommands, 'commandAfterBundling');
|
|
73
|
+
if (missing) {
|
|
74
|
+
copyAgainFunction = async () => {
|
|
75
|
+
await recreateBundlingTempFolders(lambdasEsBuildCommands);
|
|
76
|
+
await executeCommands(lambdasEsBuildCommands, 'commandBeforeBundling');
|
|
77
|
+
await copyFilesToOutput(lambdasEsBuildCommands, outputs);
|
|
78
|
+
await executeCommands(lambdasEsBuildCommands, 'commandAfterBundling');
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
Logger.log(`All Lambda functions have been built and copied to the output folder.`);
|
|
75
82
|
}
|
|
76
|
-
Logger.log(`All Lambda functions have been built and copied to the output folder.`);
|
|
77
83
|
}
|
|
78
84
|
Logger.log(`Starting to run regular CDK code.`);
|
|
79
85
|
// Regular import and execution of the compiled CDK code
|
|
@@ -364,7 +370,7 @@ async function recreateBundlingTempFolders(lambdasEsBuildCommands) {
|
|
|
364
370
|
* @param options - Compilation options including root directory and entry file
|
|
365
371
|
* @returns Path to the compiled CDK code file
|
|
366
372
|
*/
|
|
367
|
-
async function compileCdk({ rootDir, entryFile, }) {
|
|
373
|
+
async function compileCdk({ rootDir, entryFile, tsconfig, }) {
|
|
368
374
|
const isESM = await isEsm(entryFile);
|
|
369
375
|
// Plugin that:
|
|
370
376
|
// - Fixes __dirname issues in bundled code
|
|
@@ -527,6 +533,7 @@ async function compileCdk({ rootDir, entryFile, }) {
|
|
|
527
533
|
outfile: compileCodeFile,
|
|
528
534
|
sourcemap: false,
|
|
529
535
|
plugins: [injectCodePlugin],
|
|
536
|
+
tsconfig: tsconfig,
|
|
530
537
|
...(isESM
|
|
531
538
|
? {
|
|
532
539
|
format: 'esm',
|
|
@@ -23,16 +23,16 @@ parentPort.on('message', async (data) => {
|
|
|
23
23
|
global.cdkApp.synth = () => undefined; // prevent call
|
|
24
24
|
const missing = !!cloudAssembly.manifest.missing;
|
|
25
25
|
|
|
26
|
-
if (!global.lambdas || global.lambdas?.length === 0) {
|
|
27
|
-
throw new Error('No Lambda functions found in the CDK code');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
const lambdas = global.lambdas;
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
`[Worker]
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
if (!global.lambdas || global.lambdas?.length === 0) {
|
|
29
|
+
Logger.verbose(`[Worker] No Lambda functions found.`);
|
|
30
|
+
} else {
|
|
31
|
+
Logger.verbose(
|
|
32
|
+
`[Worker] Sending found Lambdas`,
|
|
33
|
+
JSON.stringify(lambdas, null, 2),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
36
|
Logger.verbose(
|
|
37
37
|
`[Worker] ${missing ? 'Some resources are missing and need to be looked up. Synth will have to be run twice.' : 'All resources are resolved.'}`,
|
|
38
38
|
);
|
|
@@ -12,6 +12,7 @@ export async function getConfigFromCliArgs() {
|
|
|
12
12
|
program.option('-v, --verbose', 'Verbose logging');
|
|
13
13
|
program.option('-b, --batch <number>', 'Number of Lambdas bundled in a batch with ESBuild', parseInteger);
|
|
14
14
|
program.option('-p, --parallel <number>', 'Number of parallel ESBuild processes. You usually do not need to change this.', parseInteger);
|
|
15
|
+
program.option('--tsconfig <path>', 'Path to tsconfig.json file for bundling CDK code');
|
|
15
16
|
program.arguments('<string>');
|
|
16
17
|
program.parse(process.argv);
|
|
17
18
|
const args = program.opts();
|
package/dist/types/cbConfig.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdk-booster",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -65,18 +65,18 @@
|
|
|
65
65
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
66
66
|
"@types/node": "^24.10.1",
|
|
67
67
|
"aws-cdk": "2.1033.0",
|
|
68
|
-
"aws-cdk-lib": "2.
|
|
68
|
+
"aws-cdk-lib": "2.231.0",
|
|
69
69
|
"constructs": "^10.4.3",
|
|
70
70
|
"eslint": "^9.39.1",
|
|
71
71
|
"eslint-config-prettier": "^10.1.8",
|
|
72
72
|
"globals": "^16.5.0",
|
|
73
73
|
"husky": "^9.1.7",
|
|
74
|
-
"prettier": "^3.
|
|
74
|
+
"prettier": "^3.7.4",
|
|
75
75
|
"semantic-release": "^25.0.2",
|
|
76
|
-
"tsx": "^4.
|
|
77
|
-
"typescript-eslint": "^8.
|
|
76
|
+
"tsx": "^4.21.0",
|
|
77
|
+
"typescript-eslint": "^8.48.1",
|
|
78
78
|
"vitepress": "^1.6.4",
|
|
79
|
-
"@aws-sdk/client-lambda": "^3.
|
|
79
|
+
"@aws-sdk/client-lambda": "^3.943.0",
|
|
80
80
|
"adm-zip": "^0.5.16",
|
|
81
81
|
"@types/adm-zip": "^0.5.7"
|
|
82
82
|
},
|