I have migrated my webpack from 3.8.1 to 4.41.2. I have been facing the issue of "this" context in standalone javascript file. Please check below code:
util.js
export const calculateSum = (a,b) => {
this.sum = 0;
this.sum += a + b;
return this.sum;
};
Please note that above is sample code depicting the issue.
While using webpack 3.8.1 I was able to use "this" object as used in above example but after migrating to 4.41.2, I am not able to do so.
I have many such cases in very large code base, so it is not feasible to change the code everywhere. Could not find such option in webpack config.
How can I fix in the new version of webpack?