2

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?

Cameron Taggart
  • 5,047
  • 3
  • 35
  • 62

1 Answers1

2

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.

Matt Hargett
  • 1,442
  • 1
  • 12
  • 32