Giter Site home page Giter Site logo

scala-js's Introduction

Scala.js, a Scala to JavaScript compiler

Scala.js compiles Scala code to JavaScript, allowing you to write your Web application entirely in Scala!

Noteworthy features are:

  • Support all of Scala (including macros!), modulo a few semantic differences
  • Very good interoperability with JavaScript code. For example, use jQuery and HTML5 from your Scala.js code, either in a typed or untyped way. Or create Scala.js objects and call their methods from JavaScript.
  • Integrated with sbt (including support for dependency management and incremental compilation)
  • Can be used with your favorite IDE for Scala
  • Generates Source Maps for a smooth debugging experience (step through your Scala code from within your browser supporting source maps)
  • Integrates Google Closure Compiler for producing minimal code for production.

Resources

Get started

We provide a bootstrapping application which you can fork to kick off your own project. Its readme provides further explanations on how to do so.

Contribute

Compile

Scala.js uses sbt for its build process. To compile your fork, simply run:

sbt> package

By default the sbt environment uses Scala 2.10.2. You can switch to any of the supported versions with, e.g.,

sbt> ++2.11.0-M7

Run the test suite

Compile and run the Scala.js-specific test suite with

sbt> scalajs-test/test

(you must have run package before running the test suite)

To run the Scala test suite (aka partest), you have to use a 2.11 version, e.g., 2.11.0-M7, and run:

sbt> scalajs-partest-suite/test

Beware, this takes a very long time.

A complete test session from scratch on 2.11.0-M7 would then be

sbt> ++2.11.0-M7
sbt> package
sbt> scalajs-test/test
sbt> scalajs-partest-suite/test

Test the examples

After having compiled Scala.js, you can compile the example applications with:

sbt> examples/optimizeJS

(you must have run package before compiling the examples)

Then, you can "execute" them by opening their respective HTML files in your favorite browser. Since optimizing the JavaScript takes time (tens of seconds to several minutes, depending on your hardware), it is also possible not to optimize JS by doing instead:

sbt> examples/packageJS

In this case, you have to open the -dev version of the HTML files.

Currently, two examples are provided:

  • examples/helloworld/helloworld.html, saying Hello World in four different ways (using DOM or jQuery, and using the untyped or typed interface to JavaScript).
  • examples/reversi/reversi.html, an implementation of a Reversi game. Note that it uses the HTML5 Canvas element, so it won't work with Internet Explorer 8 or below.

Use your fork with your own projects

Simply publish it locally with:

sbt> publishLocal
sbt> scalajs-sbt-plugin/publishLocal

License

Scala.js is distributed under the Scala License.

scala-js's People

Contributors

alistair-johnson avatar chrisvariety avatar dylanarnold avatar eecolor avatar gzm0 avatar halfninja avatar jonas avatar kastigar avatar lihaoyi avatar olivierblanvillain avatar peluko avatar pkolaczk avatar siriux avatar sjrd avatar techaddict avatar vmunier avatar xblaster avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.