Skip to content

Commit a8abad1

Browse files
fix: #78 Fails with Invalid loader value: "mjs" (CDK ESM module) (#80)
1 parent 1f3371b commit a8abad1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ If you have a new feature idea, please create and issue.
324324

325325
(alphabetical)
326326

327+
- [Kristian Dreher](https://www.linkedin.com/in/kristiandreher)
327328
- [Roger Chi](https://rogerchi.com/)
328329
- [Sebastian Bille](https://blog.sebastianbille.com)
329330
- ⭐ Your name here for notable code or documentation contributions or sample projects submitted with a bug report that resulted in tool improvement.

src/frameworks/cdkFramework.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ export class CdkFramework implements IFramework {
280280
contents = fileContent;
281281
}
282282

283-
const loader = args.path.split('.').pop() as esbuild.Loader;
283+
// for .mjs files, use js loader
284+
const fileExtension = args.path.split('.').pop();
285+
const loader: esbuild.Loader =
286+
fileExtension === 'mjs' ? 'js' : (fileExtension as esbuild.Loader);
284287

285288
// Inject code to get the file path of the Lambda function and CDK hierarchy
286289
if (args.path.includes('aws-cdk-lib/aws-lambda/lib/function.')) {
@@ -309,12 +312,12 @@ export class CdkFramework implements IFramework {
309312
};
310313
311314
// console.log("CDK INFRA: ", {
312-
// stackName: lambdaInfo.stackName,
313-
// codePath: lambdaInfo.codePath,
314-
// code: lambdaInfo.code,
315-
// handler: lambdaInfo.handler,
316-
// bundling: lambdaInfo.bundling
317-
// });
315+
// stackName: lambdaInfo.stackName,
316+
// codePath: lambdaInfo.codePath,
317+
// code: lambdaInfo.code,
318+
// handler: lambdaInfo.handler,
319+
// bundling: lambdaInfo.bundling
320+
// });
318321
global.lambdas.push(lambdaInfo);` + codeToFind,
319322
);
320323
}

0 commit comments

Comments
 (0)