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
Error loading certain minified JS libraries #1126
Comments
I'm using the k6 docker image with Typescript-compiled scriptsw and I'm seeing a similar issue trying to import local packages such as chai.
Produces this at runtime:
Similarly, if I enable Typescript's
|
@jedkcanderson, I'm not very familiar with TypeScript, but it's normal for You have to use something like |
Also, k6 does not support TypeScript (#422), but you can somewhat mitigate both problems by using my k6-es6 project which uses nodejs, webpack and babel to combine your script in one single file and do the nodejs module resolution, as well as polyfill what is needed for anything that comes from npm for you ... which hopefully will make it work. |
This was fixed by dop251/goja#221, now we should only need to update goja (and test to double-check) to close this... |
I tested with
as the path has changed.. I decided to pin the current latest version with its commit. This still breaks with the same error on 0.28.0 but works with the changes from #1707 |
I ran into this issue when trying to import the latest minified release of faker.js.
Example:
Running
k6 run -v test.js
outputs:Note that this doesn't happen with non-minified releases, or the older minified version from CDNJS (https://cdnjs.cloudflare.com/ajax/libs/Faker/3.1.0/faker.min.js), which work fine.
It seems that the
1e3
(scientific notation for1000
) dependency is incorrectly interpreted as a URL at some point, which k6 attempts to load and fails.Strangely enough, manually changing the
1e3
reference in the minified JS to1000
fixes the issue, so this seems like either Goja or k6 misinterpreting scientific notation, for some reason. A quick test ofvm.RunString("1 + 1e3")
correctly returns1001
, however, so this must be something deeper with how it resolves imports.The text was updated successfully, but these errors were encountered: