I have an ASP.NET Core 5 MVC application (no SPA framework). For my Javascript-Files I want to use a single "namespace".
For example I have two JS files:
wwwroot/js/foo.js
function foo(){
...something
}
wwwroot/js/bar.js
function bar(){
...something
}
I want both to be bundled into a single file site.js and accessible with in a single namespace:
myApp.foo();
myApp.bar();
I'm searching for something like you get with the use of IIFE. But I don't know how I can load the javascript from multiple js-files into one IIFE:
function(root, factory) {
root.myApp = factory()
}(this, (function() {
'use strict';
var myApp = {};
myApp.foo = ... foo.js;
myApp.bar = ... bar.js;
return myApp;
})));