forked from newrelic/newrelic-browser-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
agent-prelude.js
43 lines (38 loc) · 1.72 KB
/
agent-prelude.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// prelude.js edited from: https://github.com/substack/browser-pack/blob/master/prelude.js
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requireuires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
(function (modules, cache, entry) { // eslint-disable-line no-extra-parens
// Save the require from previous bundle to this closure if any
var previousRequire = typeof __nr_require === 'function' && __nr_require
function newRequire (name, jumped) {
if (!cache[name]) {
if (!modules[name]) {
// if we cannot find the the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof __nr_require === 'function' && __nr_require
if (!jumped && currentRequire) return currentRequire(name, true)
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) return previousRequire(name, true)
throw new Error("Cannot find module '" + name + "'")
}
var m = cache[name] = {exports: {}}
modules[name][0].call(m.exports, function (x) {
var id = modules[name][1][x]
return newRequire(id || x)
}, m, m.exports)
}
return cache[name].exports
}
for (var i = 0; i < entry.length; i++) newRequire(entry[i])
// Override the current require with this new one
return newRequire
})