/// <summary> /// Ensures that Babel has been loaded into the JavaScript engine. /// </summary> private void EnsureBabelLoaded(IJsEngine engine) { // If Babel is disabled in the config, don't even try loading it if (!_config.LoadBabel) { throw new BabelNotLoadedException(); } var babelLoaded = engine.Evaluate <bool>("typeof ReactNET_transform !== 'undefined'"); if (!babelLoaded) { #if NET40 var assembly = typeof(ReactEnvironment).Assembly; #else var assembly = typeof(ReactEnvironment).GetTypeInfo().Assembly; #endif string resourceName = _config.BabelVersion == BabelVersions.Babel7 || _config.BabelVersion == null ? "React.Core.Resources.babel.generated.min.js" : _config.BabelVersion == BabelVersions.Babel6 ? "React.Core.Resources.babel-legacy.generated.min.js" : throw new ReactConfigurationException("BabelVersion was not null, but did not contain a valid value."); if (_config.AllowJavaScriptPrecompilation && engine.TryExecuteResourceWithPrecompilation(_cache, resourceName, assembly)) { // Do nothing. } else { engine.ExecuteResource(resourceName, assembly); } } }
/// <summary> /// Ensures that Babel has been loaded into the JavaScript engine. /// </summary> private void EnsureBabelLoaded(IJsEngine engine) { // If Babel is disabled in the config, don't even try loading it if (!_config.LoadBabel) { throw new BabelNotLoadedException(); } var babelLoaded = engine.Evaluate <bool>("typeof ReactNET_transform !== 'undefined'"); if (!babelLoaded) { #if NET40 var assembly = typeof(ReactEnvironment).Assembly; #else var assembly = typeof(ReactEnvironment).GetTypeInfo().Assembly; #endif const string resourceName = "React.Core.Resources.babel.generated.min.js"; if (_config.AllowJavaScriptPrecompilation && engine.TryExecuteResourceWithPrecompilation(_cache, resourceName, assembly)) { // Do nothing. } else { engine.ExecuteResource(resourceName, assembly); } } }
private void LoadResource(IJsEngine engine, string resourceName, Assembly assembly) { if (_config.AllowJavaScriptPrecompilation && engine.TryExecuteResourceWithPrecompilation(_cache, resourceName, assembly)) { // Do nothing. } else { engine.ExecuteResource(resourceName, assembly); } }