We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
js.dynamicImport
Any, tested fom 3.0.0 to 3.2.1-RC1-bin-20220717-5c43324-NIGHTLY. Behaviour does not occur on 2.13.8.
3.0.0
3.2.1-RC1-bin-20220717-5c43324-NIGHTLY
import scala.scalajs.js object Main { def main(args: Array[String]): Unit = { // Message is dynamically imported and results in a `import(...) call in JS` js.dynamicImport { println(new Message().msg) } } } class Message { def msg = "Hello world dynamic import" }
Needs some linker config settings to support ES modules. Repro here in a sbt project: https://github.com/hugo-vrijswijk/scala-js-dynamic-import-scala3-bug
[info] Running Main. <ref *1> $c_jl_Error [java.lang.Error]: stub at $c_LMain$.main__AT__V (file:///project/target/scala-3.2.1-RC1-bin-20220717-5c43324-NIGHTLY/hello-world-fastopt/main.mjs:818:27) at $s_LMain__main__AT__V (file:///project/target/scala-3.2.1-RC1-bin-20220717-5c43324-NIGHTLY/hello-world-fastopt/main.mjs:804:15) at file:///project/target/scala-3.2.1-RC1-bin-20220717-5c43324-NIGHTLY/hello-world-fastopt/main.mjs:1744:1 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:385:24) at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15) { jl_Throwable__f_s: 'stub', jl_Throwable__f_e: null, jl_Throwable__f_enableSuppression: true, jl_Throwable__f_writableStackTrace: true, jl_Throwable__f_stackTraceStateInternal: [Circular *1], jl_Throwable__f_stackTrace: null, jl_Throwable__f_suppressed: null }
Scala.JS on Scala 3 emits the line:
throw $ct_jl_Error__T__(new $c_jl_Error(), "stub")
throw new $c_jl_Error("stub")
On 2.13.8 the import is emitted as expected.
Code runs without error and prints the expected message to the console. sbt ++2.13.x run works as expected, while sbt run gives the error above
sbt ++2.13.x run
sbt run
The text was updated successfully, but these errors were encountered:
Yeah, I don't think we've implemented js.dynamicImport in Scala 3 yet. 😳
Sorry, something went wrong.
Fix scala#15701: Implement js.dynamicImport for dynamic module loading.
3c9c5ba
Forward port of the compiler changes in scala-js/scala-js@a640f15
2c260e0
Merge pull request #15720 from dotty-staging/sjs-dynamic-import
837b1cc
Fix #15701: Implement js.dynamicImport for dynamic module loading.
sjrd
No branches or pull requests
Compiler version
Any, tested fom
3.0.0
to3.2.1-RC1-bin-20220717-5c43324-NIGHTLY
. Behaviour does not occur on 2.13.8.Minimized code
Needs some linker config settings to support ES modules. Repro here in a sbt project: https://github.com/hugo-vrijswijk/scala-js-dynamic-import-scala3-bug
Output
Scala.JS on Scala 3 emits the line:
throw $ct_jl_Error__T__(new $c_jl_Error(), "stub")
throw new $c_jl_Error("stub")
On 2.13.8 the import is emitted as expected.
Expectation
Code runs without error and prints the expected message to the console.
sbt ++2.13.x run
works as expected, whilesbt run
gives the error aboveThe text was updated successfully, but these errors were encountered: