镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

ChakraCore compatibility with ES6 modules #62

Description

@Zenexer

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()

Activity

  1. Taritsyn commented on Sep 30, 2018

    @Taritsyn
    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.

  2. Zenexer commented on Oct 1, 2018

    @Zenexer
    Author

    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.

  3. Taritsyn commented on Oct 1, 2018

    @Taritsyn
    Owner

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

  4. Taritsyn commented on Oct 7, 2018

    @Taritsyn
    Owner

    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).

  5. Diaskhan commented on Apr 27, 2019

    @Diaskhan

    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!

  6. Taritsyn commented on Apr 27, 2019

    @Taritsyn
    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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions