@dolphinweex/weex-harmony-transform 0.1.6 → 0.1.7
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/package.json +1 -1
- package/weexTransform.js +19 -2
package/package.json
CHANGED
package/weexTransform.js
CHANGED
|
@@ -5,7 +5,7 @@ function isNeedWeexExtProxy(module) {
|
|
|
5
5
|
return (weexExtModules.indexOf(module) === -1) ? false : true;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
module.exports = function({ types: t }) {
|
|
8
|
+
module.exports = function ({ types: t }) {
|
|
9
9
|
return {
|
|
10
10
|
name: "weexTransform",
|
|
11
11
|
visitor: {
|
|
@@ -75,8 +75,25 @@ module.exports = function({ types: t }) {
|
|
|
75
75
|
// console.log('Transform not harmony process.env.ISHARMONY:' + process.env.ISHARMONY);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
} else if (t.isIdentifier(callee) && callee.name === 'require') {
|
|
79
|
+
const arguments = astPath.node.arguments
|
|
80
|
+
if (arguments && arguments.length > 0 && arguments[0].value) {
|
|
81
|
+
const oldPath = arguments[0].value;
|
|
82
|
+
if (oldPath === 'weex-bindingx') {
|
|
83
|
+
// 构建新的路径节点
|
|
84
|
+
const newPathNode = t.stringLiteral('@dolphinweex/weex-bindingx');
|
|
85
|
+
// 替换原来的路径节点
|
|
86
|
+
astPath.node.arguments[0] = newPathNode;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
ImportDeclaration(path) {
|
|
92
|
+
const importPath = path.node.source.value;
|
|
93
|
+
if (importPath === 'weex-bindingx') {
|
|
94
|
+
path.node.source.value = "@dolphinweex/weex-bindingx"
|
|
78
95
|
}
|
|
79
|
-
|
|
96
|
+
}
|
|
80
97
|
}
|
|
81
98
|
};
|
|
82
99
|
};
|