Skip to content

abstract case class breaks Scala.js sourcemaps? #14240

Closed
@armanbilge

Description

@armanbilge

(originally reported by @mn98 as a possible Cats Effect bug)

Compiler version

3.1.1-RC2

Minimized code

// build.sbt
scalaVersion := "3.1.1-RC2"
scalaJSUseMainModuleInitializer := true
enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin)

// project/plugins.sbt
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0")

// src/main/scala/Main.scala
object Main {
  def main(args: Array[String]): Unit = ExitCode(0)
}
abstract case class ExitCode private (code: Int)
object ExitCode {
  def apply(i: Int): ExitCode = new ExitCode(i & 0xff) {}
  val Success: ExitCode = ExitCode(0)
}

Output

sbt> Compile / fastOptJS / webpack
[info] compiling 1 Scala source to /workspace/http4s4tw/target/scala-3.1.1-RC2/classes ...
[info] Updating NPM dependencies
[info] Fast optimizing /workspace/http4s4tw/target/scala-3.1.1-RC2/http4s4tw-fastopt
[error] npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
[error] npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
[error] npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
[error] npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
[error] npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
[error] npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[info] added 603 packages, and audited 604 packages in 10s
[info] 20 packages are looking for funding
[info]   run `npm fund` for details
[info] 14 vulnerabilities (8 moderate, 6 high)
[info] To address issues that do not require attention, run:
[info]   npm audit fix
[info] To address all issues, run:
[info]   npm audit fix --force
[info] Run `npm audit` for details.
[info] Writing scalajs.webpack.config.js
[info] Bundling the application with its NPM dependencies
[error] /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-map-generator.js:298
[error]       throw new Error('Invalid mapping: ' + JSON.stringify({
[error]       ^
[error] Error: Invalid mapping: {"generated":{"line":969,"column":24},"source":"/workspace/http4s4tw/src/main/scala/Main.scala","original":{"line":4,"column":-1},"name":"toString"}
[error]     at SourceMapGenerator_validateMapping [as _validateMapping] (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-map-generator.js:298:13)
[error]     at SourceMapGenerator_addMapping [as addMapping] (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-map-generator.js:110:12)
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-node.js:351:13
[error]     at SourceNode_walk [as walk] (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-node.js:230:9)
[error]     at SourceNode_walk [as walk] (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-node.js:226:13)
[error]     at SourceNode_walk [as walk] (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-node.js:226:13)
[error]     at SourceNode_toStringWithSourceMap [as toStringWithSourceMap] (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/source-map/lib/source-node.js:342:8)
[error]     at ConcatSource.proto.sourceAndMap (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack-sources/lib/SourceAndMapMixin.js:29:32)
[error]     at CachedSource.sourceAndMap (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack-sources/lib/CachedSource.js:58:31)
[error]     at getTaskForFile (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/SourceMapDevToolPlugin.js:37:30)
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/SourceMapDevToolPlugin.js:136:20
[error]     at Array.forEach (<anonymous>)
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/SourceMapDevToolPlugin.js:130:12
[error]     at SyncHook.eval [as call] (eval at create (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
[error]     at SyncHook.lazyCompileHook (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/Hook.js:154:20)
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/Compilation.js:1319:42
[error]     at AsyncSeriesHook.eval [as callAsync] (eval at create (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
[error]     at AsyncSeriesHook.lazyCompileHook (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/Hook.js:154:20)
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/Compilation.js:1315:36
[error]     at AsyncSeriesHook.eval [as callAsync] (eval at create (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
[error]     at AsyncSeriesHook.lazyCompileHook (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/Hook.js:154:20)
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/Compilation.js:1311:32
[error]     at AsyncSeriesHook.eval [as callAsync] (eval at create (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
[error]     at AsyncSeriesHook.lazyCompileHook (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/Hook.js:154:20)
[error]     at Compilation.seal (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/Compilation.js:1248:27)
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/Compiler.js:625:18
[error]     at /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/Compilation.js:1171:4
[error]     at AsyncSeriesHook.eval [as callAsync] (eval at create (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
[error]     at AsyncSeriesHook.lazyCompileHook (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/tapable/lib/Hook.js:154:20)
[error]     at Compilation.finish (/workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/lib/Compilation.js:1163:28)
[error] Failure on parsing the output of webpack: No content to map due to end-of-input
[error]  at [Source: java.lang.ProcessImpl$ProcessPipeInputStream@3fa6bef7; line: 1, column: 0]
[error] You can try to manually execute the command
[error] node /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/node_modules/webpack/bin/webpack --bail --profile --json --config /workspace/http4s4tw/target/scala-3.1.1-RC2/scalajs-bundler/main/scalajs.webpack.config.js
[error] 
[error] stack trace is suppressed; run last Compile / fastOptJS for the full output
[error] (Compile / fastOptJS / webpack) Non-zero exit code: 1
[error] Total time: 12 s, completed Jan 10, 2022, 4:01:39 PM

Expectation

Switching to Scala 2.13.7 there is no error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions