ochrons / scalajs-spa-tutorial

Tutorial for creating a simple Single Page Application in ScalaJS
Apache License 2.0
672 stars 229 forks source link

Avoid SBT macro recompilation issue #25

Open mlvn23 opened 9 years ago

mlvn23 commented 9 years ago

If you add a method in the API, you'll get an error like this:

Request path: spatutorial/shared/Api/getTodos Request path: spatutorial/shared/Api/getMessage Request path: spatutorial/shared/Api/motd Sending 4 Todo items [error] p.c.s.n.PlayDefaultUpstreamHandler - Cannot invoke the action scala.MatchError: Request(WrappedArray(spatutorial, shared, Api, getMessage),Map (what -> java.nio.HeapByteBuffer[pos=0 lim=3 cap=3])) (of class autowire.Core$Re quest)

SBT appears to have an issue in not incrementally compiling macros when its dependents change. So in this case, the Router is dependent on Api trait, and if that trait changes, all invocation to the Router needs to be recompiled. The original Router invocation was in Application, but Application will probably not change when you change the Api service. As a work-around, move it here because if you change the Api trait, you will need to change the ApiService implementation, so this entire file (including the router invocation) would have to be recompiled.

mlvn23 commented 9 years ago

This would fix #23