MCPcopy
hub / github.com/systemjs/systemjs / getOrCreateLoad

Function getOrCreateLoad

src/system-core.js:80–210  ·  view source on GitHub ↗
(loader, id, firstParentUrl, meta)

Source from the content-addressed store, hash-verified

78};
79
80export function getOrCreateLoad (loader, id, firstParentUrl, meta) {
81 var load = loader[REGISTRY][id];
82 if (load)
83 return load;
84
85 var importerSetters = [];
86 var ns = Object.create(null);
87 if (toStringTag)
88 Object.defineProperty(ns, toStringTag, { value: 'Module' });
89
90 var instantiatePromise = Promise.resolve()
91 .then(function () {
92 return loader.instantiate(id, firstParentUrl, meta);
93 })
94 .then(function (registration) {
95 if (!registration)
96 throw Error(errMsg(2, process.env.SYSTEM_PRODUCTION ? id : 'Module ' + id + ' did not instantiate'));
97 function _export (name, value) {
98 // note if we have hoisted exports (including reexports)
99 load.h = true;
100 var changed = false;
101 if (typeof name === 'string') {
102 if (!(name in ns) || ns[name] !== value) {
103 ns[name] = value;
104 changed = true;
105 }
106 }
107 else {
108 for (var p in name) {
109 var value = name[p];
110 if (!(p in ns) || ns[p] !== value) {
111 ns[p] = value;
112 changed = true;
113 }
114 }
115
116 if (name && name.__esModule) {
117 ns.__esModule = name.__esModule;
118 }
119 }
120 if (changed)
121 for (var i = 0; i < importerSetters.length; i++) {
122 var setter = importerSetters[i];
123 if (setter) setter(ns);
124 }
125 return value;
126 }
127 var declared = registration[1](_export, registration[1].length === 2 ? {
128 import: function (importId, meta) {
129 return loader.import(importId, id, meta);
130 },
131 meta: loader.createContext(id)
132 } : undefined);
133 load.e = declared.execute || function () {};
134 return [registration[0], declared.setters || [], registration[2] || []];
135 }, function (err) {
136 load.e = null;
137 load.er = err;

Callers 2

depcache.jsFile · 0.90
system-core.jsFile · 0.85

Calls 2

errMsgFunction · 0.90
triggerOnloadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…