cube-js / cube-js/cube

Any chance of upgrading to uuid v9?

Open
#6,150 3 comments 3 reactions 0 assignees View on GitHub
help wanted question
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Problem**

When attempting to run tests within Jest, with a direct or indirect dependency on `@cubejs-client/core@0.13.46` we hit this issue:
```
Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/home/ian/src/webclient/node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-browser/index.js:1
({"Object.":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';

SyntaxError: Unexpected token 'export'

3 | return new (P || (P = Promise))(function (resolve, reject) {
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
> 5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
| ^
6 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
8 | });

at Runtime.createScriptFromCode (../../../node_modules/.pnpm/jest-runtime@29.3.1/node_modules/jest-runtime/build/index.js:1449:14)
at Object. (../../../node_modules/.pnpm/@cubejs-client+core@0.31.46/node_modules/@cubejs-client/core/dist/cubejs-client-core.js:26:12)
at Object. (../../core/api/build/cube/CubeQueryBuilder.js:5:15)
at Object. (../../core/api/build/cube/index.js:5:13)
at Object. (../../core/api/build/index.js:9:13)
at Object. (../../utils/test/build/QueryClientWrapper.js:6:18)
```

This appears to be fixed in version 9+ of uuid. Upgrading would ease adoption. https://github.com/uuidjs/uuid/issues/451#issuecomment-1377099565

I believe the reference is likely https://github.com/cube-js/cube.js/blob/c4f51f457dbebec60f4848b951d2604de2512631/packages/cubejs-api-gateway/package.json#L47

**Workaround:**
There is a workaround which is to add the same version of `uuid` that cubejs requires as a peer dependency and a dev dependency, and then use `'^uuid$': require.resolve('uuid')` within the jest.config `moduleNameMapper` section. In a monorepo however, this requires quite a lot of painful duplication.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.