webpack 4 appears to be adding code like this into the bundle
try {
n = n || new Function("return this")();
} catch (e) {
"object" == typeof window && (n = window);
}
We have strict security which means this will fail csp because of the new Function
code.
Adding unsafe-eval
to csp is not an option unfortunately.
Is it possible to stop wepback from adding this code?
I have tried setting node to the following:
node: {
module: 'empty',
dgram: 'empty',
dns: 'mock',
fs: 'empty',
http2: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
setImmediate: false,
setTimeout: false,
setInterval: false,
global: false
},
I have set devtool
like this:
devtool: 'cheap-module-source-map',
and I have set globlObject
to window
globalObject: 'window',
This has reduced the number of new Function
calls but it has not removed them.
Ideally we should be using this polyfill