Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babel broken - needs upgrade #38

Open
ekkis opened this issue Mar 31, 2019 · 1 comment
Open

Babel broken - needs upgrade #38

ekkis opened this issue Mar 31, 2019 · 1 comment

Comments

@ekkis
Copy link

ekkis commented Mar 31, 2019

this module relies on Babel 6, which is broken:

$ node
> Object.prototype.test = () => null
[Function]
> require('bitbox-sdk')

yields:

Error: You passed traverse() a visitor object with the property "Block" that has the invalid property "test"
at verify (/Users/ekkis/dev/otc-trader/node_modules/babel-traverse/lib/visitors.js:205:17)
at Function.explode (/Users/ekkis/dev/otc-trader/node_modules/babel-traverse/lib/visitors.js:72:3)
at Plugin.normaliseVisitor (/Users/ekkis/dev/otc-trader/node_modules/babel-core/lib/transformation/plugin.js:155:29)
at new Plugin (/Users/ekkis/dev/otc-trader/node_modules/babel-core/lib/transformation/plugin.js:66:27)

I reached out to the Babel guys and they said v6 is no longer maintained and your package should upgrade. please see: babel/babel#9786

please upgrade and let me know when I can refresh

@ekkis
Copy link
Author

ekkis commented May 10, 2019

this issue is correlated to #32 which describes a similar bug in lodash. the issue was closed because lodash is not a direct dependency of slp-sdk. however that issue, and this one will be solved once slp-sdk upgrades to Babel 6. the version in current use is no longer supported

I have verified that the problems in Babel were fixed as of:

babel/babel@0345c1b#diff-726a7b1ebcc4ecc81357266f8395ac19

and for anyone interested, until slp-sdk upgrades, the patch below fixes the problem with babel:

diff --git a/node_modules/babel-traverse/lib/visitors.js b/node_modules/babel-traverse/lib/visitors.js
index dadf5d0..708d825 100644
--- a/node_modules/babel-traverse/lib/visitors.js
+++ b/node_modules/babel-traverse/lib/visitors.js
@@ -131,12 +131,18 @@ function explode(visitor) {
 
   for (var _nodeType in visitor) {
     if (shouldIgnoreKey(_nodeType)) continue;
+    if (!visitor.hasOwnProperty(_nodeType)) continue;
 
     var _fns = visitor[_nodeType];
 
-    var aliases = t.FLIPPED_ALIAS_KEYS[_nodeType];
+    var aliases = t.FLIPPED_ALIAS_KEYS.hasOwnProperty(_nodeType)
+       ? t.FLIPPED_ALIAS_KEYS[_nodeType]
+       : null;
+
+    var deprecratedKey = t.DEPRECATED_KEYS.hasOwnProperty(_nodeType)
+       ? t.DEPRECATED_KEYS[_nodeType]
+       : null;
 
-    var deprecratedKey = t.DEPRECATED_KEYS[_nodeType];
     if (deprecratedKey) {
       console.trace("Visitor defined for " + _nodeType + " but it has been renamed to " + deprecratedKey);
       aliases = [deprecratedKey];
@@ -199,6 +205,7 @@ function verify(visitor) {
     var visitors = visitor[nodeType];
     if ((typeof visitors === "undefined" ? "undefined" : (0, _typeof3.default)(visitors)) === "object") {
       for (var visitorKey in visitors) {
+        if (!visitors.hasOwnProperty(visitorKey)) continue;
         if (visitorKey === "enter" || visitorKey === "exit") {
           validateVisitorMethods(nodeType + "." + visitorKey, visitors[visitorKey]);
         } else {

also, the patch for the lodash problem:

diff --git a/node_modules/lodash/lodash.js b/node_modules/lodash/lodash.js
index cb139dd..9730f52 100644
--- a/node_modules/lodash/lodash.js
+++ b/node_modules/lodash/lodash.js
@@ -17039,8 +17039,11 @@
     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
       var lodashFunc = lodash[methodName];
       if (lodashFunc) { 
-        var key = (lodashFunc.name + ''),
-            names = realNames[key] || (realNames[key] = []);
+        var key = (lodashFunc.name + ''), names;
+       if (realNames.hasOwnProperty(key))
+           names = realNames[key];
+       else
+            names = realNames[key] = [];
        
         names.push({ 'name': methodName, 'func': lodashFunc });
       }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant