I'm updating dependencies in my project (yay!) but I'm having some issues with the Slack Node SDK and @vercel/ncc.
I am maintaining a serverless function that reacts to interactive Slack messages. I am using the Slack SDK in a TypeScript environment and compiling my code with ncc for deployment to AWS Lambda.
Updating ncc from 0.23.0 to 0.24.1 throws a new error when running my compiled Lambda function.
The compiled code (with no changes to the source) from ncc version 0.24.1 triggers the error Error: Attempt to inherit from WebClient methods without inheriting from WebClient in the Slack SDK
Here is how I am using the Slack SDK (non-relevant code removed for brevity):
import {WebClient as SlackWebClient} from '@slack/web-api'
(async () => {
// The slack token is fetched from SSM
const {slackToken} = await getSecrets({environment})
const slackClient = new SlackWebClient(slackToken)
await slackClient.chat.postMessage({
channel: channelID,
thread_ts: messageID,
text: `Some message text`,
})
})
which aligns with their Posting a message with Web API documentation
I was able to compile my code with TypeScript directly, without ncc, and it does not have any issues. I would prefer to use ncc though to avoid uploading unnecessary dependencies when I deploy my serverless function. With nnc the function size is small. With all of node_modules sent to Lambda it is 60M.
P.S. thank you for creating ncc, it is fantastic 鉂わ笍
I setup a new repo https://github.com/ataylorme/ncc-0.24.1-slack-compilation-issue that re-creates the issue.
The code compiled with NCC 0.23.0 passes the mocked tests I setup but the same code compiled with NCC 0.24.1 throws the Error: Attempt to inherit from WebClient methods without inheriting from WebClient error.
You can see the test results at https://github.com/ataylorme/ncc-0.24.1-slack-compilation-issue/runs/1131194239
You can also clone the repo locally, update the NCC version, and run the tests with npm test.
Hopefully this helps you in diagnosing the issue.
I was also able to fork NCC and add a unit test for the Slack NodeJS SDK which failed in GitHub Actions with the same Error: Attempt to inherit from WebClient methods without inheriting from WebClient
Also, if it helps, the error being thrown from the Slack Node SDK is here: https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/methods.ts#L37
I'm having the same issue with @slack/web-api ^5.12.0 plus NCC 0.24.1:
Error: Attempt to inherit from WebClient methods without inheriting from WebClient
If I roll back to NCC 0.23.0 everything works.
This has been fixed in ncc version 0.25.0. A big thank you to the Vercel team for maintaining ncc!
Most helpful comment
This has been fixed in
nccversion0.25.0. A big thank you to the Vercel team for maintainingncc!