I have 2 js files. First file:
var object1 = {
foo: 'bar'
}
Second file
var object2 = {
foo2: 'bar2'
}
console.log(object1.foo);
These 2 files are created using webpack in the bundle.js file. But in this case I have problems: the variable object1 is not defined.
I analyzed the code in the bundle.js file - webpack create a file for each anonymous function - and I understand why I have an error.
Is it possible to do this with webpack or not?
Off course, I can use this variable as a global variable, but I think this is not a good idea.
source
share