hxasync
hxasync copied to clipboard
Can't work with npm package "acorn" while using webpack
Hello, I'm using haxe to develop a tool project recently, I'm having some trouble with js.lib.promise syntax, after looking up related solutions in the community, I found haxelib hxasync, but I found that the project can't compile when I use it, the log information seems to be due to the npm Acorn library which was dependent on webpack, and the error output is as follows:
C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:2490
throw err
^
SyntaxError: Unexpected token (536:19)
at Parser.pp$4.raise (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:2488:13)
at Parser.pp.unexpected (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:623:8)
at Parser.pp.expect (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:617:26)
at Parser.pp$3.parseObj (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:2173:14)
at Parser.pp$3.parseExprAtom (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1994:17)
at Parser.pp$3.parseExprSubscripts (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1872:19)
at Parser.pp$3.parseMaybeUnary (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1849:17)
at Parser.pp$3.parseExprOps (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1791:19)
at Parser.pp$3.parseMaybeConditional (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1774:19)
at Parser.pp$3.parseMaybeAssign (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1750:19)
at Parser.pp$3.parseMaybeAssign (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1761:23)
at Parser.pp$3.parseExpression (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1722:19)
at Parser.pp$1.parseStatement (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:777:45)
at Parser.pp$1.parseBlock (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1040:23)
at Parser.pp$3.parseFunctionBody (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:2362:22)
at Parser.pp$1.parseFunction (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1132:8)
at Parser.pp$3.parseExprAtom (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1999:17)
at Parser.pp$3.parseExprSubscripts (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1872:19)
at Parser.pp$3.parseMaybeUnary (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1849:17)
at Parser.pp$3.parseExprOps (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1791:19)
at Parser.pp$3.parseMaybeConditional (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1774:19)
at Parser.pp$3.parseMaybeAssign (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1750:19)
at Parser.pp$3.parseExpression (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1722:19)
at Parser.pp$3.parseParenExpression (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:2025:18)
at Parser.pp$3.parseParenAndDistinguishExpression (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:2085:16)
at Parser.pp$3.parseExprAtom (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1978:41)
at Parser.pp$3.parseExprSubscripts (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1872:19)
at Parser.pp$3.parseMaybeUnary (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1849:17)
at Parser.pp$3.parseExprOps (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1791:19)
at Parser.pp$3.parseMaybeConditional (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1774:19)
at Parser.pp$3.parseMaybeAssign (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1750:19)
at Parser.pp$3.parseExpression (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:1722:19)
at Parser.pp$1.parseStatement (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:777:45)
at Parser.pp$1.parseTopLevel (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:672:23)
at Parser.parse (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:529:15)
at Object.parse (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\node_modules\acorn\dist\acorn.js:3378:37)
at Parser.processInput (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\tool\bin\split.js:1176:29)
at new Parser (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\tool\bin\split.js:1162:7)
at Object.HxSplit.run.$hx_exports.run (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-modular\tool\bin\split.js:1044:15)
at processOutput (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-loader\index.js:116:10)
at exec (C:\Users\Xuzx\Desktop\Haxe\OgmoEditor3-CE\node_modules\haxe-loader\index.js:94:27)
at ChildProcess.exithandler (child_process.js:285:7)
Do you know how to solve it? You can install the hxasync lib in the Ogmo3 project and write some code in the initialization process for testing
Hi,
Could you please tell me what node version you are using?
Also, have you checked what exactly is written in your code where it fails? Perhaps there is some invalid syntax produces by the hxasync?
My library does some modifications to the source code after it is compiled by Haxe. More specifically, it replaces special placeholders in the code by the async keyword. I suspect that there might be some cases, where hxasync replaces parts of the code which it should not replace.
Thanks for the reply, the Node version I use for the developing project is 10.18.0, I tested 14.20.0 on the Ogmo project and got the same error. The test code I added to the Ogmo project just like follow, and this will get the above error reported by acorn lib acorn when i run the build command
@:build(hxasync.AsyncMacro.build())
class XXType
{
...
// some code
@async public function myPromise() {
return "something";
}
@async public function some() {
return @await this.myPromise();
}
...
}
Thanks for the information.
Would you be able to provide some simple project were the error would be reproduced?
I would like to avoid setting up this Ogmo3 project myself.