You can use global variables across multiple files by attaching them to the global object or by using a module system to import and export variables between files.
Bundling JavaScript and non-JavaScript modules into bundles using Webpack, Rollup, Parcel and many more.
Module loaders are libraries that can handle loading modules using the different formats for further processing or executing.
An overview of CommonJS (CJS), Asynchronous Module Definition (AMD), Universal Module Definition (UMD), and ECMAScript Modules (ESM).