Some modules in RingoJS (binary, io, ringo/events) use defineClass() which modifies the global scope. In itself that's imho quite intransparent and thus not a good idea, but alas the wrong implementation of const in Rhino leads to another problem: requiring one of these modules in conjunction with const and desctructuring assignments fails with eg. TypeError: redeclaration of var ByteArray.
Module test-a.js:
require("binary");
require("test-b");
Module test-b.js:
const {ByteArray} = require("binary");
Afais Rhino walks up the prototype chain (the global scope is the prototype of all module scopes) and tries to re-declare the const ByteArray in there, which correctly fails - but i couldn't figure out why the const isn't declared in the module scope.
Workaround: use const binary = require("binary"); in modules. Adds verbosity, but works.
Some modules in RingoJS (
binary,io,ringo/events) usedefineClass()which modifies the global scope. In itself that's imho quite intransparent and thus not a good idea, but alas the wrong implementation ofconstin Rhino leads to another problem: requiring one of these modules in conjunction withconstand desctructuring assignments fails with eg.TypeError: redeclaration of var ByteArray.Module
test-a.js:Module
test-b.js:Afais Rhino walks up the prototype chain (the global scope is the prototype of all module scopes) and tries to re-declare the const ByteArray in there, which correctly fails - but i couldn't figure out why the
constisn't declared in the module scope.Workaround: use
const binary = require("binary");in modules. Adds verbosity, but works.