-
Notifications
You must be signed in to change notification settings - Fork 927
Need a method to choose JS engine. #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Perhaps a simple solution is to add a try-catch block to wrap the AddVroom method. then this factory will not be added since it failed to initialize VroomJS. I found that the JavaScript Engine Switcher already update to v2.1.2 version, but the dependencies still be 2.0.0 of React.NET 3.0.0. |
A PR has been made. |
+1 I have the same problem. |
I suggest to remove the engine selection functionality from the package and assigning responsibility for it to the user who configures React.NET. For example, it will be similarly to the DBMS selection in the Entity Framework Core. |
This is already handled - ReactJS.NET will only register engines if you have not registered them yourself: https://github.com/reactjs/React.NET/blob/master/src/React.Core/JavaScriptEngineFactory.cs#L360-L364. You just need to ensure you register the engines before registering ReactJS.NET. |
The problem is that the default configuration results in an error. I tried the following code (according to this example): JsEngineSwitcher engineSwitcher = JsEngineSwitcher.Instance;
engineSwitcher.EngineFactories.Add(new JintJsEngineFactory());
engineSwitcher.DefaultEngineName = "JintJsEngine";
Initializer.Initialize(registration => registration.AsSingleton());
var container = React.AssemblyRegistration.Container;
container.Register<ICache, NullCache>();
container.Register<IFileSystem, SimpleFileSystem>();
ReactSiteConfiguration.Configuration
.SetReuseJavaScriptEngines(false)
.AddScript("Sample.jsx"); And I had an error in this line (there is existing issue). I think, the error is in my code. But it's hard for me to know exactly where it is, because the configuration API uses implicit logic, which is dependent on global variables (JsEngineSwitcher). It would be much easier if the engine had to be explicitly specified (and get an error if it was specified incorrectly) UPD. I use it in .NET Core on macOS. |
@Daniel15 @dima117 @holmescn Good idea, but I would go further: need to remove from the React.Core all All problems, that prevented to do it have already been resolved in latest versions of the JavaScript Engine Switcher:
|
We've updated the JS engine registration logic in 4.0, please update if you're still encountering issues. |
I am trying to develop React.NET project under macOS. The VroomJS need to be compiled and I am working on it.
As I reading the source of React.NET, it already add Chakra as a candidate JS engine, but the
GetEngine
method just tried each factory and return the first that works. I have tried to install JavaScriptEngineSwitcher and add it toIServiceCollection
, but theReactEnvironment
remain try theVroomJS
engine. I don't find how to replace the factory in theTinyIoC
container.I thought we can have a option for the chosen of JS engine. That's more convenient.
I am working on building my VroomJS engine on macOS. If that works, I could try to fix this.
The text was updated successfully, but these errors were encountered: