sjrd on 0.6.x
Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)
sjrd on master
Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)
sjrd on master
Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)
Is it because two mains are merged in the same js ?
So to answer that: It's not that two mains are merged, it's that two linked JS files are merged in the same JS. If you are working with modules, you need to import the two JS files.
Hi! I am
fastLinkJS a class that uses
scala.util.parsing.input.Position and get the following errors:
[info] Fast optimizing /Users/ulugbekna/code/minicoq/minicoq/target/scala-3.0.0-RC3/minicoq-fastopt [info] Fast optimizing /Users/ulugbekna/code/minicoq/minicoq-js/target/scala-3.0.0-RC3/minicoq-js-fastopt [error] Referring to non-existent class scala.util.parsing.input.Position [error] called from private static minicoq.core.Interpreter.op$proxy1$2$$anonfun$1(minicoq.core.Term,minicoq.core.Term,minicoq.core.Term)java.lang.String [error] called from private minicoq.core.Interpreter.op$proxy1$1(minicoq.core.Stat)minicoq.core.Interpreter$Result [error] called from minicoq.core.Interpreter.interpret(minicoq.core.Stat)minicoq.core.Interpreter$Result [error] called from minicoq.core.Repl.interpret(java.lang.String)java.lang.String [error] called from minicoq.core.Repl.interpretRepl(java.lang.String)scala.util.Either [error] called from private minicoq.js.Webapp$.main$$anonfun$1(org.scalajs.dom.raw.HTMLDivElement,org.scalajs.dom.raw.HTMLInputElement,org.scalajs.dom.raw.KeyboardEvent)java.lang.Object [error] called from minicoq.js.Webapp$.main([java.lang.String)void [error] called from static minicoq.js.Webapp.main([java.lang.String)void [error] called from core module module initializers [error] involving instantiated classes: [error] minicoq.core.Repl [error] minicoq.js.Webapp$ [error] Referring to non-existent method scala.util.parsing.input.Position.longString()java.lang.String
(full error here)
minicoq.corethat is used by jvm REPL implementation and my js webapp. I want
minicoq.coreto be compatible with both jvm and js. Do you know how this could be achieved?
val dottyVersion = "3.0.0-RC3" lazy val minicoq = project .in(file("minicoq")) .enablePlugins(ScalaJSPlugin) .settings( name := "minicoq", version := "0.1.0", scalaVersion := dottyVersion, libraryDependencies += ("org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2") .withDottyCompat(scalaVersion.value), libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test, testFrameworks += new TestFramework("munit.Framework") ) lazy val minicoq_repl = project .in(file(".")) .aggregate(minicoq) .dependsOn(minicoq) .settings( name := "minicoq-repl", version := "0.1.0", scalaVersion := dottyVersion ) lazy val minicoq_js = project .in(file("minicoq-js")) .enablePlugins(ScalaJSPlugin) .aggregate(minicoq) .dependsOn(minicoq) .settings( name := "minicoq-js", version := "0.1.0", scalaVersion := dottyVersion, scalaJSUseMainModuleInitializer := true, libraryDependencies += ("org.scala-js" %%% "scalajs-dom_sjs1" % "1.1.0") .withCrossVersion(CrossVersion.for3Use2_13) )
that's where the issue is - you need to use
libraryDependencies += ("org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2")
%%%here for SJS to use this dependency (transitively)
no worries :)
Anton puts another notch next to the list of people tripped by
I think in the context of cross platform projects you can just use %%% everywhere in the build to avoid this confusion
libraryDependencies += ("org.scala-js" %%% "scalajs-dom_sjs1" % "1.1.0") .withCrossVersion(CrossVersion.for3Use2_13)at the end of my sbt file and
_sjs1suffix in the dep name. Somehow, sbt can't find this dependency without this suffix. Is this the expected behavior?
for3Use2_13? I have this library as a dependency in another project and it works without the suffix
sbt itself can compile to both jvm and js
crossproject helps generating those project - one can do it manually like you did, or with crossproject/projectmatrix plugins.
If you have a ton of cross-built projects, manual creation can become tedious quickly :)
[error] Referring to non-existent class java.io.FileNotFoundException [error] called from scala.io.Source$.fromResource(java.lang.String,j ava.lang.ClassLoader,scala.io.Codec)scala.io.BufferedSource
dang, that kind of hurts the feature right? For our app we're talking 2.4mb of uncompressed vs 7mb fullopt with no closure. I was really hoping to use this...
It is possible to mark an object annotated with
@JSImport as “used” or something, so it’s not pruned by the optimizer?
cross-fetch/polyfill so I can create WHATWG Fetch API response objects in unit tests for Cloudflare Workers. I can do something like
@js.native @JSImport("cross-fetch/polyfill", JSImport.Default) object FetchPolyfill extends js.Any // inside a test class val throwaway = FetchPolyfill
but that’s kind of inelegant, so I was hoping there’s a better solution.
(The stubs for the classes themselves are defined by
scalajs-dom so AFAICT there’s not an easy way to move the
@JSImport somewhere where it would more naturally be used.)
Ah no you're right. Emitting multiple modules is not supported by Closure either.
I don't mean to be overly critical, but what benefit does
dynamicImport have wrt to code size, worse than none? Looks like a very promising feature, one that really helps in the JS/TS world where lazy loading is a significant performance improvement.
Maybe I'm misunderstanding the performance/code size tradeoff here. Perhaps lazy loading helps on the performance front but status quo of large initial bundle size remains?