Comparing version 2.0.9 to 2.0.10
@@ -7,2 +7,4 @@ var _ = alp._; | ||
function removeExt(url) { | ||
@@ -9,0 +11,0 @@ return url.replace(/\.[\da-z]*$/i, ''); |
@@ -7,5 +7,5 @@ var colors = require('colors'); | ||
if (type) { | ||
type = '\n[' + type.toLocaleUpperCase() + '] '; | ||
type = '\n[' + type.toLocaleUpperCase() + '][ALPACA-SM]'; | ||
} | ||
process.stdout.write(type + msg + ' this is in "alpaca" module'.red + '\n'); | ||
process.stdout.write(type + msg + '\n'); | ||
} | ||
@@ -12,0 +12,0 @@ |
@@ -27,2 +27,5 @@ var esprima = require('esprima'); | ||
var requireRegExp = new RegExp('(' + config.get('word') + ')|(' + 'module\\.exports' + ')', 'gm'); | ||
/** | ||
@@ -201,15 +204,21 @@ * 匹配只有闭包js文件表达式的正则表达式 | ||
// 生成content | ||
content = escodegen.generate(file.ast, escodegenOpts); | ||
content = content.replace(/(<<<require>>>\s*;+)|(<<<require>>>\s*,+)/gim, ""); | ||
if (isOptimizer) { | ||
content = content.replace(/([;,][\s\n\r]*(?=[;,]))/gi, "").replace(/(,[\s\n\r]*(?=(var)))/gi, ";"); | ||
if (file.getContent().match(requireRegExp)) { | ||
// 生成content | ||
content = escodegen.generate(file.ast, escodegenOpts); | ||
content = content.replace(/(<<<require>>>\s*;+)|(<<<require>>>\s*,+)/gim, ""); | ||
if (isOptimizer) { | ||
content = content.replace(/([;,][\s\n\r]*(?=[;,]))/gi, "").replace(/(,[\s\n\r]*(?=(var)))/gi, ";"); | ||
} else { | ||
content = content.replace(/([\s\n\r]+);/gi, ""); | ||
} | ||
content = content.replace(closureReg(file.nsRegExp), ''); | ||
exports = file.exports; | ||
if (exports && 'type' in exports && exports.type === Syntax.Identifier) { | ||
content = content.replace(new RegExp(file.nsRegExp, 'igm'), ''); | ||
} | ||
} else { | ||
content = content.replace(/([\s\n\r]+);/gi, ""); | ||
content = file.getContent(); | ||
} | ||
content = content.replace(closureReg(file.nsRegExp), ''); | ||
exports = file.exports; | ||
if (exports && 'type' in exports && exports.type === Syntax.Identifier) { | ||
content = content.replace(new RegExp(file.nsRegExp, 'igm'), ''); | ||
} | ||
} | ||
@@ -294,2 +303,3 @@ | ||
_absUrl = path.resolve(_.unix(config.get('fileBasedRoot') ? config.get('root') : file.dirname || config.get('root')), requireValue); | ||
if (!_.exists(_absUrl)) { | ||
@@ -304,8 +314,17 @@ alp.log.warning(file.realpath + '文件:require(' + requireValue + ') 文件不存在'); | ||
// 如果require 命中配置 exculde 规则,则将发出警告,并将其替换成undefined; | ||
if (!rFile.useCompile && parentNotExpressionOrSequence) { | ||
alp.log.warning(rFile.realpath + '文件命中exclude配置项的规则,在' + file.realpath + '中的require(' + requireValue + ')将被替换为undefined'); | ||
return { | ||
name: 'undefined', | ||
type: Syntax.Identifier | ||
}; | ||
//if (!rFile.useCompile && parentNotExpressionOrSequence) { | ||
// alp.log.warning(rFile.realpath + '文件命中exclude配置项的规则,在' + file.realpath + '中的require(' + requireValue + ')将被替换为undefined'); | ||
// return { | ||
// name: 'undefined', | ||
// type: Syntax.Identifier | ||
// }; | ||
//alp.log.error(file.subpath + '中的require("' + requireValue + '")不能被解析,原因:' + rFile.subpath + '不在白名单或被包含在了黑名单中,同时参与了运算'); | ||
//alp.log.error(rFile.realpath + '文件不在白名单exclude配置项的规则,在' + file.realpath + '中的require("' + requireValue + '")'); | ||
//} | ||
if(!rFile.useCompile && parentNotExpressionOrSequence) { | ||
alp.log.error(file.subpath + '中的require("' + requireValue + '")不能被解析,原因:' + rFile.subpath + '不在白名单或被包含在了黑名单中'); | ||
} | ||
@@ -322,7 +341,3 @@ | ||
}; | ||
} else { | ||
// _this.emit('compile', rFile); | ||
} | ||
} else { | ||
@@ -335,8 +350,15 @@ _this.map[file.subpath][key] = 1; | ||
} | ||
// _this.emit('compile', rFile); | ||
} | ||
//if (rFile.useCompile) { | ||
_this.emit('compile', rFile); | ||
// } else { | ||
// alp.log.error(file.subpath + '中的require("' + requireValue + '")不能被解析,代码中会将其过滤,原因:' + rFile.subpath + '不在白名单或被包含在了黑名单中,但没有参与运算'); | ||
// return { | ||
// name: '', | ||
// type: Syntax.Identifier | ||
// }; | ||
// } | ||
if (parentNotExpressionOrSequence && rFile.isJsFile) { | ||
@@ -343,0 +365,0 @@ paramName = rFile.id; |
{ | ||
"name": "alpaca-sm", | ||
"version": "2.0.9", | ||
"version": "2.0.10", | ||
"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
53386
1350