-
Notifications
You must be signed in to change notification settings - Fork 928
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
Misconceptions about the JavaScript Engine Switcher version 2.X #409
Comments
Hey @Taritsyn, thank you so much for the detailed post! This would be good content for the https://reactjs.net/ website 😃 |
The V8 package does not work with core 1.0 in VS2017. |
@a40637francisco Yes, JavaScriptEngineSwitcher.V8 and JavaScriptEngineSwitcher.Jurassic does not support .NET Core, because .NET Core not supported by the original libraries. |
Great read! |
@gunnim This is done in order to allow user can choose only what he really needs. Advantages of this approach are more obvious when working with the JavaScriptEngineSwitcher.ChakraCore module and LibSass Host for .NET library. In addition, there is another reason. |
Closing this mega-issue, but feel free to keep referencing it :) |
ClearScript.V8 is now deprecated should instead use Microsoft.ClearScript |
This is not an error, but an open appeal to React.NET's users.
Misconceptions about the JavaScript Engine Switcher version 2.X
Over the past six months, I often had to communicate with ReactJS.NET's users about errors, that occur due the JavaScript Engine Switcher. In 80 percent of cases, these were not errors, but just wrong usage of the library, which caused by misconceptions about how it works. In this post I will consider most part of these misconceptions.
MSIE
For correct working of the JavaScriptEngineSwitcher.Msie is enough, that the Internet Explorer is installed on a computer.
At the moment, most of the JS libraries are written in ECMAScript 5 (React is also one of them). Full support of the ECMAScript 5 standard are appeared only in the Internet Explorer 9, when was released a new JavaScript engine - Chakra.
If you run the ReactJS.NET with the JavaScriptEngineSwitcher.Msie on a computer on which installed the Internet Explorer 8 or below, then you will get an error like this:
Therefore, you should always use the JavaScriptEngineSwitcher.Msie only on computers on which installed the Internet Explorer 9+ or Microsoft Edge. Ideally, same version of browser should be installed on the development computer and production server.
If you do not have the opportunity to install a modern version of browser on the server, then start using the JavaScriptEngineSwitcher.ChakraCore.
V8
JavaScriptEngineSwitcher.V8 require
msvcp120.dll
andmsvcr120.dll
assemblies from the Visual C++ Redistributable Packages for Visual Studio 2013.Since version 2.2.0 the JavaScriptEngineSwitcher.V8's native assemblies require
msvcp140.dll
assembly from the Visual C++ Redistributable for Visual Studio 2015.JavaScriptEngineSwitcher.V8 package no longer contains native assemblies, so in addition to it, you need to install the ClearScript.V8 package.
Indeed, since version 2.1.0, JavaScriptEngineSwitcher.V8 package does not contain native assemblies for Windows, but these assemblies have not gone anywhere, and were moved to separate packages: JavaScriptEngineSwitcher.V8.Native.win-x86 and JavaScriptEngineSwitcher.V8.Native.win-x64. Therefore, you do not need to install the ClearScript.V8 package, which has no relation to the JavaScript Engine Switcher. In general, usage of the ClearScript.V8 package together with the JavaScriptEngineSwitcher.V8 is causing errors.
After installation of the
JavaScriptEngineSwitcher.V8.Native.*
packages, native assemblies need to be manually copied to the application directory, because this is recommended by the authors of the ClearScript.After installation of the packages don't need to do any additional actions, this is the main advantage of the JavaScriptEngineSwitcher.V8. Installation of native assemblies is performed by using the following tools:
runtimes
directories and RIDs.In .NET 4.X versions of the JavaScriptEngineSwitcher.V8 a native assemblies are loaded from non-standard directories. In this case, native assemblies are located in the
x86
andx64
subdirectories ofbin\[Debug|Release]
directory (for web applications and sites just thebin
directory).For 64-bit Windows is enough to install only the JavaScriptEngineSwitcher.V8.Native.win-x64 package.
.NET applications, ASP.NET web applications and sites in 64-bit Windows can run not only in 64-bit processes, but also in 32-bit processes. For correct working of the JavaScriptEngineSwitcher.V8 in 32-bit process need to install the JavaScriptEngineSwitcher.V8.Native.win-x86 package. If you do not know in which process will run your application or web site, then install both packages.
ChakraCore
JavaScriptEngineSwitcher.ChakraCore for Windows require assemblies
msvcp120.dll
andmsvcr120.dll
from the Visual C++ Redistributable Packages for Visual Studio 2013.Since version 2.1.0 the JavaScriptEngineSwitcher.ChakraCore's native assemblies require
msvcp140.dll
assembly from the Visual C++ Redistributable for Visual Studio 2015.JavaScriptEngineSwitcher.ChakraCore package no longer contains native assemblies, so in addition to it, you need to install the Microsoft.ChakraCore package.
Indeed, since version 2.1.0, JavaScriptEngineSwitcher.ChakraCore package does not contain native assemblies for Windows, but these assemblies have not gone anywhere, and were moved to separate packages: JavaScriptEngineSwitcher.ChakraCore.Native.win-x86 and JavaScriptEngineSwitcher.ChakraCore.Native.win-x64. Therefore, you do not need to install the Microsoft.ChakraCore package, which has no relation to the JavaScript Engine Switcher.
In addition to these two packages are also available three packages:
If you need support for other operating systems, then you can build the ChakraCore assembly by using following instructions from official repository. Only instead of the latest version of ChakraCore's source code, you need to use a version, that is supported by the JavaScriptEngineSwitcher.ChakraCore.
After installation of the
JavaScriptEngineSwitcher.ChakraCore.Native.*
packages, native assemblies need to be manually copied to thebin
directory.After installation of the packages don't need to do any additional actions, this is the main advantage of the JavaScriptEngineSwitcher.ChakraCore. Installation of native assemblies is performed by using the following tools:
runtimes
directories and RIDs.In .NET 4.X versions of the JavaScriptEngineSwitcher.ChakraCore for native assemblies are overrided the default search paths. In this case, native assemblies are located in the
x86
,x64
andarm
subdirectories ofbin\[Debug|Release]
directory (for web applications and sites just thebin
directory).For 64-bit Windows is enough to install only the JavaScriptEngineSwitcher.ChakraCore.Native.win-x64 package.
.NET applications, ASP.NET web applications and sites in 64-bit Windows can run not only in 64-bit processes, but also in 32-bit processes. For correct working of the JavaScriptEngineSwitcher.ChakraCore in 32-bit process need to install the JavaScriptEngineSwitcher.ChakraCore.Native.win-x86 package. If you do not know in which process will run your application or web site, then install both packages.
P.S.: To avoid such misconceptions in the future I recommend you to read fluently “Release Notes” sections of updated NuGet packages. In case, when problems have already occurred, read the CHANGELOG.md or “Releases” sections. Also do not forget about the documentation and issue tracker.
UPDATE 1/1/2019: Fixed a broken links and updated information about the
JavaScriptEngineSwitcher.ChakraCore.Native.*
packages. It is also worth noting that in the JavaScript Engine Switcher version 3.X there have been some changes. For example, JavaScriptEngineSwitcher.V8 and JavaScriptEngineSwitcher.ChakraCore for Windows now require the Microsoft Visual C++ Redistributable for Visual Studio 2017. Other changes can be found in the “How to upgrade applications to version 3.X” section of documentation.The text was updated successfully, but these errors were encountered: