MCPcopy
hub / github.com/systemjs/systemjs / processScripts

Function processScripts

src/features/import-maps.js:35–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33}
34
35function processScripts () {
36 [].forEach.call(document.querySelectorAll('script'), function (script) {
37 if (script.sp) // sp marker = systemjs processed
38 return;
39 // TODO: deprecate systemjs-module in next major now that we have auto import
40 if (script.type === 'systemjs-module') {
41 script.sp = true;
42 if (!script.src)
43 return;
44 System.import(script.src.slice(0, 7) === 'import:' ? script.src.slice(7) : resolveUrl(script.src, baseUrl)).catch(function (e) {
45 // if there is a script load error, dispatch an "error" event
46 // on the script tag.
47 if (e.message.indexOf('https://github.com/systemjs/systemjs/blob/main/docs/errors.md#3') > -1) {
48 var event = document.createEvent('Event');
49 event.initEvent('error', false, false);
50 script.dispatchEvent(event);
51 }
52 return Promise.reject(e);
53 });
54 }
55 else if (script.type === 'systemjs-importmap') {
56 script.sp = true;
57 // The passThrough property is for letting the module types fetch implementation know that this is not a SystemJS module.
58 var fetchPromise = script.src ? (System.fetch || fetch)(script.src, { integrity: script.integrity, priority: script.fetchPriority, passThrough: true }).then(function (res) {
59 if (!res.ok)
60 throw Error(process.env.SYSTEM_PRODUCTION ? res.status : 'Invalid status code: ' + res.status);
61 return res.text();
62 }).catch(function (err) {
63 err.message = errMsg('W4', process.env.SYSTEM_PRODUCTION ? script.src : 'Error fetching systemjs-import map ' + script.src) + '\n' + err.message;
64 console.warn(err);
65 if (typeof script.onerror === 'function') {
66 script.onerror();
67 }
68 return '{}';
69 }) : script.innerHTML;
70 importMapPromise = importMapPromise.then(function () {
71 return fetchPromise;
72 }).then(function (text) {
73 extendImportMap(importMap, text, script.src || baseUrl);
74 });
75 }
76 });
77}
78
79function extendImportMap (importMap, newMapText, newMapUrl) {
80 var newMap = {};

Callers 1

import-maps.jsFile · 0.85

Calls 3

resolveUrlFunction · 0.90
errMsgFunction · 0.90
extendImportMapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…