I'm inspecting the source of a chrome plugin after running the compacted source through js-beautify. Each js
file has some boilerplate followed by a list of enumerated functions. I'm trying to work out what tool would make code like this and why so I can try and work out the logic, and thus modify the plugin (I'm a suffering c++ person with minimal experience with js tools). Firstly, what is this boilerplate and where did it come from?
(function() {
function b(d, e, g) {
function a(j, i) {
if (!e[j]) {
if (!d[j]) {
var f = "function" == typeof require && require;
if (!i && f) return f(j, !0);
if (h) return h(j, !0);
var c = new Error("Cannot find module '" + j + "'");
throw c.code = "MODULE_NOT_FOUND", c
}
var k = e[j] = {
exports: {}
};
d[j][0].call(k.exports, function(b) {
var c = d[j][1][b];
return a(c || b)
}, k, k.exports, b, d, e, g)
}
return e[j].exports
}
for (var h = "function" == typeof require && require, c = 0; c < g class="hljs-keyword">return a
}
return b
})()({
Secondly, each js
file has a set of enumerated functions that follow the boilerplate. What is this format and why are the functions in such a structure?
})()({
1: [function(a) {
const b = a("./modules/config"),
c = a("./modules/utils"),
d = {};
window.audioStates = d;
...
}, {
"./modules/config": 2,
"./modules/utils": 3
}],
Then
2: [function(a, b) {
b.exports = {