I have a node JS application where there exist multiple modules for header and URL of APIs. I want to reuse those modules in my k6 script.
- I tried webpack bundling
- Then accessing the bundle.js in the k6 script
- Then, running the script as usual with “k6 run k6-script.js” but didnt work.
Any changes that I can make in this bundling or running process?
Accessing the bundle.js like this:
import hello from ‘…/…/config/dist/bundle’;
This is what the webpack.config.js looks like:
const path = require('path');
var webpack = require('webpack');
module.exports = {
mode: 'production',
entry: 'testing.client.helper.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: "commonjs2",
},
module: {
rules: [{ test: /\.js$/, use: 'babel-loader' }],
},
target: 'web',
externals: /^(k6|https?\:\/\/)(\/.*)?/,
};