Comparing version 1.1.5 to 1.1.6
@@ -19,2 +19,12 @@ var esprima = require('esprima'); | ||
var closureReg = function(content) { | ||
var ns = alp.config.get('ns'); | ||
return alp.config.get('optimizer') ? | ||
new RegExp('(window\\.' + ns + ')\\s*=\\s*\\1(\\|\\|\\{\\})[,;]\\s*?function\\s*\\(.*?\\)\\s*?\\{\\s*?' + content + '\\s*\\}\\s*?\\(' + ns + '\\);', 'gi') : | ||
new RegExp('(window\\.' + ns + ')(\\s*)=\\2\\1\\2\\|\\|\\2\\{\\};([\\r\\n\\s])*\\(function\\2\\(' + ns + '\\)\\2\\{[\\r\\n\\s]*?' + content + '\\2\\}\\(' + ns + '\\)\\);*', 'gim'); | ||
}; | ||
function getCleanCss() { | ||
@@ -37,2 +47,7 @@ if (!CleanCss) { | ||
} | ||
function exportsAssign(exports) { | ||
return exports ? exports + ' = ' + exports + ' || {};':''; | ||
} | ||
/** | ||
@@ -409,8 +424,8 @@ * 为js添加一个外包。 | ||
function generateContent(obj, minCb) { | ||
function generateContent(obj, isJsFile, minCb) { | ||
var content, isMinifile = alp.config.get('optimizer'); | ||
var escodegenOptions = {}; | ||
if (obj.content) { | ||
if (!isJsFile && 'content' in obj && _.is(obj.content, 'string')) { | ||
content = obj.content; | ||
} else { | ||
} else if (isJsFile) { | ||
//content = escodegen.generate(obj.ast).replace(/([\s\n\r]+);\1/gi, ""); | ||
@@ -429,5 +444,6 @@ //content = escodegen.generate(obj.ast).replace(/;;/gi, ""); | ||
} | ||
content = escodegen.generate(obj.ast,escodegenOptions); | ||
content = escodegen.generate(obj.ast, escodegenOptions); | ||
content = content.replace(/(,\s*(<<<require>>>)\s*(?=;?))|(<<<require>>>\s*,?)/gim, ""); | ||
} else { | ||
content = ""; | ||
} | ||
@@ -439,10 +455,12 @@ | ||
}*/ | ||
content = content.replace(/[;,][\s\n\r]*(?=[;,])/gi,""); | ||
content = content.replace(/[;,][\s\n\r]*(?=[;,])/gi, ""); | ||
return content; | ||
//return minCb(content, !!obj.content); | ||
} else { | ||
return content.replace(/([\s\n\r]+);/gi, ""); | ||
content = content.replace(/([\s\n\r]+);/gi, ""); | ||
} | ||
return content.replace(closureReg(exportsAssign(obj.exportStr))); | ||
} | ||
@@ -467,3 +485,4 @@ | ||
_result[k] = { | ||
content: generateContent(obj, minCb), | ||
content: generateContent(obj, _.isJsFile(k), minCb), | ||
exportStr: obj.exportStr, | ||
map: { | ||
@@ -470,0 +489,0 @@ base: obj.base, |
{ | ||
"name": "alpaca-sm", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "分析Html文件依赖的js文件和css文件", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
40890
1372