As of April 2, 2024, the xk6-enhanced extension for making k6 TypeScript-compatible has been incorporated into xk6-ts.
When building the k6 command with xk6, use xk6-ts instead.
link: https://github.com/szkiba/xk6-ts
Issue
For example, if you tried to build with the following command:
xk6 build
--with github.com/LeonAdato/xk6-output-statsd@latest
--with github.com/grafana/xk6-dashboard@latest
--with github.com/szkiba/xk6-enhanced@latest
--with github.com/szkiba/xk6-dotenv@latest
You would now encounter the following error:
go: downloading github.com/szkiba/xk6-enhanced v0.2.0
go: k6 imports
github.com/szkiba/xk6-enhanced: github.com/szkiba/xk6-enhanced@v0.2.0: parsing go.mod:
module declares its path as: github.com/szkiba/xk6-ts
but was required as: github.com/szkiba/xk6-enhanced
Solution
Use xk6-ts instead of xk6-enhanced:
xk6 build
--with github.com/LeonAdato/xk6-output-statsd@latest
--with github.com/grafana/xk6-dashboard@latest
--with github.com/szkiba/xk6-ts@latest
--with github.com/szkiba/xk6-dotenv@latest
Note that xk6-ts can be temporarily disabled by setting XK6_TS
to false.
xk6-ts can be disabled by setting the XK6_TS environment variable to false.
https://github.com/szkiba/xk6-ts
When compiling TypeScript to JavaScript with webpack and running the JavaScript script, set XK6_TS
to false when executing the k6 command.
The final fix looks like this:
https://github.com/gonkunkun/k6-template/pull/4
This issue was immediately noticed because of the CI setup for k6.
CI is important…
https://gonkunblog.com/k6-create-ci-for-scneario/1937/
Please be careful with this issue.