Oleg
Oleg

Reputation: 941

Scaja.js browser support

Scala.js compiles Scala code to Javascript. It's clear to me.

But I can't find any info, what Javascript it is. Is it ES 5.5, or maybe ES 2015 or later? Does it polyfills modern methods, or transpiles it into old methods, like babel do?

Is threre anywhere scala.js browser compatibility table?


Sorry for my English. It's not my native.

Upvotes: 4

Views: 215

Answers (1)

sjrd
sjrd

Reputation: 22095

Scala.js compiles to ECMAScript 5.1 strict mode by default (but strict mode support is not required per se). You can refer to the Kangax ES 5 compatibility table for an accurate view of where Scala.js will run. In practice, this is basically supported by all browsers, including very old ones.

You can also configure Scala.js to emit code that requires ECMAScript 2015, with the following sbt setting:

import org.scalajs.core.tools.linker.standard._

scalaJSLinkerConfig ~= { _.withOutputMode(OutputMode.ECMAScript2015) }

In any case, Scala.js does not polyfill anything in a way that would be visible to external JavaScript code on the same web page. It does internally use a few fallback implementations for some ES features when they are not present, e.g., Math.imul when targeting ES 5.1.

Upvotes: 4

Related Questions