-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
function load(uri, names) {
if (!uri instanceof URL) {
throw new Error('uri must be an instance of URL');
}
if (!Array.isArray(names)) {
throw new Error('names must be an array');
}
const xhr = new XMLHttpRequest();
xhr.open('GET', uri, false);
xhr.send();
if (xhr.status !== 200) {
throw new Error('Error al cargar el script: ' + xhr.status);
}
let tail = '; ({ __esModule: true, ' + names.join(', ') + '});';
const code = xhr.responseText + tail;
const module = eval(code);
return module;
}
const m1 = load(new URL('https://unpkg.com/react@18/umd/react.development.js'), ['React']);
const m2 = load(new URL('https://unpkg.com/react-dom@18/umd/react-dom.development.js'), ['ReactDOM']);
Metadata
Metadata
Assignees
Labels
No labels