-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Hi @simskij ,
I'm struggling with making your template working with chunking files.
It works great when each output script embeds everything (its own imports) in its final .js file, but it makes my computer rewriting each time this full file for nothing (because only my k6 scenario changes, not imported dependencies).
The idea has been to add:
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
// cacheGroupKey here is `commons` as the key of the cacheGroup
name(module, chunks, cacheGroupKey) {
return `${cacheGroupKey}`;
},
chunks: 'all'
}
}
}
},
So dependencies are in their own final .js file and are imported by the scenario files (test1.js and test2.js in your example). But... I get this error:
ReferenceError: window is not defined at file:///Users/XXXXXXXXX/dist/test2.js:144:28(64)
Indeed this line will break:
var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
It seems to be necessary to append dependencies...
since we are not in a real browser when executing the scenario... I tried multiple possibilities but never succeed. Setting target=node
is not working also to prevent compiling dependencies with browser stuff.
Do you know a workaround so I can chunk common files while being able to import them?
Thank you,