gulp-amd-wrap
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -0,1 +1,9 @@ | ||
## [1.0.6](https://github.com/searchfe/gulp-amd-wrap/compare/v1.0.5...v1.0.6) (2019-07-04) | ||
### Bug Fixes | ||
* add callexpression require ([2420ce9](https://github.com/searchfe/gulp-amd-wrap/commit/2420ce9)) | ||
* add callexpression require ([fd8b55a](https://github.com/searchfe/gulp-amd-wrap/commit/fd8b55a)) | ||
## [1.0.5](https://github.com/searchfe/gulp-amd-wrap/compare/v1.0.4...v1.0.5) (2019-06-05) | ||
@@ -2,0 +10,0 @@ |
@@ -59,7 +59,9 @@ "use strict"; | ||
exports.DependencyAnalyzer = DependencyAnalyzer; | ||
/** 判断当前node节点为require VariableDeclarator */ | ||
/** 判断当前node节点为require VariableDeclarator 以及 require Literal */ | ||
function matchRequireVariableDeclarator(node) { | ||
return !!(node.type === 'VariableDeclarator' && node.id && node.id.name !== undefined && | ||
return !!((node.type === 'VariableDeclarator' && node.id && node.id.name !== undefined && | ||
node.init && node.init.callee !== undefined && node.init.callee.name === 'require' && | ||
node.init.arguments && node.init.arguments[0] && node.init.arguments[0].value !== undefined); | ||
node.init.arguments && node.init.arguments[0] && node.init.arguments[0].value !== undefined) || | ||
(node.type === 'CallExpression' && node.arguments[0] && node.arguments[0].type === 'Literal' && | ||
node.callee && node.callee.name === 'require')); | ||
} | ||
@@ -95,5 +97,5 @@ /** 判断当前node节点是否包含require VariableDeclarator 返回去除后正常的declarations */ | ||
return { | ||
moduleID: node.init.arguments[0].value, | ||
name: node.id.name, | ||
value: node.init.arguments[0].value, | ||
moduleID: node.init ? node.init.arguments[0].value : node.arguments[0].value, | ||
name: node.id ? node.id.name : '', | ||
value: node.init ? node.init.arguments[0].value : node.arguments[0].value, | ||
}; | ||
@@ -100,0 +102,0 @@ } |
@@ -48,3 +48,4 @@ "use strict"; | ||
if (node.arguments[0].type === 'FunctionExpression') { | ||
node.arguments.unshift({ type: 'ArrayExpression', elements: [] }); | ||
var ele = node.arguments[0].params.map(function (item) { return ({ type: 'Literal', value: item.name }); }); | ||
node.arguments.unshift({ type: 'ArrayExpression', elements: ele }); | ||
} | ||
@@ -67,4 +68,8 @@ // 首参数是依赖数组,推入moduleId | ||
deps.forEach(function (dep) { | ||
node.arguments[1].elements.push({ type: 'Literal', value: dep.moduleID }); | ||
node.arguments[2].params.push({ type: 'Identifier', name: dep.name }); | ||
if (node.arguments[1].elements.map(function (e) { return e.value; }).indexOf(dep.moduleID) < 0) { | ||
node.arguments[1].elements.push({ type: 'Literal', value: dep.moduleID }); | ||
if (dep.name) { | ||
node.arguments[2].params.push({ type: 'Identifier', name: dep.name }); | ||
} | ||
} | ||
}); | ||
@@ -71,0 +76,0 @@ if (hookOption.removeModuleId) { |
{ | ||
"name": "gulp-amd-wrap", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"discription": "gulp-amd-wrap", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
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
595670
17332