BaristaLabs / BaristaCore

BaristaCore is a framework for providing a serverless platform using ChakraCore and .Net Core
MIT License
28 stars 3 forks source link

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

Open Oceanswave opened 6 years ago

Oceanswave commented 6 years ago

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 commented 6 years ago

The upstream changes should be incorporated in ChakraCore 1.9.x

Oceanswave commented 6 years ago

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.