Reputation: 6091
Using the JavaScript Runtime (JSRT), what functions would you call to load a JavaScript module and then call functions on it. For example, how would I load the file C:\Users\camer\ts\TsAst\node_modules\typescript\lib\typescript.js
and then access ts.version
to return 2.4.2
?
Upvotes: 2
Views: 183
Reputation: 1984
There's a great example in the Chakra-Samples repository for both C++ and C#. If you're embedding on Linux, *BSD, or MacOS, you can modify the build script for above sample in line with the Hello World example in the same repository.
For a real-world example, check out how React Native Windows embeds ChakraCore by loading React Native JavaScript bundles using the same APIs as the samples. If you want to get fancy and do bytecode bundles to speed up app launch and time-to-interaction, React Native Windows' implementation can be used as a reference for that advanced use case as well.
Upvotes: 2