Ncc: 0.24.1 TypeScript compilation triggers Slack SDK error

Created on 16 Sep 2020  路  5Comments  路  Source: vercel/ncc

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 鉂わ笍

bug

Most helpful comment

This has been fixed in ncc version 0.25.0. A big thank you to the Vercel team for maintaining ncc!

All 5 comments

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.

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benseitz picture benseitz  路  5Comments

hrueger picture hrueger  路  4Comments

GiladShoham picture GiladShoham  路  3Comments

lucleray picture lucleray  路  3Comments

guybedford picture guybedford  路  5Comments