如何将Haxe编译成JavaScript

How to compile Haxe into JavaScript?

本文关键字:JavaScript 编译 Haxe      更新时间:2023-09-26

Grunt-Haxe大约在3年前建成。将它与NPM haxelib一起安装,确实提供了一种编译纯JavaScript的方法,但有一个问题是无法利用JqueryExtern库;它只是抛出一个错误,每次当试图使用jQuery类说它找不到,即使添加import jQuery.*。它编译*。Hx文件可以用Haxetoolkit,但同样不能用hax - npm, haxelib, grunt-haxe,它只是在编译时忽略JqueryExtern库。

这是我的grunt配置-我有什么东西导致这些失败吗?我使用的haxe版本是haxe 3.2.1。我不能运行gulp watch,因为它需要为Haxe分配一个任务,但这个任务还不存在

   haxe: {
        complete_example: {
            main     : 'Main',
            classpath: [ app.src.hx],
            libs     : ['jQueryExtern' ], /*specify haxelib libraries */
            //flags    : [ 'something', 'createjs' ], /* define conditional compilation flags */
            //macros   : [ 'Mymacro.doSomethingCool()' ], /*call the given macro*/
            //resources: [ 'activity/xml/map-layout.json@map_layout' ], /*define named resource files*/
            //misc     : [ '-debug', "--dead-code-elimination", "--js-modern" ], /* add any other arguments*/
            output   : app.dest.js + 'hx.js',
            onError  : function ( e ) {
                /*custom error message */
                console.log( 'There was a problem...'n' + e );
            },
            force    : true /*continue processing task (like --force)*/
        }
    }
grunt.loadNpmTasks( 'grunt-haxe' );

我能够编译它的唯一方法是使用intelliJ IDEA浏览器的文件观察者插件以及官方版本的haxe工具包。没有发现其他插件可以完成这项工作。