question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Restart scala.js runtime environment

See original GitHub issue

We build all our scala.js apps with cats-effect 3 starting with IOApp which is exported to the js runtime. e.g. https://github.com/gemini-hlsw/explore/blob/fef6caaafdafa144b6a9ae04afad18990467e132/explore/src/main/scala/explore/Explore.scala#L61

This works fine for the regular browser case and node but has some restrictions when doing development on browser. There we often want to use HMR (Hot module replacement) where the dev environent detects changes to the compiled scala.js output and reloads the js code without a browser reload.

In practice this means we call IOApp.main again, however the code below can only be ever called once. https://github.com/typelevel/cats-effect/blob/series/3.x/core/js/src/main/scala/cats/effect/IOApp.scala#L33

Would it be possible to add a method that could be called on replacement to reset the environment such that another call to IOApp.main wouldn’t fail?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cquirozcommented, May 24, 2021

I wouldn’t expect to call it from java on my use case of HMR. And it would need to be a kind of end-of-the-world call returning Unit to be exported easily to js

0reactions
djspiewakcommented, Jul 12, 2021

I think this is sufficiently addressed as of #2114. If you disagree, leave a comment and I’ll reopen!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basic tutorial - Scala.js
This is a step-by-step tutorial where we start with the setup of a Scala.js sbt project and end up having some user interaction...
Read more >
Hands-on Scala.js - Haoyi's Programming Blog
js is a compiler that compiles Scala source code to equivalent Javascript code. That lets you write Scala code that you can run...
Read more >
Minimal Runtime · Issue #4 · scala-js/scala-js - GitHub
I'd like to write small classes in pure, no-dependencies Scala and have them compiled to a reasonably small amount of pure, no- or...
Read more >
Getting Started with Scala.js and Vite | Let´s talk about Scala 3
In this video, Sébastien Doeraene shows how to get started with Scala. js, sbt, and Vite. We wire them together for a fast...
Read more >
scala-js/scala-js - Gitter
After restarting sbt (as it kept returning the old error), a new error has appeared: "[error] ... Java(TM) SE Runtime Environment (build 1.8.0_144-b01)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found