UNPKG

1.45 kBJavaScriptView Raw
1parcelRequire = (function (init) {
2 // Save the require from previous bundle to this closure if any
3 var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
4 var nodeRequire = typeof require === 'function' && require;
5 var modules = {};
6
7 function localRequire(name, jumped) {
8 if (name in modules) {
9 return modules[name];
10 }
11
12 // if we cannot find the module within our internal map or
13 // cache jump to the current global require ie. the last bundle
14 // that was added to the page.
15 var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
16 if (!jumped && currentRequire) {
17 return currentRequire(name, true);
18 }
19
20 // If there are other bundles on this page the require from the
21 // previous one is saved to 'previousRequire'. Repeat this as
22 // many times as there are bundles until the module is found or
23 // we exhaust the require chain.
24 if (previousRequire) {
25 return previousRequire(name, true);
26 }
27
28 // Try the node require function if it exists.
29 if (nodeRequire && typeof name === 'string') {
30 return nodeRequire(name);
31 }
32
33 var err = new Error('Cannot find module \'' + name + '\'');
34 err.code = 'MODULE_NOT_FOUND';
35 throw err;
36 }
37
38 localRequire.register = function register(id, exports) {
39 modules[id] = exports;
40 };
41
42 modules = init(localRequire);
43 localRequire.modules = modules;
44 return localRequire;
45})