Transpilation issue

I’m trying to use the library “openapi-request-validator” with K6.
I used the following template : GitHub - grafana/k6-template-typescript: Template to use TypeScript with k6
When running, K6 fail with an error :

ERRO[0000] SyntaxError: file:///Users/geoffreyragot/Work/numary/k6/dist/all-test.js: Unexpected token (1962:24)
  1960 |   binary: true
  1961 | };
> 1962 | exports.fastFormats = { ...exports.fullFormats,
       |                         ^

It seems to be a transpilation issue.
The code which use the syntax is located at “node_modules/openapi-request-validator/node_modules/ajv-formats”.
I don’t find how to indicate to babel to transpile this module.
Any idea?

Hi @gfyrag, welcome to the community forum!

I’ve managed to find a way to fix this and likely will make a PR to the main repo(as there are quire a bit). Unfortunately I then hit a different issue with regexp for which I have opened a PR which is not going to get in the v0.39.0 we are about to release next week.

This likely means that a fix for this will be merged in the release after that, but maybe it will have to wait for v0.40.0 in two months :frowning:

Will keep this post updated on the issue as well.

Ok, thks. I will find another solution and retry when the release will be available :slight_smile:

@gfyrag can you try the changes from node modules weren't transpiled by babel by mstoykov · Pull Request #25 · grafana/k6-template-typescript · GitHub

With those and the latest v0.38.3 I managed to make a very basic script work

@gfyrag have you had time to try the changes I linked?