scalacenter / scalajs-bundler

https://scalacenter.github.io/scalajs-bundler
Other
237 stars 101 forks source link

Running ScalaTest with fullOpt crashes #120

Open fdietze opened 7 years ago

fdietze commented 7 years ago

I set up a minimal project (https://github.com/woost/wust2/tree/scalajs-bundler-test-fullopt-bug):

git clone https://github.com/woost/wust2 -b scalajs-bundler-test-fullopt-bug --depth=1
cd wust2
./reproduce.sh

This project uses scala-js, scalajs-bundler and ScalaTest. It contains a simple test: assert(true) which runs well in fastOpt mode and without bundler (fastOpt and fullOpt). But when setting set scalaJSStage in Global := FullOptStage and running tests with bundler enabled, it crashes with the following error message:

[info] Updating NPM dependencies
[info] /tmp/tmp.OjHaOBVdSx/wust2/target/scala-2.11/scalajs-bundler/test
[info] ├── concat-with-sourcemaps@1.0.4 
[info] ├── source-map-loader@0.1.5 
[info] └── webpack@1.14.0 
[info] 
[error] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
[error] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
[error] npm WARN test No description
[error] npm WARN test No repository field.
[error] npm WARN test No license field.
[info] Full optimizing /tmp/tmp.OjHaOBVdSx/wust2/target/scala-2.11/scalajs-bundler/test/wust-test-opt.js
[info] Fast optimizing /tmp/tmp.OjHaOBVdSx/wust2/target/scala-2.11/scalajs-bundler/test/wust-test-fastopt.js
[info] Closure: 0 error(s), 0 warning(s)
[error] /tmp/tmp.OjHaOBVdSx/wust2/target/scala-2.11/scalajs-bundler/test/wust-test-opt.js:2
[error] var d,aa="object"===typeof __ScalaJSEnv&&__ScalaJSEnv?__ScalaJSEnv:{},m="object"===typeof aa.global&&aa.global?aa.global:"object"===typeof global&&global&&global.Object===Object?global:this;aa.global=m;var p=exports;aa.exportsNamespace=p;m.Object.freeze(aa);var ba={envInfo:aa,semantics:{asInstanceOfs:2,arrayIndexOutOfBounds:2,moduleInit:2,strictFloats:!1,productionMode:!0},assumingES6:!1,linkerVersion:"0.6.15"};m.Object.freeze(ba);m.Object.freeze(ba.semantics);
[error]                                                                                                                                                                                                        ^
[error] 
[error] TypeError: Cannot assign to read only property 'global' of object '#<Object>'
[error]     at Object.<anonymous> (/tmp/tmp.OjHaOBVdSx/wust2/target/scala-2.11/scalajs-bundler/test/wust-test-opt.js:2:200)
[error]     at Object.<anonymous> (/tmp/tmp.OjHaOBVdSx/wust2/target/scala-2.11/scalajs-bundler/test/wust-test-opt.js:1299:4)
[error]     at Module._compile (module.js:570:32)
[error]     at Object.Module._extensions..js (module.js:579:10)
[error]     at Module.load (module.js:487:32)
[error]     at tryModuleLoad (module.js:446:12)
[error]     at Function.Module._load (module.js:438:3)
[error]     at Module.require (module.js:497:17)
[error]     at require (internal/module.js:20:19)
[error]     at [stdin]:65:10
org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js exited with code 1
    at org.scalajs.jsenv.ExternalJSEnv$AbstractExtRunner.waitForVM(ExternalJSEnv.scala:107)
    at org.scalajs.jsenv.ExternalJSEnv$ExtRunner.run(ExternalJSEnv.scala:156)
    at org.scalajs.sbtplugin.FrameworkDetector.detect(FrameworkDetector.scala:71)
    at scalajsbundler.sbtplugin.ScalaJSBundlerPlugin$$anonfun$testSettings$4.apply(ScalaJSBundlerPlugin.scala:657)
    at scalajsbundler.sbtplugin.ScalaJSBundlerPlugin$$anonfun$testSettings$4.apply(ScalaJSBundlerPlugin.scala:589)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
julienrf commented 7 years ago

That might be the same problem as we are hitting in #90.