addMethod.js
function add(){
// do something
}
Let say, I have a function add
which can be accessed globally. But when I bundled this file with webpack(v4) I am facing an error add of undefined
when I ran that file in the browser.
So far in my research, I have only come across people recommending that global functions and methods must be appended to window object
The problem is in a larger project, how do I handle these kinds of problems?
I know I can use export or window
keyword.
But I am looking for any webpack plugin that will take care of this, instead of me having to update every file in my project??
Note: Webpack version - 4 and ES5