From f4f72c87a9cba0c3400842bd78cc57177c2fc773 Mon Sep 17 00:00:00 2001 From: spotchi Date: Fri, 21 Feb 2025 10:16:37 +0100 Subject: [PATCH 1/2] Use js loader for cjs files --- src/frameworks/cdkFramework.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frameworks/cdkFramework.ts b/src/frameworks/cdkFramework.ts index 200d0e3e..523ef1d0 100755 --- a/src/frameworks/cdkFramework.ts +++ b/src/frameworks/cdkFramework.ts @@ -283,8 +283,9 @@ export class CdkFramework implements IFramework { // for .mjs files, use js loader const fileExtension = args.path.split('.').pop(); const loader: esbuild.Loader = - fileExtension === 'mjs' ? 'js' : (fileExtension as esbuild.Loader); - + (fileExtension === 'mjs' || fileExtension === 'cjs') + ? 'js' + : (fileExtension as esbuild.Loader); // Inject code to get the file path of the Lambda function and CDK hierarchy if (args.path.includes('aws-cdk-lib/aws-lambda/lib/function.')) { const codeToFind = From 8dbd7fe797f2cb42d91286b2c2271cd9e3cb98d8 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Sun, 23 Feb 2025 09:03:26 +0100 Subject: [PATCH 2/2] fix #89: Use js loader for cjs files in CDK --- README.md | 1 + src/frameworks/cdkFramework.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3616f9d..fc1b7c28 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,7 @@ If you have a new feature idea, please create and issue. - [Roger Chi](https://rogerchi.com/) - [Sebastian / avocadomaster](https://github.com/avocadomaster) - [Sebastian Bille](https://blog.sebastianbille.com) +- [Spotchi](https://github.com/Spotchi) - ⭐ Your name here for notable code or documentation contributions or sample projects submitted with a bug report that resulted in tool improvement. ## Disclaimer diff --git a/src/frameworks/cdkFramework.ts b/src/frameworks/cdkFramework.ts index 523ef1d0..bf86c9e2 100755 --- a/src/frameworks/cdkFramework.ts +++ b/src/frameworks/cdkFramework.ts @@ -283,7 +283,7 @@ export class CdkFramework implements IFramework { // for .mjs files, use js loader const fileExtension = args.path.split('.').pop(); const loader: esbuild.Loader = - (fileExtension === 'mjs' || fileExtension === 'cjs') + fileExtension === 'mjs' || fileExtension === 'cjs' ? 'js' : (fileExtension as esbuild.Loader); // Inject code to get the file path of the Lambda function and CDK hierarchy