Open fullheart opened 1 month ago
This repo doesn't build with tsc directly but with webpack
. You can look at the documentation. And webpack specifically doesn't look into https://
imports as they are usually not supported. I am not even certain tsc
supports remote modules import. Looking at the error it seems like it doesn't do it well.
btw, what are you trying to do? You don't need to compile the module it is already available in jslib.
Thanks @mstoykov for you answer.
Our k6 use case We are load testing our AWS SageMaker endpoints (ML models) with k6. Our project is written in TypeScript (using Vite to compile into JavaScript files). We have built a k6 client to invoke a SageMaker endpoint. These components are used from this repo:
import { AWSConfig, SignatureV4 } from "k6-jslib-aws";
import { AWSClient } from "k6-jslib-aws/src/internal/client";
import { HTTPRequest, SignedHTTPRequest } from "k6-jslib-aws/src/internal/http";
With tsc
the CI pipeline validates the .ts
files.
We work around this problem for now with this patch (created with patch-package
):
diff --git a/node_modules/k6-jslib-aws/src/internal/secrets-manager.ts b/node_modules/k6-jslib-aws/src/internal/secrets-manager.ts
index cd5967f..dc9148c 100644
--- a/node_modules/k6-jslib-aws/src/internal/secrets-manager.ts
+++ b/node_modules/k6-jslib-aws/src/internal/secrets-manager.ts
@@ -1,5 +1,6 @@
import { JSONArray, JSONObject } from 'k6'
import http, { RefinedResponse, ResponseType } from 'k6/http'
+// @ts-ignore
import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js'
import { AWSClient } from './client'
@oleiade do we want to get this in our code as well?
Just to confirm my understanding, a fix that would cater to the problem would be to add a // @ts-ignore
statement on our import statement of k6-utils
in jslib-aws. Is that correct @fullheart ?
Thanks @mstoykov and @oleiade
Yes, adding the // @ts-ignore
line would be a solution.
Another solution would be, when you can add a type definition file (d.ts
) in the @types/k6
package that contains all function of this utils package. Example:
declare module 'https://jslib.k6.io/k6-utils/1.4.0/index.js' {
export function uuidv4(): string;
// TODO: Add all functions of utils package (https://grafana.com/docs/k6/latest/javascript-api/jslib/utils/#utils)
}
I prefer the second solution to having typed utils functions.
After upgrading to latest version (0.13.0) to resolve a bug, I got an other problem:
Versions: k6-jslib-aws
v0.13.0
, @types/k60.54.0
Steps to reproduce