@@ -74,7 +74,7 @@ As you expect, this will simply print "HelloWorld" when run. To run this, simply
74
74
$ sbt
75
75
sbt:Scala.js Tutorial> run
76
76
[info] Compiling 1 Scala source to (...)/scalajs-tutorial/target/scala-2.13/classes ...
77
- [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt.js
77
+ [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt
78
78
[info] Running tutorial.webapp.TutorialApp. Hit any key to interrupt.
79
79
Hello world!
80
80
[success] (...)
@@ -95,13 +95,13 @@ Now that we have a simple JavaScript application, we would like to use it in an
95
95
96
96
### Generate JavaScript
97
97
98
- To generate a single JavaScript file using sbt, just use the ` fastOptJS ` task:
98
+ To generate JavaScript using sbt, use the ` fastLinkJS ` task:
99
99
100
- > fastOptJS
101
- [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt.js
100
+ > fastLinkJS
101
+ [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt
102
102
[success] (...)
103
103
104
- This will perform some fast optimizations and generate the ` target/scala-2.13/scala-js-tutorial-fastopt.js ` file containing the JavaScript code.
104
+ This will perform some fast optimizations and generate the ` target/scala-2.13/scala-js-tutorial-fastopt/main .js ` file containing the JavaScript code.
105
105
106
106
(It is possible that the ` [info] ` does not appear, if you have just run the program and not made any change to it.)
107
107
@@ -118,7 +118,7 @@ To load and launch the created JavaScript, you will need an HTML file. Create th
118
118
</head >
119
119
<body >
120
120
<!-- Include Scala.js compiled code -->
121
- <script type="text/javascript" src="./target/scala-2.13/scala-js-tutorial-fastopt.js"></script>
121
+ <script type="text/javascript" src="./target/scala-2.13/scala-js-tutorial-fastopt/main .js"></script>
122
122
</body >
123
123
</html >
124
124
{% endhighlight %}
@@ -192,20 +192,20 @@ def main(args: Array[String]): Unit = {
192
192
193
193
To rebuild the JavaScript, simply invoke ` fastOptJS ` again:
194
194
195
- sbt:Scala.js Tutorial> fastOptJS
195
+ sbt:Scala.js Tutorial> fastLinkJS
196
196
[info] Compiling 1 Scala source to (...)/scalajs-tutorial/target/scala-2.13/classes ...
197
- [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt.js
197
+ [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt
198
198
[success] (...)
199
199
200
200
As you can see from the log, sbt automatically detects that the sources must be recompiled before fast optimizing.
201
201
202
202
You can now reload the HTML in your browser and you should see a nice "Hello World" message.
203
203
204
- Re-typing ` fastOptJS ` each time you change your source file is cumbersome. Luckily sbt is able to watch your files and recompile as needed:
204
+ Re-typing ` fastLinkJS ` each time you change your source file is cumbersome. Luckily sbt is able to watch your files and recompile as needed:
205
205
206
- sbt:Scala.js Tutorial> ~fastOptJS
206
+ sbt:Scala.js Tutorial> ~fastLinkJS
207
207
[success] (...)
208
- [info] 1. Monitoring source files for scalajs-tutorial/fastOptJS ...
208
+ [info] 1. Monitoring source files for scalajs-tutorial/fastLinkJS ...
209
209
[info] Press <enter> to interrupt or '?' for more options.
210
210
211
211
From this point in the tutorial we assume you have an sbt with this command running, so we don't need to bother with rebuilding each time.
@@ -307,7 +307,7 @@ issue. Remember the task `run`? If you try to invoke it now, you will see someth
307
307
308
308
sbt:Scala.js Tutorial> run
309
309
[info] Running tutorial.webapp.TutorialApp. Hit any key to interrupt.
310
- (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt.js:819
310
+ (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-fastopt/main .js:819
311
311
$thiz.Lorg_scalajs_dom_package$__f_window = window;
312
312
^
313
313
@@ -398,7 +398,7 @@ To run this test, simply invoke the `test` task:
398
398
399
399
> test
400
400
[info] Compiling 1 Scala source to (...)/scalajs-tutorial/target/scala-2.13/test-classes...
401
- [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-test-fastopt.js
401
+ [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-test-fastopt
402
402
-------------------------------- Running Tests --------------------------------
403
403
+ tutorial.webapp.TutorialTest.HelloWorld 2ms
404
404
Tests: 1, Passed: 1, Failed: 0
@@ -435,7 +435,7 @@ You can now call the `test` task again:
435
435
436
436
> test
437
437
[info] Compiling 1 Scala source to (...)/scalajs-tutorial/target/scala-2.13/test-classes...
438
- [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-test-fastopt.js
438
+ [info] Fast optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-test-fastopt
439
439
-------------------------------- Running Tests --------------------------------
440
440
+ tutorial.webapp.TutorialTest.HelloWorld 3ms
441
441
+ tutorial.webapp.TutorialTest.ButtonClick 6ms
@@ -452,15 +452,15 @@ Here we show a couple of things you might want to do when you promote your appli
452
452
453
453
Size is critical for JavaScript code on the web. To compress the compiled code even further, the Scala.js sbt plugin
454
454
uses the advanced optimizations of the [ Google Closure Compiler] ( http://developers.google.com/closure/compiler/ ) . To run
455
- full optimizations, simply use the ` fullOptJS ` task:
455
+ full optimizations, simply use the ` fullLinkJS ` task:
456
456
457
- > fullOptJS
458
- [info] Full optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-opt.js
457
+ > fullLinkJS
458
+ [info] Full optimizing (...)/scalajs-tutorial/target/scala-2.13/scala-js-tutorial-opt
459
459
[info] Closure: 0 error(s), 0 warning(s)
460
460
[success] (...)
461
461
462
- Note that this can take a while on a larger project (tens of seconds), which is why we typically don't use ` fullOptJS `
463
- during development, but ` fastOptJS ` instead. If you want to ` run ` and ` test ` the full-optimized version from sbt,
462
+ Note that this can take a while on a larger project (tens of seconds), which is why we typically don't use ` fullLinkJS `
463
+ during development, but ` fastLinkJS ` instead. If you want to ` run ` and ` test ` the full-optimized version from sbt,
464
464
you need to change the * stage* using the following sbt setting:
465
465
466
466
> set scalaJSStage in Global := FullOptStage
@@ -478,7 +478,7 @@ We also need to create our final production HTML file `scalajs-tutorial.html` wh
478
478
</head >
479
479
<body >
480
480
<!-- Include Scala.js compiled code -->
481
- <script type="text/javascript" src="./target/scala-2.13/scala-js-tutorial-opt.js"></script>
481
+ <script type="text/javascript" src="./target/scala-2.13/scala-js-tutorial-opt/main .js"></script>
482
482
</body >
483
483
</html >
484
484
{% endhighlight %}
0 commit comments