Sunday, 11 June 2017

How to use io.scalajs with scala-js example application -- build difficulties

I would love to use scala-js for a whole pile of AWS Lambdas I need to write.

So far I'm struggling a bit with the basics.

I followed the basic tutorial on scala-js, and got it to work.

Now, I need to use some libraries provided by node, so I add this to my build.sbt, as instructed by the github page (https://github.com/scalajs-io/nodejs):

resolvers += Resolver.sonatypeRepo("releases")

libraryDependencies += "io.scalajs" %%% "nodejs" % "0.4.0-pre5"

Further, I modified the original scala-js tutorial slightly, so it looks like this:

package tutorial.webapp

import io.scalajs.nodejs.buffer.Buffer

import scala.scalajs.js.JSApp

object TutorialApp extends JSApp {

  def main(): Unit = {
    println("Hello world!")
    val f = Buffer.from("hi")
  }
}

This small change makes my program fail to compile:

[error] /Users/mike/sjs/NodeNative/src/main/scala/tutorial/webapp/TutorialApp.scala:3: object scalajs is not a member of package io
[error] import io.scalajs.nodejs.buffer.Buffer
[error]           ^
[error] /Users/mike/sjs/NodeNative/src/main/scala/tutorial/webapp/TutorialApp.scala:11: not found: value Buffer
[error]     val f = Buffer.from("hi")
[error]             ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Jun 11, 2017 4:07:06 PM

What I don't understand is IntelliJ is perfectly happy believing that scalajs is a member of io

Obviously I've made some mistake somewhere, but I've been through it and through it and really don't see it.



via Mike

No comments:

Post a Comment