Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 23 2021 09:24
    @sjrd banned @yensaoxuan_twitter
  • Apr 18 2021 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 2021 07:47
    @sjrd banned @quangs
  • Jan 23 2021 06:34
    @sjrd banned @Rebeka58_gitlab
  • Jun 08 2020 20:43
    @sjrd banned @sw7240614
  • Sep 29 2019 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 2019 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 2019 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 2019 15:31
    @sjrd banned @lerbatax
  • Jan 31 2019 23:04
    sjrd commented #3555
  • Jan 31 2019 22:56
    sjrd review_requested #3555
  • Jan 31 2019 22:56
    sjrd opened #3555
  • Jan 31 2019 21:06

    sjrd on 0.6.x

    Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)

  • Jan 31 2019 21:06
    sjrd closed #3554
  • Jan 31 2019 20:54
    erikvanoosten commented #2665
  • Jan 31 2019 16:33
    sjrd commented #3538
  • Jan 31 2019 15:54

    sjrd on master

    Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3552
  • Jan 31 2019 15:54

    sjrd on master

    Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3553
Joel Moberg
@joelmo
I will stay with have then. Thanks for answering.
Objektwerks
@objektwerks
How can I modify the fast/fullLinkJS output directory name. For instance, in lieu of js-opt or js-fastopt, I might want to name both js for the sake of consistency. I've attempted to set scalaJSLinkerOutputDirectory, but with no success.
Sébastien Doeraene
@sjrd
It's that setting, but it needs to be scoped in Compile / or Test /
Objektwerks
@objektwerks
Ok, let me try that.
Sébastien Doeraene
@sjrd
That said, if you make both fastOpt and fullOpt point to the same location, you'll confuse sbt's change detection mechanisms, and things can go wrong (either recomputing things too often or not often enough).
Objektwerks
@objektwerks
Ok. I've tried this fastLinkJS / scalaJSLinkerOutputDirectory := file("js") with no success.
Sébastien Doeraene
@sjrd
Compile / fastLinkJS / scalaJSLinkerOutputDirectory := file("js")
Objektwerks
@objektwerks
Ok. I got this to work Compile / fastLinkJS / scalaJSLinkerOutputDirectory := target.value / public / "dev" I tried you way, but the linker got a bit lost in terms of directory location. All I can say is - sbt is an art. :)
Sébastien Doeraene
@sjrd
Once you learn to use show, inspect and above all inspect tree, a lot of things become much easier.
Objektwerks
@objektwerks
Ok, thanks for the tip, Sebastien!
Sébastien Doeraene
@sjrd
For example, inspect proj/fastLinkJS directly tells you that it depends on proj / Compile / fastLinkJS / scalaJSLinkerOutputDirectory, among other things.
Objektwerks
@objektwerks
@sjrd Yeah, sbt inspect and show provide a bit of info.:)
Carlos Quiroz
@cquiroz
Finally got around to use dynamic ES imports with scala.js
Works great, thanks @sjrd and the team for this awesome feature
Sébastien Doeraene
@sjrd
It's mostly @gzm0 in this case 😉
Martijn
@martijnhoekstra:matrix.org
[m]
Is there a way to get a stack trace from a running scalajs program on node a la jstack?
I see there is a way to connect a debugger, maybe that's a fruity approach. Is there anything already there in any of the usual tooling for attaching debuggers (maybe even with sourcemaps)?
nafg
@nafg
Is there a benefit of sbt-crossproject over sbt-projectmatrix?
Sébastien Doeraene
@sjrd
sbt-projectmatrix is a generalization of sbt-crossproject.
That said, it creates even more projects in the build, so it can slow it down.
nafg
@nafg
@sjrd is that true even for only one scala version, or do you mean that it creates a project per scala version?
Do you mean it slows it down by taking longer to load the build (more settings for sbt to process), or that if it's compiling two scala versions in parallel that can be slower than just one (but still might be faster than compiling the same scala versions via ++)
Sébastien Doeraene
@sjrd
It creates one project per Scala version, yes. It's typically pointless to use project matrix if you don't have multiple Scala versions.
And yes it makes the build slower to load.
nafg
@nafg
That's sbt's major issue still, it seems to be slowed by the huge number of settings it proliferates. And Mill still doesn't seem to have enough plugins for me to switch to it
Mathieu
@mathieuleclaire

Hi,
I am building for a while my scala-js application at runtime because my application is pluggable. I have to be abble to add plugins at runtime or restart the application including new plugins. It use the Linker methods to achieve this (see sources here: https://github.com/openmole/openmole/blob/13-dev/openmole/gui/server/org.openmole.gui.server.jscompile/src/main/scala/org/openmole/gui/server/jscompile/JSPack.scala).

Until now, I dealt with my js lib dependencies by hand, merging js deps in a big js file. But I had often js loading or depencies resolution issues. So I try to use webpack, which is pretty straight forward when everything is compiled and linked from the sbt file. But not really in my case.

My idea was to
1) fastOptJS / webpack an empty project, which depends on the same dependencies as my application (and just calling a couple of fake methods to trigger webpack), so that I get a js file resolving all the js dependencies I need for my main project,
2) build my application with fastOptJS (but with no wepback resolution)
3) merge both js in a big one.
4) compress this big js file (if it is possible afterwards)

The problem is that the main method of the main application is not recognized any more, the html body tag remains empty and nothing happens when the html is run.

Any idea on how to solve my problem ? Is the way I do seems to be the good one ?
Thanks

Sébastien Doeraene
@sjrd
Perhaps you lost scalaJSUseMainModuleInitializer := true in the process?
Mathieu
@mathieuleclaire
Nope, I didn't. Actually, for now I test in separate code to evaluate the feasability. So I fastOptJS a scala code containing a main (with the scalaJSUseMainModuleInitializer := true) and I fastOptJS / webpack my empty project on an other hand. But it should lead to the same result, right ?
Mathieu
@mathieuleclaire
Here is my build:
lazy val emptyProject = project.in(file("packJS")) enablePlugins (ScalaJSBundlerPlugin) dependsOn(ace, bootstrapnative, tools, highlightjs)

lazy val runBootstrapDemo = taskKey[Unit]("runBootsrapDemo")
lazy val bootstrapDemo = project.in(file("bootstrapDemo")) enablePlugins (ScalaJSBundlerPlugin) settings(
  sourceCode,
  scalaJSUseMainModuleInitializer := true,
  runBootstrapDemo := {
    val demoResource = (resourceDirectory in Compile).value
    val deps = (fullOptJS / webpack in emptyProject in Compile).value.head.data
    val jsBuild = (fullOptJS in Compile).value.data

    IO.copyFile(merge(jsBuild, deps), target.value / "js/demobootstrapnative.js")
    IO.copyDirectory(demoResource, target.value)

  }
) dependsOn(ace, bootstrapnative, tools, highlightjs)


def merge(f1: File, in: File) = {
  val from = java.nio.file.Files.lines(in.toPath)
  val bw = new BufferedWriter(new FileWriter(f1))
  from.forEach { p => bw.append(p + "\n") }
  bw.close
  f1
}
Sébastien Doeraene
@sjrd
Does any exception appear in the browser console?
I think your setup will be problematic at least because emptyProject, having no main method, will dead-code-eliminate everything, including its imports from other modules. That in turn will cause Webpack to think that you're not referencing any extra library.
Also Webpack is supposed to rewrite the calls to require in the JS code produced by Scala.js. With your setup, that won't happen.
Mathieu
@mathieuleclaire
I have no exceptions
well, it depends on how I merge it. If I merge jsBuild in deps, I get no exceptions. Otherwise, I get Uncaught ReferenceError: require is not defined
Sébastien Doeraene
@sjrd
If you start your main with a println("hello"), does it get printed?
Mathieu
@mathieuleclaire
nope. The body is empty
I tried to add a App / main in the emptyproject with the same result
Sébastien Doeraene
@sjrd
Hum, your merge function looks like it's trying to append at the end of the file f1, but creating the FileWriter that way will truncate everything in the file before doing anything with it.
You can fix that with new FileWriter(f1, true).
But in general, in sbt it is very bad practice to modify files that are produced by other tasks. It messes up the change detection mechanisms, and things will break.
You should create a third file instead of modifying one of the two files.
Mathieu
@mathieuleclaire
you mean a third file where i merge first 2 ?
Sébastien Doeraene
@sjrd
Yes.
Mathieu
@mathieuleclaire
Now I have Uncaught ReferenceError: require is not defined
with:
def merge(first: File, second: File) = {
  val f1 = java.nio.file.Files.lines(first.toPath)
  val f2 = java.nio.file.Files.lines(second.toPath)
  val in = java.io.File.createTempFile("merge", "JS")
  val bw = new BufferedWriter(new FileWriter(in, true))
  f1.forEach { p => bw.append(p + "\n") }
  f2.forEach { p => bw.append(p + "\n") }
  bw.close
  in
}
Sébastien Doeraene
@sjrd
Well that makes sense to me, given what I said earlier:
Also Webpack is supposed to rewrite the calls to require in the JS code produced by Scala.js. With your setup, that won't happen.
It's possible that ScalaJSBundler's LibraryAndApplication mode could save you.
Mathieu
@mathieuleclaire
Mmh, this does not sound good
Uncaught SyntaxError: redeclaration of class $c_jl_Throwable
note: Previously declared at line 70829, column 6
with :
lazy val emptyProject = project.in(file("packJS")) enablePlugins (ScalaJSBundlerPlugin) settings(
  scalaJSUseMainModuleInitializer := true,
  webpackBundlingMode := LibraryAndApplication()
)dependsOn(ace, bootstrapnative, tools, highlightjs)
Mathieu
@mathieuleclaire
Is it because two mains are merged in the same js ?