I see the release here indicates typescript can now be done without using something to compile the typescript and bundle it into a single js file. New Grafana k6 features: TypeScript support, async APIs for browser, and more | Grafana Labs
But I’m only able to get my test to work if the typescript is completely contained in a single file. Once I try to start to make some other typescript files with come functions that I’m exporting (for code reuse), then I get the error:
import http from 'k6/http';
import { sleep, check } from 'k6';
import * as utils from './utils';
// rest of code left out
my structure is
/my-test-file.ts
/utils/index.ts
/utils/utils.ts
error is:
DEBU[0000] Everything has finished, exiting k6 with an error! error="could not initialize ‘.\my-first-test.ts’: could not load JS test …
However if I compile the *.ts files with just the tsc cli, it copmiles fine, but obviously all the *.js files aren’t bundled, and it will not be able to import the modules unless I used something like commonjs, and then I’m back to webpack or something else, which I don’t want to do.