How Can I Use Webpack to Concatenate JavaScript Files Without Breaking Global Scope? [duplicate]

I’m using Webpack for my JavaScript files, and my goal is simply to concatenate them. However, I’m unsure if Webpack can achieve this.

Here’s an example:

file1.js

var app = getApp();

file2.js

app.work();

In the browser, I use:

<script src="file1.js"></script>
<script src="file2.js"></script>

This works because app is stored on the global object (var/window).

However, when I use Webpack, it generates something like:

(() => {
  eval(`var app = ...`);
})();
(() => {
  eval(`app.work()...`);
})();

Since the scripts execute inside an IIFE (Immediately Invoked Function Expression), app is no longer stored on the window object but in the local scope.

I’m working with older JavaScript and can’t modify the files to use import/export. Is there a way to configure Webpack to handle this?