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

Rhino support #41

Open
ai opened this issue Jul 24, 2014 · 4 comments
Open

Rhino support #41

ai opened this issue Jul 24, 2014 · 4 comments

Comments

@ai
Copy link

ai commented Jul 24, 2014

When I try to run compiled JS in Rhino, I get error:

InternalError: Changing attributes not supported for Function prototype property

It was generated because of:

var DP$0 = Object.defineProperty;
DP$0(MyClass, "prototype", {"configurable": false, "enumerable": false, "writable": false});

Problem is that Rhino deby to replace prototype. But this code is unnecessary in Rhino, because MyClass.prototype is already not writable.

Rhino support is very important to me, because it allow to run JS code on Java (and languages like JRuby). It is a big market and fix is very small.

@ai
Copy link
Author

ai commented Jul 24, 2014

@termi Traceur has same issue: google/traceur-compiler#1200

@ai
Copy link
Author

ai commented Jul 24, 2014

@termi we can wrap DP$0 into try catch or detect Rhino.

@ai
Copy link
Author

ai commented Aug 18, 2014

@termi how I can help with this fix?

@termi
Copy link
Owner

termi commented Sep 5, 2014

Sorry for the long absence. I don't think it should be part of the transpiler, since it's an environment bug and you can wrap it by your self:

var $Object_defineProperty = Object.defineProperty;
Object.defineProperty = function(obj, prop, desc) {
    if ( prop === 'prototype' ) {
        delete desc['writable'];
        arguments[2] = desc;
    }
    return $Object_defineProperty.apply(this, arguments);
}

But I will do an option for this in one of the future versions. Don't close this issue.

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