launchdarkly / node-server-sdk

LaunchDarkly Server-side SDK for Node
Other
79 stars 65 forks source link

UUID (v8) causing issues when running tests using Jest #270

Closed tmcdo1 closed 1 year ago

tmcdo1 commented 1 year ago

Is this a support request? No

Describe the bug Running unit tests using Jest throws an error SyntaxError: Unexpected token 'export' related to the uuid module

To reproduce Steps to reproduce the behavior. Using TypeScript. Write unit tests using Jest that import LaunchDarkly.

Expected behavior I expect my tests to run without error

Logs

/node_modules/launchdarkly-node-server-sdk/node_modules/uuid/dist/esm-browser/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
                                                                                      ^^^^^^

SyntaxError: Unexpected token 'export'
 > 1 | import LaunchDarkly, { LDClient } from 'launchdarkly-node-server-sdk';

SDK version 6.4.3

Language version, developer tools Node: 18.12.1

OS/platform MacOS 13.1

Additional context uuid has fixed the issue with v9: https://github.com/uuidjs/uuid/issues/451#issuecomment-1377099565

I have gotten tests to run properly when adding the following to package.json

"overrides": {
    "launchdarkly-node-server-sdk": {
        "uuid": "^9.0.0"
    }
}

Should be able to fix by updating uuid dependency to v9

kinyoklion commented 1 year ago

Hey @tmcdo1,

Thank you for pointing out this issue. Filed internally as 189407.

Thank you, Ryan

kinyoklion commented 1 year ago

Hello @tmcdo1,

In the updated version of this SDK we have removed the dependency on the uuid package entirely.

The new version is located here: https://github.com/launchdarkly/js-core/tree/main/packages/sdk/server-node It also has a new package name, @launchdarkly/node-server-sdk.

Thanks, Ryan

github-actions[bot] commented 1 year ago

This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days.