rewrite-imports
Advanced tools
Comparing version 2.0.2 to 2.0.3
'use strict'; | ||
var UNNAMED = /import\s*['"]([^'"]+)['"];?/gi; | ||
var NAMED = /import\s*(\*\s*as)?\s*(\w*?)\s*,?\s*(?:\{([\s\S]*?)\})?\s*from\s*['"]([^'"]+)['"];?/gi; | ||
var UNNAMED = /(^|;|\s+)import\s*['"]([^'"]+)['"](?=($|;|\s))/gi; | ||
var NAMED = /(^|[;\s]+)?import\s*(\*\s*as)?\s*(\w*?)\s*,?\s*(?:\{([\s\S]*?)\})?\s*from\s*['"]([^'"]+)['"];?/gi; | ||
@@ -21,8 +21,6 @@ function destruct(keys, target) { | ||
return str | ||
.replace(NAMED, function (x, asterisk, base, req, dep) { | ||
return generate(req ? req.split(',') : [], dep, base, fn); | ||
}) | ||
.replace(UNNAMED, function (x, dep) { | ||
return (fn + "('" + dep + "');"); | ||
.replace(UNNAMED, "$1" + fn + "('$2')") | ||
.replace(NAMED, function (x, y, z, base, req, dep) { | ||
return (y || '') + generate(req ? req.split(',') : [], dep, base, fn); | ||
}); | ||
} |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e["rewrite-imports"]=t()}(this,function(){"use strict";var e=/import\s*['"]([^'"]+)['"];?/gi,t=/import\s*(\*\s*as)?\s*(\w*?)\s*,?\s*(?:\{([\s\S]*?)\})?\s*from\s*['"]([^'"]+)['"];?/gi;function n(e,t){for(var n=[];e.length;)n.push(e.shift().trim().replace(/ as /g,":"));return"const { "+n.join(", ")+" } = "+t+";"}return function(r,i){return i=i||"require",r.replace(t,function(e,t,r,o,s){return function(e,t,r,i){return t=i+"('"+t+"')",e.length&&!r?n(e,t):"const "+r+" = "+t+";"+(e.length?"\n"+n(e,r):"")}(o?o.split(","):[],s,r,i)}).replace(e,function(e,t){return i+"('"+t+"');"})}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e["rewrite-imports"]=t()}(this,function(){"use strict";var e=/(^|;|\s+)import\s*['"]([^'"]+)['"](?=($|;|\s))/gi,t=/(^|[;\s]+)?import\s*(\*\s*as)?\s*(\w*?)\s*,?\s*(?:\{([\s\S]*?)\})?\s*from\s*['"]([^'"]+)['"];?/gi;function n(e,t){for(var n=[];e.length;)n.push(e.shift().trim().replace(/ as /g,":"));return"const { "+n.join(", ")+" } = "+t+";"}return function(r,s){return s=s||"require",r.replace(e,"$1"+s+"('$2')").replace(t,function(e,t,r,i,o,u){return(t||"")+function(e,t,r,s){return t=s+"('"+t+"')",e.length&&!r?n(e,t):"const "+r+" = "+t+";"+(e.length?"\n"+n(e,r):"")}(o?o.split(","):[],u,i,s)})}}); |
{ | ||
"name": "rewrite-imports", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"repository": "lukeed/rewrite-imports", | ||
@@ -5,0 +5,0 @@ "description": "Rewrite `import` statements as `require()`s; via RegExp", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7128
42