final class ESFeatures extends AnyRef
ECMAScript features to use when linking to JavaScript.
The options in ESFeatures
specify what features of modern versions of
JavaScript are used by the Scala.js linker.
- Options whose name is of the form
useX
*force* the linker to use the corresponding features, guaranteeing that the specific semantics that they provide will be used. - Options whose name is of the form
allowX
*allow* the linker to use the corresponding features if it supports them. Support for such options can be dropped in any subsequent version of the linker, including patch versions. - Options whose name is of the form
avoidX
*hint* at the linker to avoid the corresponding features *when it does not affect observable semantics*. They are related to optimizations (for performance or code size). The linker is free to ignore those options. - The
esVersion
setting does not follow any of the schemes above. It is both a hint not to include support for old versions of ECMAScript, and a command to enable library or language features that rely on recent versions of ECMAScript.
As of Scala.js 1.6.0, the setting useECMAScriptSemantics2015
is derived
from esVersion
. In the future, it might become independently
configurable.
- Alphabetic
- By Inheritance
- ESFeatures
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
val
allowBigIntsForLongs: Boolean
EXPERIMENTAL: Primitive
Long
s *may* be compiled as primitive JavaScriptbigint
s.EXPERIMENTAL: Primitive
Long
s *may* be compiled as primitive JavaScriptbigint
s.Default:
false
Future versions of Scala.js may decide to ignore this setting.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
val
avoidClasses: Boolean
Avoid
class
'es when usingfunction
s andprototype
s has the same observable semantics.Avoid
class
'es when usingfunction
s andprototype
s has the same observable semantics.Default:
true
SpiderMonkey is known to exhibit terrible performance with JavaScript
class
'es, with up to an order of magnitude of performance degradation.Setting this option to
true
provides a hint to the Scala.js linker to avoid usingclass
'es when using other JavaScript features (typicallyfunction
s andprototype
s) has the same observable semantics, in order to improve expected performance. Setting it tofalse
provides a hint not to avoidclass
'es. Either way, the linker is free to ignore this option.Avoiding
class
'es has a negative impact on code size. If the code is only targeted at engines that are known to have good performance withclass
'es, it is desirable to set this option tofalse
. If the code is targeted at browsers (among others), it is recommended to set it totrue
.This option never affects the code emitted for JavaScript classes (classes extending
js.Any
), since that would have an impact on observable semantics.This option is always ignored when
esVersion < ESVersion.ES2015
. -
val
avoidLetsAndConsts: Boolean
Avoid
let
s andconst
s when usingvar
s has the same observable semantics.Avoid
let
s andconst
s when usingvar
s has the same observable semantics.Default:
true
Due to their semantics in JavaScript (their Temporal Dead Zone, TDZ),
let
s andconst
s are more difficult for engines to optimize thanvar
s. There have been known cases of dramatic performance issues with them, such as the Webkit issue https://bugs.webkit.org/show_bug.cgi?id=199866.Setting this option to
true
provides a hint to the Scala.js linker to avoid using them when using avar
has the same observable semantics, in order to improve expected performance. Setting it tofalse
provides a hint not to avoidlet
s andconst
s. Either way, the linker is free to ignore this option.Using
let
s andconst
s has benefits for humans writing code as they help readability and debugging, but there is little to no benefit in using them when the code is compiler-generated.This option is always ignored when
esVersion < ESVersion.ES2015
. -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(that: Any): Boolean
- Definition Classes
- ESFeatures → AnyRef → Any
-
val
esVersion: ESVersion
The ECMAScript version that is assumed to be supported by the runtime.
The ECMAScript version that is assumed to be supported by the runtime.
Default:
ESVersion.ES2015
The linker and the libraries may use this value to:
- provide more features that rely on recent ECMAScript language features, and/or
- dead-code-eliminate away polyfills.
Prefer reading this value over
useECMAScript2015Semantics
to perform feature tests. -
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- ESFeatures → AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- ESFeatures → AnyRef → Any
-
val
useECMAScript2015Semantics: Boolean
Use the ECMAScript 2015 semantics of Scala.js language features.
Use the ECMAScript 2015 semantics of Scala.js language features.
Default:
true
As of Scala.js 1.6.0, this is
true
if and only ifesVersion >= ESVersion.ES2015
. In the future, it might become independently configurable.When
true
, the following behaviors are guaranteed:- JavaScript classes are true
class
'es, therefore a) they can extend native JavaScriptclass
'es and b) they inherit static members from their parent class. - Lambdas for
js.Function
s that are not alsojs.ThisFunction
s are JavaScript arrow functions (=>
). Lambdas forjs.ThisFunction
s arefunction
functions. - Throwable classes are proper JavaScript error classes, recognized as such by debuggers (only with the JavaScript backend; not in Wasm).
- In Script (
NoModule
) mode, top-level exports are defined aslet
s.
When
false
, the following behaviors apply instead:- All classes defined in Scala.js are
function
s instead ofclass
'es. Non-native JS classes cannot extend native JSclass
'es and they do not inherit static members from their parent class. - All lambdas for
js.Function
s arefunction
s. - Throwable classes have JavaScript's
Error.prototype
in their prototype chain, but they are not considered proper error classes. - In Script (
NoModule
) mode, top-level exports are defined asvar
s.
Prefer reading this value instead of
esVersion
to determine which semantics apply. Doing so will be future-proof if and when this setting becomes configurable independently fromesVersion
. - JavaScript classes are true
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- def withAllowBigIntsForLongs(allowBigIntsForLongs: Boolean): ESFeatures
- def withAvoidClasses(avoidClasses: Boolean): ESFeatures
- def withAvoidLetsAndConsts(avoidLetsAndConsts: Boolean): ESFeatures
- def withESVersion(esVersion: ESVersion): ESFeatures
Deprecated Value Members
-
val
useECMAScript2015: Boolean
Use ECMAScript 2015 features.
Use ECMAScript 2015 features.
Prefer reading
esVersion
oruseECMAScript2015Semantics
instead, depending on the use case.This is always equal to
useECMAScript2015Semantics
.- Annotations
- @deprecated
- Deprecated
(Since version 1.6.0) use esVersion or useECMAScript2015Semantics instead
-
def
withUseECMAScript2015(useECMAScript2015: Boolean): ESFeatures
Specifies whether the linker should use ECMAScript 2015 features.
Specifies whether the linker should use ECMAScript 2015 features.
If
false
, this method sets theesVersion
toESVersion.ES5_1
. Otherwise, ifesVersion
was belowES2015
, it sets it toES2015
. Otherwise, it returns the same configuration ofESFeatures
.- Annotations
- @deprecated
- Deprecated
(Since version 1.6.0) use withESVersion(ESVersion.ES5_1) or withESVersion(ESVersion.ES2015) instead