I’m trying to resolve a node module to be able to create webrtc connection needed for some of our tests based on the pattern and config presented here:
Webpack config:
module.exports = {
mode: 'production',
output: {
path: path.join(__dirname, 'dist'),
libraryTarget: 'commonjs',
filename: '[name].js',
},
entry: entry(entry.basePath('scripts'), './scripts/**/*.js'),
resolve: {
fallback: {
https: require.resolve('https-browserify'),
"url": require.resolve("url/"),
"http": require.resolve("stream-http"),
"buffer": require.resolve("buffer/")
},
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
},
],
},
externals: /^(k6|https?\:\/\/)(\/.*)?/,
stats: {
colors: true,
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{
context: './lib',
from: './fake-data/*.json',
},
],
}),
],
It works with presented node packages, but with the one I work with it fails on the babel compilation stage with error like
k6-load-tests/dist/test.js: Unexpected token, expected ( (2:175532)
^
at <internal/k6/compiler/lib/babel.min.js>:7:10099(24)
at <internal/k6/compiler/lib/babel.min.js>:5:29529(56)
at <internal/k6/compiler/lib/babel.min.js>:7:8385(51)
at <internal/k6/compiler/lib/babel.min.js>:7:5838(57)
at <internal/k6/compiler/lib/babel.min.js>:7:3622(281)
at <internal/k6/compiler/lib/babel.min.js>:6:30266(598)
at <internal/k6/compiler/lib/babel.min.js>:6:25697(16)
at <internal/k6/compiler/lib/babel.min.js>:6:25286(124)
at <internal/k6/compiler/lib/babel.min.js>:6:23854(12)
at <internal/k6/compiler/lib/babel.min.js>:6:23442(13)
at <internal/k6/compiler/lib/babel.min.js>:6:22671(73)
at <internal/k6/compiler/lib/babel.min.js>:6:5488(27)
at <internal/k6/compiler/lib/babel.min.js>:6:2562(11)
at <internal/k6/compiler/lib/babel.min.js>:5:31032(259)
at <internal/k6/compiler/lib/babel.min.js>:6:4439(38)
at <internal/k6/compiler/lib/babel.min.js>:6:4049(19)
at <internal/k6/compiler/lib/babel.min.js>:7:7060(62)
at <internal/k6/compiler/lib/babel.min.js>:7:6374(21)
at <internal/k6/compiler/lib/babel.min.js>:7:613(225)
at <internal/k6/compiler/lib/babel.min.js>:6:30046(561)
at <internal/k6/compiler/lib/babel.min.js>:6:25697(16)
at <internal/k6/compiler/lib/babel.min.js>:6:25286(124)
at <internal/k6/compiler/lib/babel.min.js>:6:23854(12)
at <internal/k6/compiler/lib/babel.min.js>:6:23442(13)
at <internal/k6/compiler/lib/babel.min.js>:6:22671(73)
at <internal/k6/compiler/lib/babel.min.js>:7:5011(25)
at <internal/k6/compiler/lib/babel.min.js>:7:5503(16)
at <internal/k6/compiler/lib/babel.min.js>:7:3648(292)
at <internal/k6/compiler/lib/babel.min.js>:6:30266(598)
at <internal/k6/compiler/lib/babel.min.js>:6:25697(16)
at <internal/k6/compiler/lib/babel.min.js>:6:25286(124)
at <internal/k6/compiler/lib/babel.min.js>:6:23854(12)
at <internal/k6/compiler/lib/babel.min.js>:6:23442(13)
at <internal/k6/compiler/lib/babel.min.js>:6:22671(73)
at <internal/k6/compiler/lib/babel.min.js>:6:5488(27)
at <internal/k6/compiler/lib/babel.min.js>:6:2562(11)
at <internal/k6/compiler/lib/babel.min.js>:5:31032(259)
at <internal/k6/compiler/lib/babel.min.js>:6:4439(38)
at <internal/k6/compiler/lib/babel.min.js>:6:4049(19)
at <internal/k6/compiler/lib/babel.min.js>:7:7060(62)
at <internal/k6/compiler/lib/babel.min.js>:7:6374(21)
at <internal/k6/compiler/lib/babel.min.js>:7:613(225)
at <internal/k6/compiler/lib/babel.min.js>:6:30046(561)
at <internal/k6/compiler/lib/babel.min.js>:6:25697(16)
at <internal/k6/compiler/lib/babel.min.js>:6:25286(124)
at <internal/k6/compiler/lib/babel.min.js>:6:23854(12)
at <internal/k6/compiler/lib/babel.min.js>:6:23442(13)
at <internal/k6/compiler/lib/babel.min.js>:6:22671(73)
at <internal/k6/compiler/lib/babel.min.js>:7:176(119)
at <internal/k6/compiler/lib/babel.min.js>:6:30046(561)
at <internal/k6/compiler/lib/babel.min.js>:6:25697(16)
at <internal/k6/compiler/lib/babel.min.js>:6:25286(124)
at <internal/k6/compiler/lib/babel.min.js>:6:23854(12)
at <internal/k6/compiler/lib/babel.min.js>:6:23442(13)
at <internal/k6/compiler/lib/babel.min.js>:6:22671(73)
at <internal/k6/compiler/lib/babel.min.js>:6:22078(13)
at <internal/k6/compiler/lib/babel.min.js>:5:31890(386)
at <internal/k6/compiler/lib/babel.min.js>:6:4439(38)
at <internal/k6/compiler/lib/babel.min.js>:5:29672(15)
at <internal/k6/compiler/lib/babel.min.js>:5:28444(17)
at h (<internal/k6/compiler/lib/babel.min.js>:4:30563(6))
at <internal/k6/compiler/lib/babel.min.js>:2:27418(93)
at <internal/k6/compiler/lib/babel.min.js>:2:28703(9)
at <internal/k6/compiler/lib/babel.min.js>:14:24458(9)
at <internal/k6/compiler/lib/babel.min.js>:2:28270(21)
at <internal/k6/compiler/lib/babel.min.js>:14:24413(11)
at bound (native)
at s (<internal/k6/compiler/lib/babel.min.js>:1:1327(8)) hint="script exception"
The char where the error message points to is ‘=’ var ye={...Object.freeze({__proto__:null,hasBrowserEnv:le,hasStandardBrowserWebWorkerEnv:pe,hasStandardBrowserEnv:fe,origin:de})
Any idea where to look at the first place? Is it webpack \ babel issue? Some pluggins are needed maybe?