babel-plugin-vasille 4.2.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/mesh.js +20 -6
- package/lib/transformer.js +3 -2
- package/package.json +1 -1
package/lib/mesh.js
CHANGED
|
@@ -205,11 +205,25 @@ function meshExpression(nodePath, internal) {
|
|
|
205
205
|
const right = path.get("right");
|
|
206
206
|
if (left.isMemberExpression() && !(0, expression_js_1.exprIsSure)(left, internal)) {
|
|
207
207
|
const property = left.node.property;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
let iterator = path;
|
|
209
|
+
let inConstructor = false, inFunction = false;
|
|
210
|
+
while (iterator && !inConstructor && !inFunction) {
|
|
211
|
+
inConstructor =
|
|
212
|
+
iterator.isClassMethod() && t.isIdentifier(iterator.node.key) && iterator.node.key.name === "constructor";
|
|
213
|
+
inFunction = iterator.isFunction();
|
|
214
|
+
iterator = iterator.parentPath;
|
|
215
|
+
}
|
|
216
|
+
if (!(inConstructor &&
|
|
217
|
+
t.isIdentifier(property) &&
|
|
218
|
+
property.name[0] === "$" &&
|
|
219
|
+
t.isThisExpression(left.node.object) &&
|
|
220
|
+
((right.isIdentifier() && (0, expression_js_1.idIsIValue)(right)) || (right.isMemberExpression() && (0, expression_js_1.memberIsIValue)(right.node))))) {
|
|
221
|
+
meshExpression(left.get("object"), internal);
|
|
222
|
+
meshExpression(right, internal);
|
|
223
|
+
/* istanbul ignore else */
|
|
224
|
+
if (!t.isPrivateName(property)) {
|
|
225
|
+
path.replaceWith(internal.set(left.node.object, !left.node.computed && t.isIdentifier(property) ? t.stringLiteral(property.name) : property, right.node));
|
|
226
|
+
}
|
|
213
227
|
}
|
|
214
228
|
}
|
|
215
229
|
else {
|
|
@@ -493,7 +507,7 @@ function meshClassBody(path, internal) {
|
|
|
493
507
|
meshAllUnknown(value.get("arguments"), internal);
|
|
494
508
|
}
|
|
495
509
|
else {
|
|
496
|
-
if (key.isIdentifier()) {
|
|
510
|
+
if (key.isIdentifier() && value.node !== null) {
|
|
497
511
|
(0, lib_js_1.checkNonReactiveName)(key, internal);
|
|
498
512
|
}
|
|
499
513
|
meshExpression(item.get("value"), internal);
|
package/lib/transformer.js
CHANGED
|
@@ -115,14 +115,15 @@ function updateImports(path, internal, ids, used) {
|
|
|
115
115
|
if (used.size > 0 && !internal.global && internal.importStatement) {
|
|
116
116
|
const statementPath = internal.importStatement;
|
|
117
117
|
const statement = statementPath.node;
|
|
118
|
-
const specifiers = statement.specifiers
|
|
118
|
+
const specifiers = statement.specifiers;
|
|
119
|
+
const usedSpecifiers = statement.specifiers.filter(item => {
|
|
119
120
|
/* istanbul ignore else */
|
|
120
121
|
if (t.isImportSpecifier(item) && t.isIdentifier(item.local)) {
|
|
121
122
|
return statementPath.scope.bindings[item.local.name].referenced;
|
|
122
123
|
}
|
|
123
124
|
});
|
|
124
125
|
for (const name of used) {
|
|
125
|
-
if (!
|
|
126
|
+
if (!usedSpecifiers.find(specifier => t.isImportSpecifier(specifier) && [name, ids[name]].includes(extractText(specifier.imported)))) {
|
|
126
127
|
specifiers.push(t.importSpecifier(t.identifier(ids[name]), t.identifier(name)));
|
|
127
128
|
}
|
|
128
129
|
}
|