-
Notifications
You must be signed in to change notification settings - Fork 100
Description
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.