Skip to content

Invalid loader value: "cjs" #89

@Spotchi

Description

@Spotchi

I am using Lambda Live Debugger for the first time with CDK.
I am using a Slack client in one of my lambdas, with axios as a transitive dependency.

Here's the offending dependency :

"@slack/web-api": "^7.8.0",

The LLD output

Starting the debugger (ID 10a57bf796ffb60a02253f2a2a376d72)...
Changing current folder to /Users/quentinlaurent/Desktop/app/cdk
Getting resources with 'cdk' framework
[CDK] Entry file: /Users/quentinlaurent/Desktop/app/cdk/bin/cdk.ts
[CDK] Using ESM format
✘ [ERROR] Invalid loader value: "cjs" [plugin injectCode]

    node_modules/@slack/web-api/dist/WebClient.js:72:40:
      72 │ const axios_1 = __importDefault(require("axios"));
         ╵                                         ~~~~~~~

Error: Error building CDK code: Build failed with 1 error:
node_modules/@slack/web-api/dist/WebClient.js:72:40: ERROR: [plugin: injectCode] Invalid loader value: "cjs"
    at CdkFramework.getLambdasDataFromCdkByCompilingAndRunning (file:///Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/dist/frameworks/cdkFramework.mjs:288:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async CdkFramework.getLambdas (file:///Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/dist/frameworks/cdkFramework.mjs:51:30)
    at async Object.getLambdas (file:///Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/dist/resourceDiscovery.mjs:43:21)
    at async Object.discoverLambdas (file:///Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/dist/configuration.mjs:115:26)
    at async run (file:///Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/dist/lldebugger.mjs:54:5) {
  [cause]: Error: Build failed with 1 error:
  node_modules/@slack/web-api/dist/WebClient.js:72:40: ERROR: [plugin: injectCode] Invalid loader value: "cjs"
      at failureErrorWithLog (/Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:1651:15)
      at /Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:1059:25
      at runOnEndCallbacks (/Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:1486:45)
      at buildResponseToResult (/Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:1057:7)
      at /Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:1086:16
      at responseCallbacks.<computed> (/Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:704:9)
      at handleIncomingPacket (/Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:764:9)
      at Socket.readFromStdout (/Users/quentinlaurent/Desktop/qualia/lambda-live-debugger/node_modules/esbuild/lib/main.js:680:7)
      at Socket.emit (node:events:517:28)
      at addChunk (node:internal/streams/readable:368:12) {
    errors: [Getter/Setter],
    warnings: [Getter/Setter]
  }
}

I did find a similar issue in this repo with mjs files : #78

It seems to me that a similar fix could be applied for cjs files?

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions