Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 21 02:28
    exoego edited #310
  • Aug 21 02:28
    exoego edited #310
  • Aug 21 02:28
    exoego edited #310
  • Aug 19 14:46
    julienrf commented #312
  • Aug 19 11:40
    vhiairrassary edited #312
  • Aug 19 11:20
    vhiairrassary opened #312
  • Aug 19 08:12
    julienrf commented #293
  • Aug 19 08:05
    vhiairrassary commented #293
  • Aug 18 10:58
    julienrf commented #311
  • Aug 18 10:24
    exoego commented #311
  • Aug 18 08:07
    julienrf commented #311
  • Aug 18 07:49
    unarist commented #311
  • Aug 18 07:46
    exoego closed #311
  • Aug 18 07:46
    exoego commented #311
  • Aug 18 07:23
    unarist commented #311
  • Aug 18 07:23
    unarist commented #311
  • Aug 15 09:28
    exoego commented #311
  • Aug 15 09:28
    exoego commented #311
  • Aug 15 08:29
    julienrf commented #311
  • Aug 15 08:19
    exoego commented #311
nafg
@nafg
If you change the artifact name it won't even see it
OTOH if you pick an artifact name suffix that is at all awkward, it would be unfortunate to have to remain with it.
So it's a bit of a dilemma
Another place this has happened is https://github.com/vmunier/sbt-web-scalajs
bjenkinsgit
@bjenkinsgit
I'm trying to migrate from using jsDependencies to npmDependencies as @japgolly recommends in the latest scalajs-react README and have scalajs-bundler in my build.sbt file and it seems to be pulling down my NPM dependencies and emitting them to a file named a2-fastopt-bundle.js when I issue a fastOptJS::webpack command in my sbt repl. My project name, however, is sp and when I issue the command fastOptJS it generates an sp-fastopt.js file that has the main entry point (my main is in a file named ReactApp.scala and when do a grep ReactApp sp-fastopt.js I see JS code in there). My question is: I was under the impression (from reading the scalajs-bunder docs) that issuing fastOptJS::webpack would integrate my main with the other JS libraries I need (jQuery, scalajs-react, etc.) into ONE .js file. But when I grep for "ReactApp" in the as-fastopt-bundle.js file, it is not there. Are all my .js code needs supposed to be in one .js file or not?
Julien Richard-Foy
@julienrf
Yes, but make sure that you properly import the libs, otherwise they will be cut out of the resulting bundle
bjenkinsgit
@bjenkinsgit
@julienrf Can you be more specific with properly import the libs ? Do I need to order the dependencies manually in my build.sbt file or will NPM just sort that out?
Here is a snippet from my build.sbt file:
enablePlugins(ScalaJSBundlerPlugin)

npmDependencies in Compile ++= Seq(
  "popper.js" -> "^1.12.9",
  "jquery" -> versions.jQuery,
  "bootstrap" -> versions.bootstrap,
  "datatables" -> versions.datatables,
  "datatables-bootstrap3-plugin" -> versions.datatables_bootstrap,
  "react" -> versions.react,
  "react-dom" -> versions.react)
@julienrf I am getting some errors when I do fastOptJS::webpack but they look more like warnings (and, a .js file is getting output)
sbt:a2> fastOptJS::webpack
[info] Updating NPM dependencies
[error] npm WARN deprecated mixin-deep@1.3.1: Critical bug fixed in v2.0.1, please upgrade to the latest version.
[error] npm WARN deprecated set-value@2.0.0: Critical bug fixed in v3.0.1, please upgrade to the latest version.
[error] npm WARN deprecated set-value@0.4.3: Critical bug fixed in v3.0.1, please upgrade to the latest version.
[info] > fsevents@1.2.9 install /Users/bwj/Documents/workspace_EE/Attendant/A2/target/scala-2.12/scalajs-bundler/main/node_modules/fsevents
[info] > node install
[error] node-pre-gyp WARN Using request for node-pre-gyp https download 
[info] [fsevents] Success: "/Users/bwj/Documents/workspace_EE/Attendant/A2/target/scala-2.12/scalajs-bundler/main/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node" is installed via remote
[info] > uglifyjs-webpack-plugin@0.4.6 postinstall /Users/bwj/Documents/workspace_EE/Attendant/A2/target/scala-2.12/scalajs-bundler/main/node_modules/uglifyjs-webpack-plugin
[info] > node lib/post_install.js
[error] npm notice created a lockfile as package-lock.json. You should commit this file.
[info] added 651 packages from 427 contributors and audited 5810 packages in 13.663s
[info] found 2 vulnerabilities (1 low, 1 high)
[info]   run `npm audit fix` to fix them, or `npm audit` for details
[info] Writing scalajs.webpack.config.js
[info] Bundling the application with its NPM dependencies
[info] Version: 3.5.5
[info] Hash: 96a39776c33ebd7d931a
[info] Time: 451ms
[info] Path: <default>
[info] Built at 2019-06-24T15:22:51.911
[info]                    Asset    Size                     Chunks
[info]     a2-fastopt-bundle.js   81312   [emitted]   [a2-fastopt]
[info] a2-fastopt-bundle.js.map   64140   [emitted]   [a2-fastopt]
[success] Total time: 22 s, completed Jun 24, 2019 3:22:56 PM
bjenkinsgit
@bjenkinsgit
@dragonfly-ai I had the same issue with @sjrd 's https://github.com/scala-js/scalajs-cross-compile-example sample. I wanted to convert that sample to using the @sjrd 's newer syntax of using crossType in build.sbt. The solution was to slap a @JSExport before my main function. Then it gets exported to my fastopt.js file.
bjenkinsgit
@bjenkinsgit
What setting do I have to change to get scalajs-bundler to look in a different directory for scalajs sources (ex. js/src) rather than in src?
Thien Do
@dvkndn
  1. are you using MainInitializer?
  2. I think what @julienrf meant is to import the library and actually used them in your app
or else it would be removed by dead code elimination
bjenkinsgit
@bjenkinsgit

@dvkndn Irrelevant. At this point, I don't care about any imported libs from npmDependencies. I'm just trying to get webpack to find my Main scalajs entry point object. I have a dead simple entry point object at js/src/main/scala/Main.scala like so:

import scala.scalajs.js
import scala.scalajs.js.annotation.{JSExport,JSExportTopLevel}

@JSExportTopLevel("Main")
object Main {
  @JSExport
  def main(args: Array[String]): Unit = {
    println("Hello from Javascript!")
//    val lib = new MyLibrary
//    println(lib.sq(2))
  }
}

And a dead simple top level build.sbt file:

import sbtcrossproject.{crossProject, CrossType}

inThisBuild(Def.settings(
  crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.6"),
  scalaVersion := crossScalaVersions.value.last,
  version := "0.1.1-SNAPSHOT",
))  

lazy val sp = crossProject(JSPlatform, JVMPlatform)
  .in(file("."))
  .settings()
  .jvmSettings()
  .jsSettings()
  .jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))

scalaJSUseMainModuleInitializer in sp.js in Compile := true

Notice the extra axis in scalaJSUseMainModuleInitializer in sp.js in Compile of sp.js. When I issue a fastOptJS command, it produces an sp-fastopt.js file and if I then issue the command spJS/run I get the expected output of Hello from Javascript. More importantly, if I grep for Main in the sp-fastopt.js file, I see the JS code. The webpack plugin puts its output from fastOptJS::webpack in a different location with a different name of *-fastopt-bundle.js. The only way I can get webpack to find my Main.scala object is if I MOVE that file out from under js/src/main/scala/ and place it at src/main/scala and change my build.sbt file to remove the sp.js axis qualifier in scalaJSUseMainModuleInitializer and then to add in the init to the plugin. So, at the bottom of my build.sbt file I have:

scalaJSUseMainModuleInitializer in Compile := true
enablePlugins(ScalaJSBundlerPlugin)

So it seems pretty clear to me that webpack is defaulting to looking in src/main/... for files. I'm hoping there is a setting that will allow me to set the path for finding ScalaJS source so I can point it to js/src/.... Notice that I have commented out a call to a instantiate a shared Scala object called MyLibrary. Cross-builds allow you to have a ./shared subfolder in which you can put scala code that is callable by BOTH Scalajs scala code and regular scalacode (jvm folder code). So I also need for webpack to pick up on that. You can see I had to comment out that logic in my Main.scala JS code because webpack could not find it.

Øyvind Raddum Berg
@oyvindberg
@bjenkinsgit you're supposed to store the js/jvm projects in vals as well. lazy val spJs = sp.js
bjenkinsgit
@bjenkinsgit
@oyvindberg Hmm, so far I've been able to get away without that extra syntax / boilerplate.
Øyvind Raddum Berg
@oyvindberg
I would try it anyway
Russ White
@russwyte

can I use this two together?
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0")

When I try do this:

    jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv(),
...

I get:
error: object jsdomnodejs is not a member of package org.scalajs.jsenv

Julien Richard-Foy
@julienrf
For Scala.js 0.6, you have to use a custom version number: https://scalacenter.github.io/scalajs-bundler/getting-started.html#basic-setup
Russ White
@russwyte
Thanks!
What if you want to cross compile 1.x.x and 0.6?
Julien Richard-Foy
@julienrf
Then you have to take the Scala.js version as an environment variable, and compute the scalajs-bundler version number accordingly.
nafg
@nafg
Has anyone tried scalajs-bundler on sbt 1.3 prereleases?
I get errors like this:
[error] java.util.zip.ZipException: duplicate entry: public/app_js-fastopt-library.js.map
[error]         at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:232)
[error]         at java.base/java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
[error]         at sbt.io.IO$.addFileEntry$1(IO.scala:684)
[error]         at sbt.io.IO$.$anonfun$writeZip$3(IO.scala:693)
[error]         at sbt.io.IO$.$anonfun$writeZip$3$adapted(IO.scala:693)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:941)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:941)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1429)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error]         at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error]         at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error]         at sbt.io.IO$.writeZip(IO.scala:693)
[error]         at sbt.io.IO$.$anonfun$archive$1(IO.scala:647)
[error]         at sbt.io.IO$.$anonfun$archive$1$adapted(IO.scala:644)
[error]         at sbt.io.IO$.$anonfun$withZipOutput$1(IO.scala:730)
[error]         at sbt.io.IO$.$anonfun$withZipOutput$1$adapted(IO.scala:718)
[error]         at sbt.io.Using.apply(Using.scala:27)
[error]         at sbt.io.IO$.withZipOutput(IO.scala:718)
[error]         at sbt.io.IO$.archive(IO.scala:644)
[error]         at sbt.io.IO$.jar(IO.scala:619)
[error]         at sbt.Package$.makeJar(Package.scala:164)
[error]         at sbt.Package$.$anonfun$apply$4(Package.scala:99)
[error]         at sbt.Package$.$anonfun$apply$4$adapted(Package.scala:97)
[error]         at sbt.util.Tracked$.$anonfun$outputChanged$1(Tracked.scala:102)
[error]         at sbt.Package$.apply(Package.scala:108)
[error]         at sbt.Defaults$.$anonfun$packageTask$1(Defaults.scala:1343)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:280)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error]         at sbt.Execute.work(Execute.scala:289)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:280)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]         at java.base/java.lang.Thread.run(Thread.java:844)
unless I do this:
    Assets / WebKeys.deduplicators += {
      val log = streams.value.log

      { files: Seq[File] =>
        files.distinct match {
          case Seq(one) => Some(one)
          case _        =>
            log.error(s"Actual duplicates: " + files)
            None
        }
      }
    }
Dan Di Spaltro
@dispalt
@nafg which version of 1.3 specifically?
nafg
@nafg
@dispalt RC2, and a nightly
1.3.0-bin-20190713T235600
(newer than RC2)
Matt Hughes
@matthughes
Under what circumstances would I see my sbt shell spawn off multiple node sub-processes? Trying to improve the speed of my build and confused why I see like 10 node sub-processes at one time.
Somewhat related, I’m trying to configure my build to put the node_modules outside of my project’s root directory. I’ve set crossTarget in npmUpdate := file("/Users/matt/npm”), but it doesn’t seem to have the effect I’d hope. Trying to avoid having my CI server download the same 500 JS modules on every SNAPSHOT build.
Sébastien Doeraene
@sjrd
@matthughes Scala.js spawns several instances of node when testing, to run tests in parallel.
Matt Hughes
@matthughes
thx
nkgm
@nkgm
Getting java.lang.NoClassDefFoundError: org/scalajs/sbtplugin/ScalaJSPlugin$autoImport$ with WebScalaJSBundlerPlugin ("sbt-web-scalajs-bundler" % "0.15.0"). Am on"sbt-scalajs" % "0.6.28". Do I need to be using a different version?
Sébastien Doeraene
@sjrd
You need the 0.6.x-compatible version of scalajs-bundler, yes.
nkgm
@nkgm
Already doing what the guide suggests: addSbtPlugin("ch.epfl.scala" % "sbt-web-scalajs-bundler" % "0.15.0"). There is no 0.15.0-0.6 for sbt-web-scalajs-bundler.
nkgm
@nkgm
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28")
addSbtPlugin("com.vmunier" % "sbt-web-scalajs" % "1.0.9-0.6")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0-0.6")
addSbtPlugin("ch.epfl.scala" % "sbt-web-scalajs-bundler" % "0.15.0")
Sébastien Doeraene
@sjrd
hum
@julienrf Shouldn't there be a -0.6 version of sbt-web-scalajs-bundler?
nkgm
@nkgm
FWIW I've tried that but it won't resolve the dependency
Julien Richard-Foy
@julienrf
Indeed, it may not have been published. Let me check.
@nkgm When you use version "0.15.0-0.6" for sbt-web-scalajs-bundler, what error message do you get exactly? Which download URLs have been unsuccessfully tried?
nkgm
@nkgm
Let me check again
nkgm
@nkgm
Of course now it works, and I'm embarassed :)
Intellij kept choking on this dependency (using sbt shell for builds and imports), so I went back and did a full reimport in order to enable sbt sources to better troubleshoot this issue, and apparently that's all it took
Julien Richard-Foy
@julienrf
no worries ;)