BaristaCore icon indicating copy to clipboard operation
BaristaCore copied to clipboard

Improve module evaluation by not requiring shim scripts in order to access namespace objects.

Open Oceanswave opened this issue 6 years ago • 2 comments

Thanks to https://github.com/Microsoft/ChakraCore/pull/4707, it's now possible to programmatically get at namespace objects.

This allows the functionality in https://github.com/BaristaLabs/BaristaCore/blob/master/src/BaristaLabs.BaristaCore.Common/BaristaContext.cs#L456 and https://github.com/BaristaLabs/BaristaCore/blob/master/src/BaristaLabs.BaristaCore.Common/BaristaModuleRecord.cs#L260

to no longer rely on a 'shim' script in order to get at the variables exported by modules. This should improve execution speed, remove pollution of the global namespace, reduce the possibility of down-stream side effects, and allow the export of non-default values as well.

Oceanswave avatar Mar 01 '18 03:03 Oceanswave

The upstream changes should be incorporated in ChakraCore 1.9.x

Oceanswave avatar Mar 03 '18 23:03 Oceanswave

This functionality is now partially implemented thanks to the upstream changes in ChakraCore 1.10.x.

The relevant sections of BaristaModuleRecord.cs still parse script, however, as 1) It doesn't appear to be able to set variables in namespaces 2) attempting to eval getnamespace during module loading breaks the runtime and throws an exception.

Oceanswave avatar Aug 16 '18 23:08 Oceanswave