@kezh/my-custom-js-converter 0.0.18 → 0.0.20
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/core/encode.js +22 -7
- package/package.json +1 -1
package/core/encode.js
CHANGED
|
@@ -108,6 +108,7 @@ function getImportMethods(modPathByName, methodNamesByMod) {
|
|
|
108
108
|
...new Set([...useMethodNames, ...inlineMethodNames])
|
|
109
109
|
];
|
|
110
110
|
modifyModMethods(name, mergeMethodNames, modAst);
|
|
111
|
+
console.log((0, generator_1.default)(modAst).code);
|
|
111
112
|
mergeMethodNames = mergeMethodNames.map((m) => `${m}__${name}`);
|
|
112
113
|
const mergeMethods = mergeMethodNames
|
|
113
114
|
.map((name) => {
|
|
@@ -244,13 +245,27 @@ function getSrcMethodNames(entry, srcAst) {
|
|
|
244
245
|
function getMethods(entry, ast) {
|
|
245
246
|
const methods = [];
|
|
246
247
|
(0, traverse_1.default)(ast, {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
248
|
+
Program(path) {
|
|
249
|
+
path.node.body.forEach((statement) => {
|
|
250
|
+
if (core_1.types.isVariableDeclaration(statement)) {
|
|
251
|
+
const variableDeclaration = statement;
|
|
252
|
+
variableDeclaration.declarations.filter((declaration) => {
|
|
253
|
+
if (core_1.types.isIdentifier(declaration.id)) {
|
|
254
|
+
const id = declaration.id;
|
|
255
|
+
if (id.name === entry) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return false;
|
|
260
|
+
}).forEach((declaration) => {
|
|
261
|
+
if (core_1.types.isObjectExpression(declaration.init)) {
|
|
262
|
+
const init = declaration.init;
|
|
263
|
+
const objectMethods = init.properties.filter(property => core_1.types.isObjectMethod(property));
|
|
264
|
+
methods.push(...objectMethods);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
});
|
|
254
269
|
}
|
|
255
270
|
});
|
|
256
271
|
return methods;
|