Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function run(url, str) {
window.dimport = dimport;
var key, keys=[], urls=[], mod={ exports:{} };
var txt = imports(
// Ensure full URLs & Gather static imports
str.replace(/(^|\s|;)(import\s*)(\(|.*from\s*|)['"]([^'"]+)['"];?/gi, function (_, pre, req, type, loc) {
loc = "'" + new URL(loc, url).href + "'";
return pre + req + type + (type == '(' ? loc : `'$dimport[${urls.push(loc) - 1}]';`);
})
// Ensure we caught all dynamics (multi-line clause)
.replace(/(^|\s|;)(import)(?=\()/g, '$1window.dimport')
// Exports
.replace(/export default/, 'module.exports =')
.replace(/export\s+(const|function|class|let|var)\s+(.+?)(?=(\(|\s|=))/gi, function (_, type, name) {
return keys.push(name) && (type + ' ' + name);
})
.replace(/export\s*\{([\s\S]*?)\}/gi, function (_, list) {
var tmp, out='', arr=list.split(',');
function run(url, str) {
window.dimport = dimport;
var key, keys=[], urls=[], mod={ exports:{} };
var txt = imports(
// Ensure full URLs & Gather static imports
str.replace(/(^|\s|;)(import\s*)(\(|.*from\s*|)['"]([^'"]+)['"];?/gi, function (_, pre, req, type, loc) {
loc = "'" + new URL(loc, url).href + "'";
return pre + req + type + (type == '(' ? loc : `'$dimport[${urls.push(loc) - 1}]';`);
})
// Ensure we caught all dynamics (multi-line clause)
.replace(/(^|\s|;)(import)(?=\()/g, '$1window.dimport')
// Exports
.replace(/export default/, 'module.exports =')
.replace(/export\s+(const|function|class|let|var)\s+(.+?)(?=(\(|\s|=))/gi, function (_, type, name) {
return keys.push(name) && (type + ' ' + name);
})
.replace(/export\s*\{([\s\S]*?)\}/gi, function (_, list) {
var tmp, out='', arr=list.split(',');