Sender | Message | Time |
---|---|---|
16 Apr 2024 | ||
ex0ns | I have a question regarding scala.js and sbt, I have a module design that contains components and common UI helpers, it also contains a raw js file (in the resource directory), that is loaded using a JSImport inside one of the file.I'm using the module (which will be split out from the repository and published as a lib in the future) from another module called frontend however when running fastLinkJS and serving my frontend with vite, it fails to resolve the file.js coming from the design module.A solution I have found it adding fronted / Compile / unmanagedResources ++= (design / Compile / unamanedResources).value in my build and changing my import to @JSImport("../classes/file.js") which seems to be working, but feels pretty ugly (and I don't know how it will behave when the design module will not be a module but a dependency)Is there an easier way to perform that ? | 08:43:16 |
nikitaga | Relative import paths are resolved by the bundler (Vite or Webpack), not by Scala.js – and so, they are relative to the scala.js output directory, not to the Scala source file in which you do JSImport. So, with that in mind, you can use the correct relative path when JSImport-ing main.js, which I believe should work, or, if you use Vite, I made a plugin that lets you import a single file by glob pattern, e.g. you can say JSImport("@find/**/file.js) and it will find your file.js wherever it is: https://github.com/raquo/vite-plugin-glob-resolver | 08:49:54 |
nikitaga | * ex0ns Relative import paths are resolved by the bundler (Vite or Webpack), not by Scala.js – and so, they are relative to the scala.js output directory, not to the Scala source file in which you do JSImport. So, with that in mind, you can use the correct relative path when JSImport-ing main.js, which I believe should work, or, if you use Vite, I made a plugin that lets you import a single file by glob pattern, e.g. you can say JSImport("@find/**/file.js) and it will find your file.js wherever it is: https://github.com/raquo/vite-plugin-glob-resolver | 08:50:14 |
fel_mazo joined the room. | 08:51:31 | |
unicorny9205 joined the room. | 08:57:33 | |
mcall7651 joined the room. | 09:09:42 | |
mcall7651 | I wrote a Scala 3 project depending on this Java library math.geom2d:javaGeom 0.11.1 (https://search.maven.org/#artifactdetails|math.geom2d|javaGeom|0.11.1|jar) for performing geometric computations. I would like to compile my project for scala.js as well. How can I achieve this result? * It seems not possible to use the dependency as is in a Scala JS project, if I am not mistaken. Are there solutions to somehow convert it or wrap it? * Or should I refactor the whole project to depend on a different equivalent Scala library that can be used for Scala JS as well? In case, any suggestion for a replacement? | 09:09:43 |
mcall7651 changed their display name from _discord_1047877952077037599 to mcall7651. | 09:09:44 | |
mcall7651 | Asked the same question also here https://users.scala-lang.org/t/scala-js-and-java-geom-library/9930 | 09:10:10 |
_gzm0 | Are there solutions to somehow convert it or wrap it? Not that I know of. You'll need to replace it. No suggestions unfortunately 😕 | 09:11:36 |
mcall7651 | Thank you _gzm0 this is already a good pointer | 09:13:43 |
dexter.2305 changed their display name from dexter to dexter.2305. | 09:50:49 | |
ptrdom | You could try forking and converting the project of the dependency to Scala. Just at a quick glance at Java geom sources it seems like its core depends on parts of Java that are compatible with Scala and Scala.js. Might be worth it if this library is critical for you and a good deed for the community too 😃 | 10:54:23 |
Lorenzo Gabriele (lolgab) | Maybe compile it to js wihh TeaVM and then call it as if it was a javascript library? Could such a frankestain work? | 11:05:57 |
Lorenzo Gabriele (lolgab) | * Maybe compile it to js with TeaVM and then call it as if it was a javascript library? Could such a frankestain work? | 11:06:12 |
Lorenzo Gabriele (lolgab) | Forking and converting to Scala seems a much cleaner and sane option, though, you can get help from Imtellij, since it can transpile java to Scala | 11:07:23 |
ekrich | ptrdom I did this file by file on this project - https://github.com/ekrich/sconfig It is quite a bit of work but if you have any questions let me know. | 16:24:09 |
jjmalina set a profile picture. | 18:44:06 | |
alexa1234 joined the room. | 19:46:13 | |
damianreeves | Curious if anyone has an example of using ScalaJS with Bun? | 20:49:50 |
17 Apr 2024 | ||
kawaxte changed their profile picture. | 00:58:59 | |
_pleb_ joined the room. | 09:33:04 | |
pismice joined the room. | 15:42:00 | |
18 Apr 2024 | ||
oclok_ joined the room. | 03:11:10 | |
loafingb changed their display name from LoafingB to loafingb. | 10:30:10 | |
3sant joined the room. | 16:44:59 | |
19 Apr 2024 | ||
arturaz | Anyone using ViteJS and knows what's up? I have a directory structure like this:
I launch vite from the /client/vite folder.Now the weird part is that if I edit .scala files in /client/src/ Vite picks it up and reloads the page, even if no JS was actually changed.For example:
Why is it doing that and how can I make it not care about the .scala files? 🙂 | 04:40:47 |
jysh_ joined the room. | 05:22:24 | |
sherpal | Maybe you can use the server.watch options? https://vitejs.dev/config/server-options.html#server-watch | 07:45:52 |
arturaz | Yup, vite.config.js with this content helped: | 08:34:49 |