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

Using Activator broke native ES6 functions #56

Closed
IvanMMM opened this issue Mar 3, 2018 · 15 comments
Closed

Using Activator broke native ES6 functions #56

IvanMMM opened this issue Mar 3, 2018 · 15 comments

Comments

@IvanMMM
Copy link

IvanMMM commented Mar 3, 2018

This is caused by Styliner module dependence called 'collections'. Looks like they tried to fix it, but no results for now.

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

Well, that certainly isn't good!

@IvanMMM can you share a simple example code (gist or just pasted in here) that triggers it? And can you link to the Styliner issue?

@IvanMMM
Copy link
Author

IvanMMM commented Mar 4, 2018

const arr = [{a:1},{a:2},{a:3}];
console.log(arr.find.toString()); //=>> function find() { [native code] }

const activator = require('activator');

activator.init({
    user:{},
    transport:{},
    from: `...`,
    templates:activator.templates.file(__dirname+'/../../templates'),
    signkey:'...',
    id:'_id',
    emailProperty:'email',
    sendPasswordResetComplete:true
});


console.log(arr.find.toString());
/*
function (value, equals) {
    equals = equals || this.contentEquals || Object.equals;
    for (var index = 0; index < this.length; index++) {
        if (index in this && equals(this[index], value)) {
            return index;
        }
    }
    return -1;
}
*/

As you can see, first console.log displays native ES6 search function and second displays patched function.

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

I don't get it. How does the above break? If I run it, it exits (because we didn't listen()), but it gives sane output:

$ node --version
v9.3.0
$ node ./test.js
function find() { [native code] }
function find() { [native code] }

@IvanMMM
Copy link
Author

IvanMMM commented Mar 4, 2018

Hm. And here's my log

+ [email protected]
updated 1 package in 10.793s

f:\NodeJS\STIV>node --version
v8.9.3

f:\NodeJS\STIV>node activator.js
function find() { [native code] }
function (value, equals) {
    equals = equals || this.contentEquals || Object.equals;
    for (var index = 0; index < this.length; index++) {
        if (index in this && equals(this[index], value)) {
            return index;
        }
    }
    return -1;
}

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

Same thing if I use node v8.6.0

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

And 8.4.0 and 8.0.0. So it isn't that.

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

I am going to clean out my node_modules and reinstall

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

OK, now I got it. My prior node_modules/ did not cause the problem. Probably should have kept it around. Maybe I will restore from backup.

You indicated you know the cause?

@IvanMMM
Copy link
Author

IvanMMM commented Mar 4, 2018

Yes. Look like guys tried to fix it, but...
SLaks/Styliner#17

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

But your sample doesn't use styliner, does it?

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

And the patches there indicate that it was fixed in styliner 1.0.0?

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

Not exactly. Looks like they rolled it back. Here is the move to q-io 2.x in Oct 2015, and here is the rollback in Oct 2016.

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

Key issue is here

In the meantime, forcing styliner to be 1.0.0 precisely rather than ^1.0.0 holds it in place. Putting in place now.

@deitch
Copy link
Owner

deitch commented Mar 4, 2018

Pushed out as 3.0.2. I don't love being forced back to precisely styliner 1.0.0 when there have been some patches since, but until their issue is resolved, at least this works.

@IvanMMM
Copy link
Author

IvanMMM commented Mar 4, 2018

Great! Thank you :)

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

2 participants