Scala.js 1.3.1 with scalajs-bundler breaks Circe
See original GitHub issueSee the following repository for full example: https://github.com/kamilkloch/x-monitor-webpack.git
sbt
project frontend
fastOptJS / webpack
Open frontend/index-dev.html
, show console.
With Scala.js 1.3.1 web console reads
{
"name" : "Bob"
}
io.circe.FailedCursor@1
Left(DecodingFailure(Attempt to decode value on failed cursor, List(DownField(name))))
With Scala.js 1.3.0 it works:
{
"name" : "Bob"
}
io.circe.cursor.ObjectCursor@1
Right(Bob)
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Announcing Scala.js 1.3.1
We are pleased to announce the release of Scala.js 1.3.1! ... as they contain a host of important information, including breaking changes.
Read more >scalacenter/scalajs-bundler - Gitter
I'm happy with the external JS libraries being bundled to one file and the ScalaJS output to another. It's just the source map...
Read more >Release Notes · Airframe - wvlet.github.io
This version upgrades Scala.js to 1.10.1, msgpack-core 0.9.3 (JDK17 support). AirSpec 22.7.0 fixes JUnit test report (test-repot.xml) output.
Read more >Scala.js (@scala_js) / Twitter
native vals and defs, as well as some bug fixes. If you're using scalajs-bundler, make sure to upgrade to v0.18.0.
Read more >scalajs-bundler - Scaladex
scalajs-bundler Gitter Build Status. Module bundler for Scala.js projects that use NPM packages. Uses npm and webpack under the hood.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found why it only surfaces in scalajs-bundler! The bundle produced by scalajs-bundler doesn’t have
at the top of the file! It has it at the beginning of the Scala.js code, but that comes after the code inserted by the bundler for the “module system”. This means that the whole script loses strict mode, including the Scala.js-related code. If I manually add the
'use strict';
at the top of the file produced by scalajs-bundler, then it also fixes the bug!That also explains why forcing
class
es fixes the issue, because the body of JavaScriptclass
es always executes in strict mode.It does not explain why Scala.js 1.5.0+ fixes the issue. Most likely, because for an arbitrary reason, we do not rely on having strict mode somewhere where we previously relied on it.
It does mean that the root issue is not in this repo, however, and that it can pop up again in the future, at any arbitrary time. We should fix it properly in scalajs-bundler.
Thinking about this some more, I think we should at lest leave this open and ideally dedicate some time minimizing this. Especially because: