Reputation: 79
I have a file where i defined the absolute path of directory.
Ex : script=/absolutepath/scripts
utility=/absolutepath/utility
I want to use "script"/"utility" instead of absolute path in other javascript files.How i can do this.
What i want :
import random from "script/random.js"
instead of
import random from "/absolutepath/scripts/random.js"
PS :I am using k6 load generating framework which doesn't support node modules.
Upvotes: 0
Views: 2608
Reputation: 1
You could try using importmaps.
Inside your index.html
:
<html lang="en">
<head>
<script type="importmaps">
{
"imports": {
"random": "/absolutePath/scripts/random.js"
}
}
</script>
<script type="module" src="app.js"></script>
</head>
</html>
You can now import your module from ANYWHERE
import random from 'random'
Upvotes: 0
Reputation: 1106
You currently can't do that in k6 v0.26.0.
Import paths like that are reserved for internal k6 modules (e.g. k6/http
) and "magic" remote import URLs (e.g. import from github.com/loadimpact/k6/samples/thresholds_readme_example.js
instead of https://raw.githubusercontent.com/loadimpact/k6/master/samples/thresholds_readme_example.js
, and we're trying to softly discourage this). You can't define your own, you either have to use relative paths or absolute paths when importing your own JS files.
Upvotes: 1