Problem in Compiling Web.HTML.HTMLScriptElement

Compiling Web.HTML.HTMLScriptElement
Error found:
at .spago/web-html/v3.2.0/src/Web/HTML/HTMLScriptElement.purs:1:1 - 75:69 (line 1, column 1 - line 75, column 69)

Unable to parse foreign module:

.spago/web-html/v3.2.0/src/Web/HTML/HTMLScriptElement.js


The module could not be parsed:


AsyncToken {tokenSpan = TokenPn 1062 57 30, tokenLiteral = "async", tokenComment = []}

See documentation/ErrorParsingFFIModule.md at master · purescript/documentation · GitHub for more information,
or to contribute content related to this error.

[error] Failed to build.

I’m new to purescript. Try to setup a new project. When I try to build this is what get.

Hello,

can you tell us a bit more about how you setup your project and where you got your PureScript compiler from (see the issue bellow)?

For what it’s worth there was an similar issue before: HTMLScriptElement.purs doesn't compile · Issue #31 · purescript-web/purescript-web-html · GitHub

If you download/install PureScript / Spago via NPM and you should be fine.


As far as I understand it the problem is this:

  • the PureScript compiler is written in Haskell
  • It uses a library called language-javascript
  • At some point (0.7.1.0?) this library updated to deal with newer language constructs in JavaScript - including Support for async/await - so now async is a keyword - the new parser in the library does not like the function async used in HTMLScriptElements.js
  • Now this is no problem if the PureScript-compiler is build against the right version of this library but it seems on some systems/circumstances (homebrew) if you build it yourself the wrong version might still be selected
1 Like