Chat: #scala-js on Discord.
This is the repository for Scala.js, the Scala to JavaScript compiler.
Scala.js is distributed under the Apache License Version 2.0.
Source for https://www.scala-js.org/
Chat: #scala-js on Discord.
This is the repository for Scala.js, the Scala to JavaScript compiler.
Scala.js is distributed under the Apache License Version 2.0.
It is not documented anywhere. I had to look at compiler code to see what it does (!).
I'm sorry if I missed the obvious but I when playing around with scala.js I didn't find a way to easily generate js code that can be executed with node right away, e.g. from a bash script or other situations where you would like to avoid starting a JVM. IMHO having that option would increase the attractiveness of scala.js. From playing around with scala.js, I got the impression that I can simply concatenate *-opt.js and *-launcher.js to achieve this goal but it would be nice if there were an options (which is documented in the docs) that would make sbt do this for me. I'm not talking about creating modules that can be loaded from js code via require
.
Regards
For the code:
"abcdefg".substring(3, 1)
It will throw exception when running with normal Scala:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(String.java:1937)
But will get a substring without any exception with scala.js:
bc
Shall we make them consistent?
Originated from scala-js/scala-js#834
They are now supported but they leak memory, see scala-js/scala-js#234
(ochrons suggested submitting this as an Issue, since the new site isn't integrated yet, so a direct PR isn't as straightforward for me.)
Please add the new jstree-facade to the listing: "Static types for the [jsTree jQuery widget]."
It is very hard to make PRs to scala-js-website because of ruby-related dependency hell. I suggest to move it to scala. Maybe something simple, like scalatext ( that is used for https://github.com/lihaoyi/hands-on-scala-js )
jsDependencies
to jQuery (sjrd/scala-js-jquery#7) and bump to 0.6, + make it use Scala.js 0.5.0
I'm trying out ScalaJS, and just made a little program that makes a simple Ajax request and tries to parse it with json4s. The code compiles fine, but the optimizer fails with the message below. json4s uses reflection via extract
. The claim on the ScalaJS is that it supports all of scala, so it seems this should be allowed. Is there something else I'm doing wrong? Perhaps the implicit DefaultFormats is somehow not compiled to Javascript?
[info] Fast optimizing /foo/target/scala-2.11/example-fastopt.js
[error] Referring to non-existent class Lorg_json4s_DefaultFormats$
import org.scalajs.dom.ext.Ajax
import scala.concurrent.Future
import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
import org.json4s.DefaultFormats
import org.json4s.native.JsonMethods.parse
object Pagerduty {
type Json = org.json4s.JsonAST.JValue
val token = "foo"
implicit val formats = DefaultFormats
def onCall: Future[EscalationPolicy] =
Ajax.get(
url = "https://foo.pagerduty.com/api/v1/escalation_policies/on_call"
) map (xhr => parse(xhr.responseText).extract[EscalationPolicy])
}
PS: ScalaJS is a nice project.
set scalaJSStage := FastOptStage
only works for run
and not test
, and that's not obvious. I'd guess more people use test
from the command line than use run
* . Took me a few minutes to figure it out, and I probably know this stuff better than anyone*
*Citation Needed
Some text could be added (in the "Cross-Building" page?) to describe how (and why) to export shared classes for JS usage.
I've spent some time searching for a solution before realizing it was already available in the form of the stubs library.
It could be a time saver for many people, IMHO.
It seems to be (very) unclear that the *.class
files produced by the Scala.js compiler are not to be run on the JVM. We need to properly document and explain this.
People ask this all the time. It probably does deserve a more prominent place.
http://stackoverflow.com/questions/26638171/how-do-i-create-options-objects-in-scala-js
hi,
my plugin.scala
addSbtPlugin("org.scala-lang.modules.scalajs" %% "scalajs-sbt-plugin" % "0.5.6")
addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.3")
I followed tutorial to step 6, sbt test works fine, but when run TutorialAppTest inside intellij, error occurs:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.jetbrains.plugins.scala.testingSupport.uTest.UTestRunner.runTestSuites(UTestRunner.java:187)
at org.jetbrains.plugins.scala.testingSupport.uTest.UTestRunner.main(UTestRunner.java:254)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
at org.scalajs.jquery.package$.<init>(package.scala:6)
at org.scalajs.jquery.package$.<clinit>(package.scala)
at scalajs.TutorialApp$.setupUI(TutorialApp.scala:22)
at scalajs.TutorialAppTest$.<init>(TutorialAppTest.scala:10)
at scalajs.TutorialAppTest$.<clinit>(TutorialAppTest.scala:13)
at scalajs.TutorialAppTest.tests(TutorialAppTest.scala)
... 11 more
From Gitter:
But where is the list of SJS wrappers in the new website?
That was one of the most useful parts in the last one
sjrd 12:17:
http://www.scala-js.org/community/libraries/
How did you search for it? Where were you expecting to see links to it that you did not find?
mkotsbak 12:18
A bit hidden. I looked at "community", but did not notice the menu on the right
What about a "LIBRARIES" top level menu?
sjrd 12:27
We could do that, yes.
ochrons 12:33
yea, the Community is a bit abstract, so Libraries top item would be good
although that then leaves the community part quite bare
mkotsbak 12:33
No, I don't think so. It contains what you expect to find there
libs was 0 clicks in old webiste, so it should not be more than 1 click in the new
Actually it is two as there are sections
Sections could be dropdown menu or filters
Due to the lack of reflection in Scala.js, not all Enum definitions work. We should document this.
A number of things have changed in 0.2 and 0.3, and the documentation is not up-to-date anymore. We need to make a complete pass on the Website before we release 0.3.
I'm lazy, but I've heard that's a good trait for a developer :-)
I was reading the docs of the new homepage and wanted to submit a pull request to correct some minor errors on a specific page. It would have been much easier if the page had an "Improve this doc" link right there on the page (like in the footer).
The Jekyll help (jekyll/jekyll-help#5) says:
If you're hosting the site on GitHub Pages, they inject the source repository into a variable called
site.github.repository_url which you can use in combination with page.path to wire up the URL on
github.com.
Example: <a href="{{site.github.repository_url}}/blob/gh-pages/{{page.path}}">Improve this doc</a>
java.lang.Integer, etc. do not have reference equality as on the JVM. We should document this.
Suggested outline:
Possible future additions:
See discussions at:
https://groups.google.com/d/msg/scala-js/rE1pQniDDlc/TyEW1puCPKQJ
Assemble a list which Scala libraries are published for Scala.js and where
See scala-js/scala-js#177. Supporting character sets (i.e. conversion from byte to char) is hard. Only implement if absolute need arises.
I am working on this on my fork.
Installed "pygments" locally.
Modified the theme to add CSS for syntax highlighting.
Starting to add SH tags to code examples.
I believe after https://github.com/scala-js/scala-js-website/blob/master/doc/calling-javascript.md#defining-javascript-interfaces-with-traits it would be beneficial to show extending a Javascript interface. That way users can easily see how to enrich their JavaScript APIs with minimal work. I have provided an example below. However, I am sure a more useful example can be provided.
trait Window extends js.Object {
def alert(message: String): Unit = js.native
}
object Window {
implicit class RichWindow(val self: Window) extends AnyVal {
def help: Unit = self.alert("help")
}
}
jsDependencies +=
ProvidedJS / "moment-recur/moment-recur.min.js"
When I
sbt publishLocal
Then open the jar file to look at it at
C:\Users\philip.ivy2\local\io.github.widok\scala-js-moment-recur_sjs0.6_2.11\0.1.0-SNAPSHOT\jars
it has
{"libDeps":[{"resourceName":"moment-with-locales.min.js"},{"resourceName":"moment-recur/moment-recur.min.js"}],"origin":{"configuration":"compile","moduleName":"root"}}
So I think the moment-recur/moment-recur.min.js is a problem because of the /
When I tried to import this with SBT it fails with an error message.
However, if I place the moment-recur.min.js in the resources directory NOT in a sub-directory then its fine and works.
Coming from scala-js/scala-js#706
Originated here: scala-js/scala-js#965
Name: MetaRx
URL: https://github.com/MetaStack-pl/MetaRx
Description: Reactive data structures for Scala and Scala.js
Dependency: "pl.metastack" %%% "metarx" % "0.1.3"
It would be nice to know what works without having to read the source code, and the list has grown relatively large by this point so it's hard to keep track in your head.
We could probably just regex through the stuff in https://github.com/scala-js/scala-js and gather a list of class
/def
s, which would make it trivial to keep the list up to date: just re-run the regex and regenerate the list each release.
What should we do with the internals section? Update & Move? Integrate elsewhere (sbt plugin's compile, run, link section)?
I'm unsure if this is using "outstanding" in the sense of "exceptionally good" or "not yet resolved", meaning I'm unsure if this means the features are included, or are planned but not yet implemented.
I thought it meant the latter, but then one of the linked pages suggested these features are already included, which would be outstanding!*
The remark:
"Troubleshooting: Should you experience errors with the PermGen size of the JVM at this point, you can increase it. Refer, for example, to this StackOverflow question."
should be reviewed. Since Java 8 the PermGen is removed.
/etc/sbt/sbtopts
should be read as ${sbt_home}/conf/sbtconfig.txt
.On my Windows machine I am using the Xmx JVM option, contents of ${sbt_home}/conf/sbtconfig.txt
is:
# Set the java args to high
-Xmx896M
-XX:ReservedCodeCacheSize=128m
# Set the extra SBT options
-Dsbt.log.format=true```
(With no PermGen options the the annoying "VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0" message will disappear.)
Add API doc for:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.