Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 18 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 07:47
    @sjrd banned @quangs
  • Jan 23 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
  • Jan 31 2019 15:33
    sjrd commented #2665
Allan Brighton
@acbrighton_twitter

@srj Thanks for the tips. I was trying to follow this template project.

It took me a while to figure out the right way to get the js dependencies for a Play/Scalajs app.
In the end I found that the client needed these lines in buid.sbt:

    Compile / fastLinkJS / jsMappings += toPathMapping((Compile / packageJSDependencies).value),
    Compile / fullLinkJS / jsMappings += toPathMapping((Compile / packageMinifiedJSDependencies).value),

I also changed findScript.scala.html:

@(assets: AssetsFinder, scripts: String*)

@scripts.find(name => getClass.getResource(s"/public/$name") != null).map { asset =>
  <script src=@assets.path(asset) type="text/javascript"></script>
}

which may not be necessary, and added this to main.scala.html:

        @findScript(assets, "client-jsdeps.js", "client-jsdeps.min.js")

Without the above line, the js dependencies were not included.

For reference, the branch for the project I tested this with is here.

Sébastien Doeraene
@sjrd
The thing is that the jsDependencies mechanism is basically discontinued. We provide sbt-jsdependencies as a stop-gap measure when upgrading from Scala.js 0.6.x, but newer projects should use other mechanisms. When using Play!, directly using WebJars the Play! way is a good replacement.
fromscalatohaskell
@fromscalatohaskell_gitlab
Joe Koberg
@jkoberg
Can a JVM and ScalaJS subproject coexist in an sbt build? My initial efforts seem to fail... have sbt multi project, add scalajs plugin in root /project/scalajs.sbt file, attempt to enable plugin for one subproject
7 replies
Tobias Schlatter
@gzm0
@fromscalatohaskell_gitlab potentially. Devil is in the details though :)
Tobias Schlatter
@gzm0
@fromscalatohaskell_gitlab I have answered here: https://github.com/scala-js/scala-js/issues/3893#issuecomment-855384109
fromscalatohaskell
@fromscalatohaskell_gitlab
@gzm0 great, thanks! So what does it mean? We need to investigate?
silizza
@silizza
Hi!
Is there a way to scroll html element by coordinates? I don't see "scroll" or "scrollBy" method for elements.
1 reply
Ashkan Kh. Nazary
@ashkann

Hello everyone. Trying to do the simplest possible scala-js-bundle that I can think of. When I add an @JSExportTopLevel("addClickedMessage") to any method (even an empty method) then this error appears on the browser's console :

Main.scala:18 Uncaught ReferenceError: exports is not defined

Searched everywhere to no avail. Thanks.

Dave Smith
@davesmith00000
I'm not very familiar with scala-js-bundle but are you exporting as the right module type?
The docs don't imply you need to, having said that... 😬
Ashkan Kh. Nazary
@ashkann
Not sure I understand you :D (I'm very new to this all). But the code works flawlessly when compiled with fastLinkJS. However when compiling with fastOptJS:webpack the error happens.
The project is an absolute bare minimum and thus doesn't really use any module (no npmDependencies). I'm just adding the scala-js-bundle to an essentially empty project to see whether it will break things, which it did !
Dave Smith
@davesmith00000
I don't use the bundler plugin, but to use scala.js with parcel I have to emit as a common js module, or it doesn't work. 🙂
Dave Smith
@davesmith00000
@ashkann Hang on, I don't use fastLinkJS either (I'm out of date!) but fastOpJS results in a different filename, with -fastopt appended. Does fastLinkJS:webpack (one : or two ::?) work?
Plan B: Forget the bundler if you don't need it (you said)
Plan C: Bundle with something else, I use parcel: https://github.com/PurpleKingdomGames/tyrian/tree/main/examples/counter
Vu Duc Nhi
@vdnhi

Hi all,

I've followed the tutorial about module splitting on scala-js docs with the same App.scala and build.sbt on https://www.scala-js.org/doc/project/module.html#module-splitting but when I run fastLinkJS or fullLinkJS still met this error:

[error] Found multiple public modules but module support is disabled: [b, a]
[error]   exported to JavaScript with @JSExport
[error] There were linking errors
[error] (Compile / fastLinkJS) There were linking errors

I don't know how to fix this, I really appreciate if anyone can told me how to do right with module splitting. Thank you.
I am using scala 2.13.6 with sbt 1.5.3 and scalajs 1.5.1

Sébastien Doeraene
@sjrd
@vdnhi Did you configure the ModuleKind, as mentioned at the top of that doc page?
Like scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) } in the settings of your project?
Vu Duc Nhi
@vdnhi
@sjrd It's worked, thank you a lot.
nafg
@nafg
Seems @scala-steward jumped the gun again, as usual
Robert Walker
@olofwalker
Hi, does anyone know if there are any tutorials or examples on how to use a wasm package with ScalaJS?
Sébastien Doeraene
@sjrd

Hi, does anyone know if there are any tutorials or examples on how to use a wasm package with ScalaJS?

Presumably any existing tutorial to do so from JS would work, by replacing calls to the JS APIs by calls to Scala.js facade types for said APIs.

Shah Saraei
@ShahOdin

:wave: I am trying to create a function to construct a n instance of my type from an instance of a javascript class: I have added the relevant lib using ScalablyTyped so I have the facade version of the lib available to me, let's call it X. now X has a method returning A| B
where A and B are themselves facade types. Googling around, I was told to pattern match on it like this:

(facadeInstance.foo: Any) {
  case a: A => 
  case b: B => 
}

Compiler is taking issues with it saying:

isInstanceOf[A] not supported because it is a JS trait.

I still know close to nothing about union types in scalajs. does this mean that I basically can't do anything with the response I get from functions like foo?

Tobias Schlatter
@gzm0
It depends what A and B are: JS traits are mere interface definitions. An actual JS object doesn't know which traits it "implements".
So if you need to pattern match on the types, you need classes.
Hmmm... Reading through your question again: yes that seems very broken. If a facade returns a union type where at least on of the types is a trait, it's very hard to use (or impossible).
What facade are we talking about?
Maybe the concrete names of A / B help.
(one contrived case I could imagine is if A | B is always supposed to be passed forward to some other (JS) functions that take A | B. But at that point, one might as well define an opaque type...
Shah Saraei
@ShahOdin

ok great. So the facade is that of https://www.npmjs.com/package/@types/postman-collection generated using https://github.com/ScalablyTyped/Converter
the foos in question are:

  var url: String | Url = js.native
  //another example
  var body: js.UndefOr[RequestBody | RequestBodyDefinition] = js.native

which are from the facade:

package typings.postmanCollection.mod
@js.native
class Request protected () extends Property[RequestDefinition] {

https://www.postmanlabs.com/postman-collection/Request.html ^

is the fact that they are both var trying to tell us something? since I can see actual functions on that trait too, but they are returning js.Any

Øyvind Raddum Berg
@oyvindberg
@ShahOdin The unfortunate truth is that consuming union types in Scala.js will involve some casting. At least for Scala 2. I haven't had time to check it out properly yet, but I had the impression that Scala 3 will let you use whatever interface all the types in the union have in common.
Pattern matching will work in a few cases I think (classes, primitives), but for everything else you cast. What I normally do is I write the equivalent of a typescript type predicate in the form of an extractor, where the implementation typically casts to js.Dynamic and checks the shape of the object somehow
I've actually thought about letting ST generate extractors of some form, but it's hard to solve in the general case
August Nagro
@AugustNagro
Is anyone using Scala.js and Maven with Scala 3.0.0?
August Nagro
@AugustNagro
Just tried the two scala maven plugins I found on google, and they aren't working with Scala 3. I cloned both and couldn't mvn install either of them, lol. One has all it's dependencies in Bintray, the other one never finishes building for some reason, even with tests disabled.
Sébastien Doeraene
@sjrd
Scala.js 1.6.0 is released! With js.import.meta, js.WeakRef & js.FinalizationRegistry, and some bug fixes.
Carlos Quiroz
@cquiroz
👏👏
Carlos Quiroz
@cquiroz
Let’s see how we make good use of import.meta
Li Haoyi
@lihaoyi

@sjrd not sure if this is an intentional or unintentional pun, but I found it funny :P

Despite linking and successfully running, code using WeakReference et al. was therefore stubtly wrong.

Vu Duc Nhi
@vdnhi

Hi all,

I'am building app with scalajs-react with multiple routers, first for homepage to route to each specific page and in each individual page have a single router for inner section on that page. Then I want to split build each single page and lazy load when redirect from homepage. But I meet this error do fastLinkJS:

You may not export a getter or a setter to the top level

with my sample code in a single module

@JSExportTopLevel(name = "router", moduleID = "pageA")
def router: Router[PageA.Pages.Page] = Router(baseUrl, config)

Anyone have idea on how to achieve my purpose please help, thank you guys.

Sébastien Doeraene
@sjrd
@lihaoyi Hum no it's not intentional. In fact I don't get where there's a pun in that sentence. 🤔😅
@vdnhi Either declare it as val router, to export it as a variable (initialized when the module is loaded) or as def router() with () to export it as a function.
Here you're trying to define it as def router without (), but that would correspond to a JavaScript getter, which is not possible to export from a module.
Sébastien Doeraene
@sjrd
@lihaoyi Oh Nikita pointed out the pun on Twitter: https://twitter.com/raquo/status/1402775999037644803?s=19 😁
Vu Duc Nhi
@vdnhi

@sjrd Yah, thank you. But if I have each router function return a Router like that, how can I use it on router config of Homepage. Before separating them into modules, I configured my homepage router likes

 dynamicRouteCT("page-a" ~ hash.caseClass[PageA]) ~> render(PageA.router())

How can I do lazy load at this point?

Sébastien Doeraene
@sjrd
If you want lazy loading, it clearly should be a def router(), not a val router.