Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
375 stars 178 forks source link

tslib is required with importHelpers - autoclosed #785

Closed lawrenceong closed 1 year ago

lawrenceong commented 1 year ago

Expected Behavior

Able to start up a service using @vonage/server-sdk without any issue

Current Behavior

When using typescript with @vonage/server-sdk and without the presence of tslib, the following error is being encountered:

Error: Cannot find module 'tslib'
Require stack:
- /app/node_modules/@vonage/accounts/dist/accounts.js
- /app/node_modules/@vonage/accounts/dist/index.js
- /app/node_modules/@vonage/server-sdk/dist/vonage.js
- /app/node_modules/@vonage/server-sdk/dist/index.js
...

The reason why this is happening is because of the introduction of importHelpers as part of the commit #746. As per the documentation at https://www.npmjs.com/package/tslib, it stated that:

This is a runtime library for TypeScript that contains all of the TypeScript helper functions. This library is primarily used by the --importHelpers flag in TypeScript

Possible Solution

Either:

Steps to Reproduce (for bugs)

  1. Create a very simple project and install the libraries as such
    npm i @vonage/server-sdk
    npm i -D @types/node typescript
  2. Create a tsconfig.json file with the following contents
    {
      "compilerOptions": {
        "module": "commonjs",
        "outDir": "./dist",
        "esModuleInterop": true,
        "baseUrl": "./",
        "paths": {
          "*": ["src/*"]
        }
      }
    }
  3. Create a very simple typescript file, eg. src/test.ts

    import { Vonage } from '@vonage/server-sdk';
    
    const client = new Vonage({
      apiKey: "junk",
      apiSecret: "junk",
    } as any);
  4. Compile it to js by running npx tsc
  5. Run the file using node dist/test.js to see the error

Context

We needed to install tslib as part of our package when it should actually be as part of the dependencies from @vonage/server-sdk. Service fails to startup otherwise.

Your Environment

mend-for-github-com[bot] commented 1 year ago

:heavy_check_mark: This issue was automatically closed by Mend because the errors have been resolved.

manchuck commented 1 year ago

@lawrenceong importHelpers have been removed. you should be g2g now