UNPKG

1.31 kBJavaScriptView Raw
1(function (entrypoint, files, compilations)
2{
3 global.process = { env: { NODE_ENV:"development" } };
4
5 function cachedRequire(index)
6 {
7 const module = Module._cache[index] || new Module(index);
8
9 return module.exports;
10 }
11
12 function Module(index)
13 {
14 Module._cache[index] = this;
15
16 const file = files[index];
17 const filename = file[0];
18
19 console.log("INSTANTIATING " + file[0]);
20
21 const precompiled = compilations[file[1]];
22 const references = file[2];
23
24 this.exports = { };
25 this.__dirname = filename.split("/").slice(0, -1).join("/");
26 this.__filename = filename;
27 this.require = function require(index)
28 {
29 if (typeof index !== "number")
30 throw TypeError("Expected index require");
31
32 const reference = references[index];
33
34 if (typeof reference !== "number")
35 throw TypeError("Could not find file referenced at " + index);
36
37 return cachedRequire(reference);
38 }
39
40 precompiled.call(
41 this.exports, /*this*/
42 this.exports,
43 this.require,
44 this,
45 this.__filename,
46 this.__dirname);
47 }
48
49 Module._cache = { };
50
51 cachedRequire(entrypoint);
52})