Instead of calling Init manually on the runtime, each module would register itself either as a global (NODE_BINDING_PER_ISOLATE_INIT_OBJ) or as a node module (NODE_BINDING_CONTEXT_AWARE_INTERNAL).
Globals are already working, we still need work for the node modules (essentially check if a module is a native module and call it + cache it).
This will allow us to require('ns:crypto'), for example. In the future, we could even rework the way we use native libraries so you can do: import { NSString } from 'ns:native:Foundation' to get a slimmer app size and automatic metadata filtering through bundlers
Draft on how new modules and globals could work
Instead of calling Init manually on the runtime, each module would register itself either as a global (
NODE_BINDING_PER_ISOLATE_INIT_OBJ
) or as a node module (NODE_BINDING_CONTEXT_AWARE_INTERNAL
).Globals are already working, we still need work for the node modules (essentially check if a module is a native module and call it + cache it).
This will allow us to
require('ns:crypto')
, for example. In the future, we could even rework the way we use native libraries so you can do:import { NSString } from 'ns:native:Foundation'
to get a slimmer app size and automatic metadata filtering through bundlershttps://github.com/NativeScript/NativeScript/issues/195