babel-plugin-hylid-bridge
Advanced tools
Comparing version 2.4.0-alpha.0 to 2.4.0-alpha.1
@@ -6,2 +6,10 @@ # Change Log | ||
## [2.4.0-alpha.1](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.4.0-alpha.0...v2.4.0-alpha.1) (2022-08-15) | ||
### Features | ||
* 不修改全局的 my, 新建本地变量 | ||
## [2.4.0-alpha.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.1.0...v2.4.0-alpha.0) (2022-08-12) | ||
@@ -8,0 +16,0 @@ |
@@ -98,2 +98,4 @@ "use strict"; | ||
var myLocalName = "".concat(identifierPrefix, "my__"); | ||
var _default = function _default(_, opts) { | ||
@@ -115,3 +117,7 @@ var targets = getTargets(opts === null || opts === void 0 ? void 0 : opts.targets); | ||
var newNode = babelTypes.cloneNode(path.node, true, true); | ||
newNode.object = babelTypes.identifier(myLocalName); | ||
if (state.usedJSAPIList === 'all') { | ||
path.replaceWith(newNode); | ||
return; | ||
@@ -142,2 +148,4 @@ } | ||
} | ||
path.replaceWith(newNode); | ||
}, | ||
@@ -185,10 +193,10 @@ Program: { | ||
var targetSplit = splitTarget(target); | ||
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat(_lodash.default.camelCase("is_".concat(targetSplit[0], "_").concat(targetSplit[1])))), babelTypes.blockStatement([babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier('my'), babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_my__"))))]), buildElseIf(targetList.slice(1))); | ||
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat(_lodash.default.camelCase("is_".concat(targetSplit[0], "_").concat(targetSplit[1])))), babelTypes.blockStatement([babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier(myLocalName), babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_my__"))))]), buildElseIf(targetList.slice(1))); | ||
}; | ||
nodes.push(babelTypes.variableDeclaration('var', [babelTypes.variableDeclarator(babelTypes.identifier('my'))])); // Do not generate the `if statement` when there is just one target. | ||
nodes.push(babelTypes.variableDeclaration('var', [babelTypes.variableDeclarator(babelTypes.identifier(myLocalName))])); // Do not generate the `if statement` when there is just one target. | ||
if (targets.length === 1) { | ||
var targetSplit = splitTarget(targets[0]); | ||
nodes.push(babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier('my'), babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_my__"))))); | ||
nodes.push(babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier(myLocalName), babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_my__"))))); | ||
} else { | ||
@@ -220,6 +228,6 @@ var elseIfNode = buildElseIf(targets); | ||
}); | ||
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat(_lodash.default.camelCase("is_".concat(targetSplit[0], "_").concat(targetSplit[1])))), babelTypes.blockStatement([babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier('my'), babelTypes.objectExpression(propertyList)))]), _buildElseIf(targetList.slice(1))); | ||
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat(_lodash.default.camelCase("is_".concat(targetSplit[0], "_").concat(targetSplit[1])))), babelTypes.blockStatement([babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier(myLocalName), babelTypes.objectExpression(propertyList)))]), _buildElseIf(targetList.slice(1))); | ||
}; | ||
nodes.push(babelTypes.variableDeclaration('var', [babelTypes.variableDeclarator(babelTypes.identifier('my'))])); // Do not generate the `if statement` when there is just one target. | ||
nodes.push(babelTypes.variableDeclaration('var', [babelTypes.variableDeclarator(babelTypes.identifier(myLocalName))])); // Do not generate the `if statement` when there is just one target. | ||
@@ -232,3 +240,3 @@ if (targets.length === 1) { | ||
}); | ||
nodes.push(babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier('my'), babelTypes.objectExpression(propertyList)))); | ||
nodes.push(babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier(myLocalName), babelTypes.objectExpression(propertyList)))); | ||
} else { | ||
@@ -235,0 +243,0 @@ var _elseIfNode = _buildElseIf(targets); |
{ | ||
"name": "babel-plugin-hylid-bridge", | ||
"version": "2.4.0-alpha.0", | ||
"version": "2.4.0-alpha.1", | ||
"description": "babel-plugin-hylid-bridge", | ||
@@ -5,0 +5,0 @@ "main": "lib/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
17252
261