This is where the files go when they're loaded as actual JS code
function load(name) {
// Modules can only be loaded once. We save the values here.
if (modules[name]) {
return modules[name];
}
// Set up all the arguments... in a real CommonJS system there's more info here
const require = load;
const exports = {};
const __filename = name;
const func = Function("require", "exports", "__filename", files[name]);
// Run the module code
func(require, exports, __filename);
// Save and return the exports object
modules[name] = exports;
return exports;
}
This is basically the `require` function, but I gave it the name `load` so it seemed less magical
load("main.js");
This is where you would load the file specified on the command line (e.g. `main.js` in the command `node main.js`)