-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
3 - M (<= 1 month)
-
Incrementals
-
2126
-
Not Needed
Goals
In general its bad practice for a library to mutate objects without the developers consent, in particular it's bad practice for a plugin to write to the global object.
Expected Results
I expect Realm to not write to the global object.
Actual Results
Create a node project, install Realm and start the node REPL, notice how global.Realm gets set after Realm has been required.
> global.Realm
undefined
> require("realm")
{ [Function: Realm]
open: [Function: open],
openAsync: [Function: openAsync],
createTemplateObject: [Function: createTemplateObject],
automaticSyncConfiguration: [Function],
_extendQueryBasedSchema: [Function: _extendQueryBasedSchema] }
> global.Realm
{ [Function: Realm]
open: [Function: open],
openAsync: [Function: openAsync],
createTemplateObject: [Function: createTemplateObject],
automaticSyncConfiguration: [Function],
_extendQueryBasedSchema: [Function: _extendQueryBasedSchema] }
Depending on this being a feature or a bug it might be a breaking change when its fixed.
This looks like the offending line of code: https://github.com/realm/realm-js/blob/v2.23.0/src/js_realm.hpp#L421 but it also looks like there are a few parts of the code calling Object::get_global(ctx, "Realm") which is dependent on this global.
Steps to Reproduce
☝️
Code Sample
☝️
Version of Realm and Tooling
- Realm JS SDK Version: 2.19.1
- Node or React Native: N/A
- Client OS & Version: N/A
- Which debugger for React Native: N/A
- is depended on by
-
RJS-305 [10.0] Breaking changes
- Closed
-
RSTUDIO-380 Support multiple Realm file formats without upgrading files
- Backlog