jasononeil / webpack-haxe-loader

Webpack loader for the Haxe programming language.
MIT License
38 stars 11 forks source link

ES6 support? #57

Closed dionjwa closed 5 years ago

dionjwa commented 5 years ago

Haxe 4 includes the option of generating ES6 output. It doesn't work for my current project. Is this a configuration issue, or does ES6 require more significant plumbing?

/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:2490
  throw err
  ^

SyntaxError: Unexpected token (4:6)
    at Parser.pp$4.raise (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:2488:13)
    at Parser.pp.unexpected (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:623:8)
    at Parser.pp.semicolon (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:600:59)
    at Parser.pp$1.parseExpressionStatement (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1025:8)
    at Parser.pp$1.parseStatement (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:780:22)
    at Parser.pp$1.parseBlock (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1040:23)
    at Parser.pp$3.parseFunctionBody (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:2362:22)
    at Parser.pp$1.parseFunction (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1132:8)
    at Parser.pp$3.parseExprAtom (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1999:17)
    at Parser.pp$3.parseExprSubscripts (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1872:19)
    at Parser.pp$3.parseMaybeUnary (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1849:17)
    at Parser.pp$3.parseExprOps (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1791:19)
    at Parser.pp$3.parseMaybeConditional (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1774:19)
    at Parser.pp$3.parseMaybeAssign (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1750:19)
    at Parser.pp$3.parseExpression (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1722:19)
    at Parser.pp$3.parseParenExpression (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:2025:18)
    at Parser.pp$3.parseParenAndDistinguishExpression (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:2085:16)
    at Parser.pp$3.parseExprAtom (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1978:41)
    at Parser.pp$3.parseExprSubscripts (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1872:19)
    at Parser.pp$3.parseMaybeUnary (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1849:17)
    at Parser.pp$3.parseExprOps (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1791:19)
    at Parser.pp$3.parseMaybeConditional (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1774:19)
    at Parser.pp$3.parseMaybeAssign (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1750:19)
    at Parser.pp$3.parseExpression (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:1722:19)
    at Parser.pp$1.parseStatement (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:777:45)
    at Parser.pp$1.parseTopLevel (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:672:23)
    at Parser.parse (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:529:15)
    at Object.parse (/workspace/node_modules/haxe-modular/node_modules/acorn/dist/acorn.js:3378:37)
    at Parser.processInput (/workspace/node_modules/haxe-modular/tool/bin/split.js:1167:29)
    at new Parser (/workspace/node_modules/haxe-modular/tool/bin/split.js:1153:7)
    at Object.HxSplit.run.$hx_exports.run (/workspace/node_modules/haxe-modular/tool/bin/split.js:1035:15)
    at processOutput (/workspace/node_modules/haxe-loader/index.js:116:10)
    at exec (/workspace/node_modules/haxe-loader/index.js:94:27)
    at ChildProcess.exithandler (child_process.js:268:7)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
elsassph commented 5 years ago

JavaScript is processed by Haxe Modular which uses Acorn.js JavaScript parser in ES5 mode, so generally this doesn't support the new Haxe ES6 output. Do you have specific expectations from the ES6 output?

dionjwa commented 5 years ago

Not functionality thankfully.

I noticed that haxe4 had es6 output, and one of my js libraries is small and is meant to run in different websites, so I want to make the source as simple and readable as possible (while still using haxe!), and thought es6 might help there. This answers my question for the future, thanks!