Skip to content
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

ChakraCore compatibility with ES6 modules #62

Open
Zenexer opened this issue Sep 30, 2018 · 6 comments
Open

ChakraCore compatibility with ES6 modules #62

Zenexer opened this issue Sep 30, 2018 · 6 comments

Comments

@Zenexer
Copy link

Zenexer commented Sep 30, 2018

Is it possible to get ChakraCore to work with ES6 modules? I'm attempting to use it with ReactJS.NET, and I can't find a way around this error:

ReactScriptLoadException: Error while loading "js\components\Test.jsx": Compile error: Module import or export statement unexpected here
Line: 14
Column:1
React.ReactEnvironment.EnsureUserScriptsLoaded()
@Taritsyn
Copy link
Owner

ES6 modules are not supported by the JavaScript Engine Switcher library. I want to remind for what purpose the JavaScript Engine Switcher library was created:

JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines (MSIE JavaScript Engine for .Net, Microsoft ClearScript.V8, Jurassic, Jint, ChakraCore and VroomJs). This library allows you to quickly and easily switch to using of another JavaScript engine.

@Zenexer
Copy link
Author

Zenexer commented Oct 1, 2018

Does that mean they are supported by the underlying .NET libraries (e.g., ClearScript.V8), and would therefore be usable if I interfaced with those directly? I've been scouring the web for resources and have found very few answers, unfortunately.

@Taritsyn
Copy link
Owner

Taritsyn commented Oct 1, 2018

I can not promise anything, but on weekend I'll try to investigate this problem.

@Taritsyn
Copy link
Owner

Taritsyn commented Oct 7, 2018

Hello, Paul!

I checked support of ES6 modules by JS engines, which are used in the JavaScript Engine Switcher. I was very surprised to learn that the Microsoft ClearScript.V8 and prerelease version of Jint do not support them. Support is available only in the ChakraCore (a lot of things need to implement yourself) and NiL.JS (so far very raw support and many errors).

To implement modules, at least two methods (EvaluateModule and ExecuteModule) must be added to the IJsEngine interface. Plus, need to provide hosting of modules: resolving paths and loading code from the file system. This is a large amount of work (for the most part research). Therefore, third version of the JavaScript Engine Switcher will be released without this functionality. While leave the implementation of this functionality for the future (fourth version).

@Diaskhan
Copy link

Diaskhan commented Apr 27, 2019

The case scenario!

I'am trying to make C# bundler via nodejs envirement!
But all comes to One to use managed code and wrapper ?

@Taritsyn Is there possible to make some bundler in C# like webpack do it ?
Analyze dependecies zipped and save to file ?
How its possible to implement in C# world ?

Enterpise Scenarion When Developers write code on js! And Tooling budle them!

@Taritsyn
Copy link
Owner

@Diaskhan Hello! You can use the EmbedHostObject and EmbedHostType methods to pass .NET objects and types to script, but there are some limitations (for example, collections are not supported). Interop is still the weak side of this library.

If I were you, I would look at specialized libraries for working with Node.js: Edge.js or Microsoft.AspNetCore.NodeServices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants