You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/internals/scalajs-0.6.x-eol.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,3 +18,5 @@ Please upgrade to Scala.js 1.x as soon as possible.
18
18
See [the release notes of Scala.js 1.0.0]({{ BASE_PATH }}/news/2020/02/25/announcing-scalajs-1.0.0/) for important migration information.
19
19
20
20
There are no plans to offer paid support for Scala.js 0.6.x.
21
+
22
+
The last version of this website with 0.6.x documentation is at [9799280](https://github.com/scala-js/scala-js-website/tree/9799280483e3a21bb519e624b7fdb16e6a6af9c9).
Copy file name to clipboardExpand all lines: doc/interoperability/export-to-javascript.md
-107Lines changed: 0 additions & 107 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,26 +55,6 @@ object HelloWorld {
55
55
56
56
exports the `HelloWorld` object in JavaScript.
57
57
58
-
**Pre 0.6.15 note**: Before Scala.js 0.6.15, objects were exported as 0-argument
59
-
functions using `@JSExport`, rather than directly with `@JSExportTopLevel`. This
60
-
is deprecated in 0.6.x, and not supported anymore in Scala.js 1.x.
61
-
62
-
### Exporting under a namespace (deprecated)
63
-
64
-
**Note:** Deprecated since Scala.js 0.6.26, and not supported anymore in Scala.js 1.x.
65
-
66
-
The export name can contain dots, in which case the exported object is namespaced in JavaScript.
67
-
For example,
68
-
69
-
{% highlight scala %}
70
-
@JSExportTopLevel("myapp.foo.MainObject")
71
-
object HelloWorld {
72
-
...
73
-
}
74
-
{% endhighlight %}
75
-
76
-
will be accessible in JavaScript using `myapp.foo.MainObject`.
77
-
78
58
## Exporting classes
79
59
80
60
The `@JSExportTopLevel` annotation can also be used to export Scala.js classes
@@ -99,10 +79,6 @@ will log the string `"Foo(3)"` to the console. This particular example works
99
79
because it calls `toString()`, which is always exported to JavaScript. Other
100
80
methods must be exported explicitly as shown in the next section.
101
81
102
-
**Pre 0.6.15 note**: Before Scala.js 0.6.15, classes were exported using
103
-
`@JSExport` instead of `@JSExportTopLevel`, with the same meaning. This is
104
-
deprecated in 0.6.x, and not supported anymore in Scala.js 1.x.
105
-
106
82
## Exports with modules
107
83
108
84
When [emitting a module for Scala.js code](../project/module.html), top-level exports are not sent to the JavaScript global scope.
@@ -202,49 +178,6 @@ gives:
202
178
Hint to recognize this error: the methods are named `$js$exported$meth$`
203
179
followed by the JavaScript export name.
204
180
205
-
### <aname="JSExportNamed"></a> Exporting for call with named parameters (deprecated)
206
-
207
-
**Note:** Since Scala.js 0.6.11, `@JSExportNamed` is deprecated, and is not supported anymore in Scala.js 1.x.
208
-
Refer to [the Scaladoc]({{ site.production_url }}/api/scalajs-library/0.6.18/#scala.scalajs.js.annotation.JSExportNamed) for migration tips.
209
-
210
-
It is customary in Scala to call methods with named parameters if this eases understanding of the code or if many arguments with default values are present:
211
-
212
-
{% highlight scala %}
213
-
def foo(x: Int = 1, y: Int = 2, z: Int = 3) = ???
214
-
215
-
foo(y = 3, x = 2)
216
-
{% endhighlight %}
217
-
218
-
A rough equivalent in JavaScript is to pass an object with the respective properties:
219
-
{% highlight javascript %}
220
-
foo({
221
-
y: 3,
222
-
x: 2
223
-
});
224
-
{% endhighlight %}
225
-
226
-
The `@JSExportNamed` annotation allows to export Scala methods for use in JavaScript with named parameters:
227
-
228
-
{% highlight scala %}
229
-
class A {
230
-
@JSExportNamed
231
-
def foo(x: Int, y: Int = 2, z: Int = 3) = ???
232
-
}
233
-
{% endhighlight %}
234
-
235
-
Note that default parameters are not required. `foo` can then be called like this:
236
-
{% highlight javascript %}
237
-
var a = // ...
238
-
a.foo({
239
-
y: 3,
240
-
x: 2
241
-
});
242
-
{% endhighlight %}
243
-
244
-
Not specifying `x` in this case will fail at runtime (since it does not have a default value).
245
-
246
-
Just like `@JSExport`, `@JSExportNamed` takes the name of the exported method as an optional argument.
247
-
248
181
## Exporting top-level methods
249
182
250
183
While an `@JSExport`ed method inside an `@JSExportTopLevel` object allows JavaScript code to call a "static" method,
@@ -401,43 +334,3 @@ class B(val a: Int) extends A {
401
334
def sum(x: Int, y: Int): Int = x + y
402
335
}
403
336
{% endhighlight %}
404
-
405
-
## Deprecated: Automatically exporting descendent objects or classes
406
-
407
-
**Pre 0.6.15 note**: Before Scala.js 0.6.15, this deprecated feature used to be
408
-
often used to "reflectively" instantiate classes and load objects. This use case
Copy file name to clipboardExpand all lines: doc/interoperability/facade-types.md
+2-16Lines changed: 2 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,12 +25,7 @@ There are also non-native JS traits (aka Scala.js-defined JS traits), documented
25
25
The latter have more restrictions, but can be *implemented* from Scala.js code.
26
26
Native JS traits as described here should only be used for interfaces that are exclusively implemented by the JavaScript library--not for interfaces/contracts meant to be implemented by the user of said library.
27
27
28
-
**Scala.js 0.6.x:** In Scala.js 0.6.x, unless using the `-P:scalajs:sjsDefinedByDefault` compiler option, the annotation `@js.native` is assumed by default, with a deprecation warning.
29
-
You might still find old code that does not yet use it to annotate native JS types.
30
-
31
28
In native JS types, all concrete definitions must have `= js.native` as body.
32
-
Any other body will be handled as if it were `= js.native`, and a warning will be emitted.
33
-
(In Scala.js 1.x, this is an error.)
34
29
35
30
Here is an example giving types to a small portion of the API of `Window`
36
31
objects in browsers.
@@ -179,10 +174,6 @@ class RegExp(pattern: String) extends js.Object {
179
174
}
180
175
{% endhighlight %}
181
176
182
-
**Pre 0.6.15 note**: Before Scala.js 0.6.15, the `@JSGlobal` annotation did not
183
-
exist, so you will find old code that does not yet use it to annotate native JS
184
-
classes.
185
-
186
177
The call `new RegExp("[ab]*")` will map to the obvious in JavaScript, i.e.,
187
178
`new RegExp("[ab]*")`, meaning that the identifier `RegExp` will be looked up
Prior to 0.6.13, `extends js.GlobalScope` was used instead of `@JSGlobalScope`.
292
-
`js.GlobalScope` is now deprecated.
293
-
294
-
**Scala.js 1.x:** Also read [access to the JavaScript global scope](./global-scope.html).
282
+
Also read [access to the JavaScript global scope](./global-scope.html).
295
283
296
284
## <aname="import"></a> Imports from other JavaScript modules
297
285
@@ -577,9 +565,7 @@ reflective call can therefore not be generated.
577
565
578
566
Sometimes, it is more convenient to manipulate JavaScript values in a dynamically typed way.
579
567
Although it is not recommended to do so for APIs that are used repetitively, Scala.js lets you call JavaScript in a dynamically typed fashion if you want to.
580
-
The basic entry point is to grab a dynamically typed reference to the global scope, with `js.Dynamic.global`, which is of type `js.Dynamic`.
581
-
582
-
**Scala.js 1.x:** In Scala.js 1.x, `js.Dynamic.global` is a [global scope object](./global-scope.html) instead of an actual value of type `js.Dynamic`.
568
+
The basic entry point is to grab a dynamically typed reference to the [global scope](./global-scope.html), with `js.Dynamic.global`, which is of type `js.Dynamic`.
583
569
584
570
You can read and write any field of a `js.Dynamic`, as well as call any method
585
571
with any number of arguments. All input types are assumed to be of type
A non-native JS type, aka Scala.js-defined JS type, is a JavaScript type implemented in Scala.js code.
7
7
This is in contrast to native JS types, described in [the facade types reference](./facade-types.html), which represent APIs implemented in JavaScript code.
8
8
9
-
## About `@ScalaJSDefined`
10
-
11
-
In Scala.js 0.6.x, the `@ScalaJSDefined` is necessary to declare a non-native JS type, also called a Scala.js-defined JS type.
12
-
Starting from Scala.js 1.x however, the annotation is not necessary anymore.
13
-
Since Scala.js 0.6.17, you can opt-in for the new semantics of 1.x where `@ScalaJSDefined` is not necessary, by giving the option `-P:scalajs:sjsDefinedByDefault` to scalac.
14
-
In an sbt build, this is done with
15
-
16
-
{% highlight scala %}
17
-
scalacOptions += "-P:scalajs:sjsDefinedByDefault"
18
-
{% endhighlight %}
19
-
20
-
The present documentation assumes that you are using this option (or Scala.js 1.x).
21
-
Code snippets mention the necessary `@ScalaJSDefined` in comments as a reference for older versions.
22
-
23
9
## Defining a non-native JS type
24
10
25
11
Any class, trait or object that inherits from `js.Any` is a JS type.
@@ -36,7 +22,7 @@ class Foo extends js.Object {
36
22
}
37
23
{% endhighlight %}
38
24
39
-
Such classes are called *non-native JS classes*, and are also known as Scala.js-defined JS classes (especially in 0.6.x).
25
+
Such classes are called *non-native JS classes*, and were previously known as Scala.js-defined JS classes.
40
26
All their members are automatically visible from JavaScript code.
41
27
The class itself (its constructor function) is not visible by default, but can be exported with `@JSExportTopLevel`.
42
28
Moreover, they can extend JavaScript classes (native or not), and, if exported, be extended by JavaScript classes.
@@ -324,8 +310,6 @@ val pos = new Position {
324
310
}
325
311
{% endhighlight %}
326
312
327
-
Note that anonymous classes extending `js.Any` are always non-native, even in 0.6.x without `-P:scalajs:sjsDefinedByDefault` nor `@ScalaJSDefined`.
328
-
329
313
#### Use case: configuration objects
330
314
331
315
For configuration objects that have fields with default values, concrete members with `= js.undefined` can be used in the trait.
Copy file name to clipboardExpand all lines: doc/project/building.md
-30Lines changed: 0 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,11 +37,6 @@ Just like in a JVM project, sbt will automatically detect the object with a `mai
37
37
Note that this will require that there is a *unique* such object or that the one to use be explicitly set with `mainClass in Compile := Some(<name>)`.
38
38
If you explicitly set `mainClass`, note that it needs to be set on a per-configuration basis (i.e. the part `in Compile` is essential, otherwise the setting will be ignored). For further information see the Stack Overflow entry ['How to set mainClass in ScalaJS build.sbt?'](http://stackoverflow.com/questions/34965072/how-to-set-mainclass-in-scalajs-build-sbt) (specific to Scala.js) and the Stack Overflow entry ['How to set main class in build?'](http://stackoverflow.com/questions/6467423/how-to-set-main-class-in-build) (not specific to Scala.js).
39
39
40
-
**Note for Scala.js 0.6.17 and earlier:** in Scala.js 0.6.17 and earlier, the main object was required to extend the special trait [`js.JSApp`]({{ site.production_url }}/api/scalajs-library/0.6.20/#scala.scalajs.js.JSApp).
41
-
Since 0.6.18, any object with a standard `main` method will be recognized.
42
-
`js.JSApp` is now deprecated.
43
-
See [the Scaladoc of `js.JSApp`]({{ site.production_url }}/api/scalajs-library/0.6.20/#scala.scalajs.js.JSApp) for migration tips.
44
-
45
40
## Produce JavaScript code
46
41
47
42
To produce JavaScript code from your Scala code, you need to call the linker:
@@ -66,19 +61,9 @@ You can run a Scala.js application (that has `scalaJSUseMainModuleInitializer` s
66
61
This will run the `main.js` file right inside of your sbt console.
67
62
By default, the file is run with [Node.js](https://nodejs.org/), which you need to install separately.
68
63
69
-
**Scala.js 0.6.x only:** If your application or one of its libraries requires a DOM (which can be specified with `jsDependencies += RuntimeDOM`), you will also need to install [`jsdom`](https://github.com/jsdom/jsdom) with `npm install jsdom`.
70
-
`jsDependencies += RuntimeDOM` is now deprecated, and should be replaced by `jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()`.
71
-
72
64
There are alternative JavaScript interpreters that are available.
73
65
See [JavaScript environments](./js-environments.html) for more details.
74
66
75
-
### Deprecated: Run without `scalaJSUseMainModuleInitializer`
76
-
77
-
**Scala.js 0.6.x only**
78
-
79
-
It is still possible to `run` a Scala.js application that does not have `scalaJSUseMainModuleInitializer := true`.
80
-
However, this is not recommended anymore.
81
-
82
67
## Disabling the optimizations
83
68
84
69
If, for some reason (for example, to make stepping through the code with a debugger more predictable), you want to disable the optimizations, you can do so with the following sbt setting:
@@ -106,18 +91,3 @@ You can run your code and tests in fullOpt stage with the following command:
106
91
107
92
**Note for Scala.js 1.2.x and earlier:** in Scala.js 1.2.x and earlier, we used `fullOptJS` instead of `fullLinkJS`, which always produces a single file with the suffix `-opt.js`.
108
93
`scalaJSStage` works the same way in Scala.js 1.2.x and in later versions.
109
-
110
-
## Deprecated: Writing Launcher Code
111
-
112
-
**Scala.js 0.6.x only**
113
-
114
-
For applications that do not use `scalaJSUseMainModuleInitializer := true`, it is possible to generate a small .js file that calls the `main` method, known as a "launcher" file.
115
-
This is done with the following sbt setting:
116
-
117
-
{% highlight scala %}
118
-
persistLauncher := true
119
-
{% endhighlight %}
120
-
121
-
The resulting file in the target folder will have the suffix `-launcher.js`.
122
-
123
-
This feature is deprecated: applications should migrate to using `scalaJSUseMainModuleInitializer`.
Copy file name to clipboardExpand all lines: doc/project/dependencies.md
-91Lines changed: 0 additions & 91 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,94 +20,3 @@ Note the `%%%` (instead of the usual `%%`) which will add the current Scala.js v
20
20
Some Scala.js core libraries (such as the Scala.js library itself) do not need the `%%%` since their version number *is* the Scala.js version number itself.
21
21
22
22
Note that you can also use `%%%` in a Scala/JVM project, in which case it will be the same as `%%`. This allows you to use the same `libraryDependencies` settings when cross compiling Scala/JVM and Scala.js.
23
-
24
-
## Deprecated: Depending on JavaScript libraries
25
-
26
-
The `jsDependencies` mechanism should be considered deprecated.
27
-
Use [scalajs-bundler](https://scalacenter.github.io/scalajs-bundler/) instead.
28
-
29
-
**Scala.js 1.x note:** since Scala.js 1.x, this functionality is not part of the core Scala.js sbt plugin.
30
-
Instead, it is provided by [sbt-jsdependencies](https://github.com/scala-js/jsdependencies).
31
-
32
-
The rest of this section applies to Scala.js 0.6.x only.
33
-
[Scala.js 0.6.x has reached End of Life.]({{ BASE_PATH }}/doc/internals/scalajs-0.6.x-eol.html)
34
-
35
-
Thanks to [WebJars](http://www.webjars.org/), you can easily fetch a JavaScript library like so:
This will fetch the required JAR containing jQuery. However, it will not include it once you run your JavaScript code, since there is no class-loading process for JavaScript.
42
-
43
-
The Scala.js sbt plugin has `jsDependencies` for this purpose. You can write:
This will make your project depend on the respective WebJar and include a file named `**/2.1.4/jquery.js` in the said WebJar when your project is run or tested. We are trying to make the semantics of "include" to be as close as possible to writing:
50
-
51
-
{% highlight html %}
52
-
<scripttype="text/javascript"src="..."></script>
53
-
{% endhighlight %}
54
-
55
-
All `jsDependencies` and associated metadata (e.g. for ordering) are persisted in a file (called `JS_DEPENDENCIES`) and shipped with the artifact your project publishes. For example, if you depend on the `scalajs-jquery` package for Scala.js, you do not need to explicitly depend or include `jquery.js`; this mechanism does it for you.
56
-
57
-
Note: This will **not** dump the JavaScript libraries in the file containing your compiled Scala.js code as this would not work across all JavaScript virtual machines. However, the Scala.js plugin can generate a separate file that contains all raw JavaScript dependencies (see [below](#packageJSDependencies)).
58
-
59
-
### Scoping to a Configuration
60
-
61
-
You may scope `jsDependencies` on a given configuration, just like for normal `libraryDependencies`:
Some (most?) JavaScript libraries try to adapt the best they can to the environment in which they are being executed.
70
-
When they do so, you have to specify explicitly the name under which they are exported in a CommonJS environment (such as Node.js), otherwise they won't work when executed in Node.js.
71
-
This is the purpose of the `commonJSName` directive, to be used like this:
when running with Node.js from sbt (with `run`, `test`, etc.).
84
-
85
-
### Dependency Ordering
86
-
87
-
Since JavaScript does not have a class loading mechanism, the order in which libraries are loaded may matter. If this is the case, you can specify a library's dependencies like so:
Note that the dependee must be declared as explicit dependency elsewhere, but not necessarily in this project (for example in a project the current project depends on).
94
-
95
-
### Local JavaScript Files
96
-
97
-
If you need to include JavaScript files which are provided in the resources of your project, use:
98
-
99
-
{% highlight scala %}
100
-
jsDependencies += ProvidedJS / "myJSLibrary.js"
101
-
{% endhighlight %}
102
-
103
-
This will look for `myJSLibrary.js` in the resources and include it. It is an error if it doesn't exist. You may use ordering and scoping if you need.
104
-
105
-
### <aname="packageJSDependencies"></a> Write a Dependency File
106
-
107
-
If you want all JavaScript dependencies to be concatenated to a single file (for easy inclusion into a HTML file for example), you can set:
108
-
109
-
{% highlight scala %}
110
-
skip in packageJSDependencies := false
111
-
{% endhighlight %}
112
-
113
-
in your project settings. The resulting file in the target folder will have the suffix `-jsdeps.js`.
0 commit comments