Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any chance of upgrading to uuid v9? #6150

Open
IPWright83 opened this issue Feb 13, 2023 · 3 comments
Open

Any chance of upgrading to uuid v9? #6150

IPWright83 opened this issue Feb 13, 2023 · 3 comments
Labels
enhancement New feature proposal help wanted Community contributions are welcome. question The issue is a question. Please use Stack Overflow for questions.

Comments

@IPWright83
Copy link

Problem

When attempting to run tests within Jest, with a direct or indirect dependency on @cubejs-client/[email protected] 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/[email protected]/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'

      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/[email protected]/node_modules/jest-runtime/build/index.js:1449:14)
      at Object.<anonymous> (../../../node_modules/.pnpm/@[email protected]/node_modules/@cubejs-client/core/dist/cubejs-client-core.js:26:12)
      at Object.<anonymous> (../../core/api/build/cube/CubeQueryBuilder.js:5:15)
      at Object.<anonymous> (../../core/api/build/cube/index.js:5:13)
      at Object.<anonymous> (../../core/api/build/index.js:9:13)
      at Object.<anonymous> (../../utils/test/build/QueryClientWrapper.js:6:18)

This appears to be fixed in version 9+ of uuid. Upgrading would ease adoption. uuidjs/uuid#451 (comment)

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.

@IPWright83 IPWright83 added the question The issue is a question. Please use Stack Overflow for questions. label Feb 13, 2023
@paveltiunov paveltiunov added enhancement New feature proposal help wanted Community contributions are welcome. labels Feb 13, 2023
@github-actions
Copy link

If you are interested in working on this issue, please leave a comment below and we will be happy to assign the issue to you.
If this is the first time you are contributing a Pull Request to Cube.js, please check our contribution guidelines.
You can also post any questions while contributing in the #contributors channel in the Cube.js Slack.

@cirdes
Copy link

cirdes commented Apr 25, 2023

@IPWright83 , same problem here! Thanks for the workaround. Waiting for the fix!

@joaobibiano
Copy link

Same problem here, using the workaround but definitely the team should fix that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature proposal help wanted Community contributions are welcome. question The issue is a question. Please use Stack Overflow for questions.
Projects
None yet
Development

No branches or pull requests

4 participants