Skip to content

Import the Node.js with jsdom env from the Scala.js core repository. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 27, 2017
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2c7b6f9
Fix scala-js/scala-js#595: Test SBT plugin in published form on Travis
gzm0 May 7, 2014
1367e17
Fix scala-js/scala-js#1060: Cleanup scala.scalajs.test namespace
gzm0 Sep 19, 2014
8e8aaad
Add DOMJSEnv based on 'jsdom' in Node.js.
nicolasstucki Dec 21, 2015
7ccf30d
Remove Jasmine from sbtPluginTest.
nicolasstucki Apr 26, 2016
fdf02b9
Add history API support to JSDOMNodeJSEnv
julienrf Dec 5, 2016
8427547
Use VirtualJSFiles instead of ResolvedJSDependency in the JSEnv API.
sjrd Mar 28, 2017
b568d64
Do not use jsDependencies (nor jQuery) in sbt-plugin-test/withDOM.
sjrd Apr 5, 2017
4a75741
Unify the parameter names of external JS env constructors.
sjrd Apr 8, 2017
8d4006c
Merge '0.6.x' into 'master'.
sjrd Apr 9, 2017
703ec63
Fix scala-js/scala-js#2874: Remove the distinction libs/code in the J…
sjrd Apr 10, 2017
f582d26
Fix scala-js/scala-js#2902: Adapt to jsdom v10.
sjrd Apr 25, 2017
796d971
Merge '0.6.x' into 'master'.
sjrd Apr 28, 2017
ca40d6c
Recognize any "standard" JVM-style main object in the sbt plugin.
sjrd Jun 7, 2017
f06ed90
Introduce a new surface API for JS envs with `Config` objects.
sjrd Jun 9, 2017
3740ad5
Merge pull request scala-js/scala-js#3001 from sjrd/new-jsenv-api-0.6.x
gzm0 Jun 14, 2017
2768e29
Merge '0.6.x' into 'master'.
sjrd Jun 15, 2017
c354793
Remove the deprecated APIs in JS envs.
sjrd Jun 16, 2017
7501666
Fix scala-js/scala-js#2877: Internal JS envs config amenable to binco…
sjrd Jun 16, 2017
1c8cede
Extract JSDOMNodeJSEnv in its own project.
sjrd Jun 22, 2017
62df6b6
Import the Node.js with jsdom env from the Scala.js core repository.
sjrd Jun 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Recognize any "standard" JVM-style main object in the sbt plugin.
In addition to recognizing objects extending `js.JSApp`, the sbt
plugin now recognizes "standard" main methods as well, i.e.,
objects with a method of the form

    def main(args: Array[String]): Unit = ...

If such an object is used as main class, its main method is called
using the new `ModuleInitializer.mainMethodWithArgs`.

This has the nice benefit that we can finally write a
cross-platform main object.

We "softly" deprecate `js.JSApp`: its documentation says not to
use anymore, but it does not cause a deprecation warning yet.

For backward compatibility, objects extending `js.JSApp` are
still recognized, and their `main(): Unit` method will be called.

There are some subtle scenarios regarding backward compatibility:

* If an object *both* extends `js.JSApp` and has a standard main
  method, the `main()` method of `js.JSApp` is preferred, for
  backward compatibility.
* If an object has a `main(): Unit` method but does not extend
  `js.JSApp`, it will not be *discovered*. In that case, we assume
  the old style and call `main()`. This can happen if the user
  explicitly sets the `mainClass` setting.
* If an object has *both* a `main(): Unit` method and a
  `main(args: Array[String]): Unit` method, it *will* now be
  discovered, and the new style will be assumed. This can
  potentially break compatibility, as now the standard main will
  be called. This only happens in case the user has explicitly set
  `mainClass`. Moreover, it is only problematic if `main()` does
  not behave the same as `main(Array())`, in which case the
  codebase is arguably in a bad shape to begin with.
* The very fact of recognizing *more* objects as potential main
  objects means that the sbt build can break because it cannot
  automatically choose between several discovered objects. This
  will however fail to link with a nice error message, so it is
  not too bad.

Here are some examples.

* Old-style only, `main()` is selected

    object OldStyleOnly extends js.JSApp {
      def main(): Unit = ...
    }

* New-style only, `main(Array[String])` is selected

    object NewStyleOnly {
      def main(args: Array[String]): Unit = ...
    }

* Old and new style combined, `main()` is selected

    object OldAndNewStyle extends js.JSApp {
      def main(): Unit = ...
      def main(args: Array[String]): Unit = ...
    }

* `def main(): Unit` without `js.JSApp` only, `main()` is selected

    object OldStyleNonJSApp {
      def main(): Unit = ...
    }

* Both styles of methods without `js.JSApp`, `main(Array[String])`
  is selected (potentially silently breaking)

    object OldAndNewStyleNonJSApp {
      def main(): Unit = ...
      def main(args: Array[String]): Unit = ...
    }

* Both styles exist in two different objects, sbt reports an
  ambiguity and demands that `mainClass` be set explicitly

    object OldStyle extends js.JSApp {
      def main(): Unit = ...
    }
    object NewStyle {
      def main(args: Array[String]): Unit = ...
    }
  • Loading branch information
sjrd committed Jun 7, 2017
commit ca40d6cf3961bae65eb7a2598ee04ecbbf79d111
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package sbttest.withDOM

import scala.scalajs.js
object TestApp {

object TestApp extends js.JSApp {

def main(): Unit = {
def main(args: Array[String]): Unit = {
Lib.appendDocument("Hello World")
Lib.appendDocument("Still Here!")

Expand Down