random-maven / scalor-maven-plugin

Build integrator for Java, Scala, Scala.macro, Scala.js, Scala.native, Eclipse and Maven.
https://random-maven.github.io/scalor-maven-plugin/2.12/plugin-info.html
Other
50 stars 6 forks source link

work around invalid component injector in m2e-1.8 #1

Closed PaulAtBanno closed 6 years ago

PaulAtBanno commented 6 years ago

Creating a simple Maven project with the following pom.xml exhibits the above error when updating the project settings:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.duck</groupId>
    <artifactId>invest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>invest</name>

    <properties>

        <version.java>1.8</version.java>

        <version.scala.epoch>2.11</version.scala.epoch>
        <version.scala.release>2.11.12</version.scala.release>

        <version.scala.plug.macro>2.1.0</version.scala.plug.macro>
        <version.scala.zinc>1.1.0</version.scala.zinc>

        <version.sjs.epoch>0.6</version.sjs.epoch>
        <version.sjs.release>${version.sjs.epoch}.21</version.sjs.release>
        <version.sjs.library>sjs${version.sjs.epoch}_${version.scala.epoch}</version.sjs.library>
        <version.sjs.scalacss>0.5.4</version.sjs.scalacss>
        <version.sjs.scalatags>0.6.7</version.sjs.scalatags>
        <version.sjs.autowire>0.2.6</version.sjs.autowire>
        <version.sjs.prickle>1.1.14</version.sjs.prickle>
        <version.sjs.upickle>0.5.1</version.sjs.upickle>
        <version.sjs.scalarx>0.3.2</version.sjs.scalarx>
        <version.sjs.utest>0.6.2</version.sjs.utest>
    </properties>

    <repositories>
        <repository>
            <id>random-maven</id>
            <name>Random Maven</name>
            <url>https://dl.bintray.com/random-maven/maven</url>
        </repository>
    </repositories>

    <dependencies>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${version.scala.release}</version>
        </dependency>

        <dependency>
            <groupId>org.scala-js</groupId>
            <artifactId>scalajs-library_${version.scala.epoch}</artifactId>
            <version>${version.sjs.release}</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>

            <!-- Disable default compiler. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <skip>true</skip>
                    <skipMain>true</skipMain>
                </configuration>
            </plugin>

            <!-- Enable alternative compiler. -->
            <plugin>
                <groupId>com.carrotgarden.maven</groupId>
                <artifactId>scalor-maven-plugin_2.12</artifactId>
                <!-- <version>RELEASE</version> -->
                <version>1.0.1.20180112171513</version>

                <configuration>

                    <skip>false</skip>

                    <zincLogSourcesList>true</zincLogSourcesList>
                    <zincLogProjectClassPath>true</zincLogProjectClassPath>
                    <zincLogCompilerClassPath>true</zincLogCompilerClassPath>
                    <zincLogCompilerPluginList>true</zincLogCompilerPluginList>

                    <!-- <skipLogReason>true</skipLogReason> -->
                    <!-- <eclipseLogBuildParticipant>true</eclipseLogBuildParticipant> -->

                    <zincCompileOptions>
                        -target:jvm-${version.java}
                        -encoding
                        ${project.build.sourceEncoding}
                        -deprecation
                        -unchecked
                        -feature
                        -P:scalajs:sjsDefinedByDefault
                        -compileorder:Mixed
                    </zincCompileOptions>

                    <defineBridge>
                        <dependency>
                            <groupId>org.scala-sbt</groupId>
                            <artifactId>compiler-bridge_${version.scala.epoch}</artifactId>
                            <version>${version.scala.zinc}</version>
                        </dependency>
                    </defineBridge>
                    <defineCompiler>
                        <dependency>
                            <groupId>org.scala-lang</groupId>
                            <artifactId>scala-compiler</artifactId>
                            <version>${version.scala.release}</version>
                            <exclusions>
                                <exclusion>
                                    <groupId>jline</groupId>
                                    <artifactId>jline</artifactId>
                                </exclusion>
                            </exclusions>
                        </dependency>
                    </defineCompiler>
                    <definePluginList>
                        <dependency>
                            <groupId>org.scala-js</groupId>
                            <artifactId>scalajs-compiler_${version.scala.release}</artifactId>
                            <version>${version.sjs.release}</version>
                        </dependency>
                        <dependency>
                            <groupId>org.scalamacros</groupId>
                            <artifactId>paradise_${version.scala.release}</artifactId>
                            <version>${version.scala.plug.macro}</version>
                        </dependency>
                    </definePluginList>

                </configuration>

                <executions>
                    <execution>
                        <goals>

                            <goal>eclipse-config</goal>

                            <goal>register-macro</goal>
                            <goal>register-main</goal>
                            <goal>register-test</goal>

                            <goal>clean-macro</goal>
                            <goal>clean-main</goal>
                            <goal>clean-test</goal>

                            <goal>compile-macro</goal>
                            <goal>prepack-macro</goal>

                            <goal>compile-main</goal>
                            <goal>prepack-main</goal>

                            <goal>compile-test</goal>
                            <goal>prepack-test</goal>

                            <goal>link-scala-js-main</goal>
                            <goal>prepack-linker-main</goal>

                            <goal>link-scala-js-test</goal>
                            <goal>prepack-linker-test</goal>

                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Replacing the new project's pom.xml rightly presents the issue that the project's settings need updating. Doing so, however, results in the error in the subject.

Andrei-Pozolotin commented 6 years ago

1) please try 1.0.2 development release https://bintray.com/random-maven/maven/scalor-maven-plugin_2.12

2) please post zip of maven console output https://www.ibm.com/support/knowledgecenter/SS8PJ7_9.1.0/com.ibm.etools.maven.doc/topics/troubleshooting.html

PaulAtBanno commented 6 years ago

OK, here is logs.zip, which includes my current pom.xml, the Maven console output, and the stacktrace taken from the resulting alert. Thanks for the new plugin, which I'm very excited about, and for looking into this!

Andrei-Pozolotin commented 6 years ago

thanks - from zips it looks like I depend on wrong version of M2E (you use 1.8 (?) vs I use 1.9)

please attach zip (with sanitized system properties) eclipse config (so I can verify your plugin versions):

Eclipse -> Help -> About Eclipse -> Installation Details -> Configuration -> [select / copy / save]
PaulAtBanno commented 6 years ago

You're exactly right: I use 1.8.2, and in fact can't find a "1.9" anywhere. Here is configuration.txt.zip for confirmation. Thanks again!

Andrei-Pozolotin commented 6 years ago

thanks, now I can reproduce problem 100%

Andrei-Pozolotin commented 6 years ago
  1. here is the fix https://github.com/random-maven/scalor-maven-plugin/blob/master/src/main/scala/com/carrotgarden/maven/scalor/eclipse/Maven.scala#L243

  2. please try release 1.0.3 http://search.maven.org/#search%7Cga%7C1%7Cscalor-maven-plugin_2.12

  3. with demo project (clone / copy / paste) https://github.com/random-maven/scalor-maven-plugin/tree/master/demo

PaulAtBanno commented 6 years ago

With the latest plugin, updating my Maven settings gets me this Maven console:

1/16/18, 4:06:18 PM EST: [INFO] Update started
1/16/18, 4:06:19 PM EST: [INFO] Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.duck:invest:0.0.1-SNAPSHOT @ /Users/psnively/eclipse-workspace/invest/pom.xml.
1/16/18, 4:06:22 PM EST: [INFO] Adding source folder /invest/src/main/java
1/16/18, 4:06:22 PM EST: [INFO] Adding resource folder /invest/src/main/resources
1/16/18, 4:06:22 PM EST: [INFO] Adding source folder /invest/src/test/java
1/16/18, 4:06:22 PM EST: [INFO] Adding resource folder /invest/src/test/resources
1/16/18, 4:06:23 PM EST: [INFO] Update completed: 5 sec
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config] Using Eclipse platform plugins:
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config]    org.eclipse.core.resources_3.12.0.v20170417-1558 [122]
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config]    org.eclipse.m2e.core_1.8.2.20171007-0217 [572]
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config]    org.eclipse.m2e.core.ui_1.8.2.20171007-0217 [573]
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config] Configuring companion Eclipse plugin:
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config]    pluginId: com.carrotgarden.maven.scalor-maven-plugin_2.12_1.0.3.20180115180433
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config]    location: file:/Users/psnively/.m2/repository/com/carrotgarden/maven/scalor-maven-plugin_2.12/1.0.3.20180115180433/scalor-maven-plugin_2.12-1.0.3.20180115180433.jar
1/16/18, 4:06:25 PM EST: [INFO] [scalor] Plugin start: com.carrotgarden.maven.scalor-maven-plugin_2.12_1.0.3.20180115180433
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config] Companion plugin installed in Eclipse: com.carrotgarden.maven.scalor-maven-plugin_2.12_1.0.3.20180115180433_0.0.0 [1973]
1/16/18, 4:06:25 PM EST: [INFO] [scalor:eclipse-config] Scheduling project update in Eclipse to invoke M2E project configurator.
1/16/18, 4:06:25 PM EST: [WARN] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
1/16/18, 4:06:25 PM EST: [INFO] Copying 0 resource
1/16/18, 4:06:25 PM EST: [WARN] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
1/16/18, 4:06:25 PM EST: [INFO] Copying 0 resource
1/16/18, 4:06:26 PM EST: [INFO] Update started
1/16/18, 4:06:26 PM EST: [INFO] Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.duck:invest:0.0.1-SNAPSHOT @ /Users/psnively/eclipse-workspace/invest/pom.xml.
1/16/18, 4:06:26 PM EST: [INFO] [scaler:step#1] Configuring dependency classpath.
1/16/18, 4:06:26 PM EST: [INFO] [scaler:step#1] Verifying Maven M2E version.
1/16/18, 4:06:26 PM EST: [INFO] [scaler:step#1]    version 1.8.2.20171007-0217 is in range [1.8.0,1.10.0)
1/16/18, 4:06:26 PM EST: [INFO] [scaler:step#1] Verifying Scala IDE version.
1/16/18, 4:06:26 PM EST: [INFO] [scaler:step#1]    version 4.7.0.v-2_12-201709291352-71a28d0 is in range [4.7.0,4.7.2)
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-macro] Registering root:   /Users/psnively/eclipse-workspace/invest/src/macro/java
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-macro] Registering root:   /Users/psnively/eclipse-workspace/invest/src/macro/scala
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-macro] Already registered: /Users/psnively/eclipse-workspace/invest/target/classes
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-macro] Ensuring build folders.
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-main] Already registered: /Users/psnively/eclipse-workspace/invest/src/main/resources
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-main] Already registered: /Users/psnively/eclipse-workspace/invest/src/main/java
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-main] Registering root:   /Users/psnively/eclipse-workspace/invest/src/main/scala
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-main] Already registered: /Users/psnively/eclipse-workspace/invest/target/classes
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-main] Ensuring build folders.
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-test] Already registered: /Users/psnively/eclipse-workspace/invest/src/test/resources
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-test] Already registered: /Users/psnively/eclipse-workspace/invest/src/test/java
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-test] Registering root:   /Users/psnively/eclipse-workspace/invest/src/test/scala
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-test] Already registered: /Users/psnively/eclipse-workspace/invest/target/test-classes
1/16/18, 4:06:27 PM EST: [INFO] [scalor:register-test] Ensuring build folders.
1/16/18, 4:06:27 PM EST: [INFO] Adding source folder /invest/src/main/java
1/16/18, 4:06:27 PM EST: [INFO] Adding source folder /invest/src/macro/java
1/16/18, 4:06:27 PM EST: [INFO] Adding source folder /invest/src/macro/scala
1/16/18, 4:06:27 PM EST: [INFO] Adding source folder /invest/src/main/scala
1/16/18, 4:06:27 PM EST: [INFO] Adding resource folder /invest/src/main/resources
1/16/18, 4:06:27 PM EST: [INFO] Adding source folder /invest/src/test/java
1/16/18, 4:06:27 PM EST: [INFO] Adding source folder /invest/src/test/scala
1/16/18, 4:06:27 PM EST: [INFO] Adding resource folder /invest/src/test/resources
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2] Configuring project classpath.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/macro/java -> /invest/target/classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/macro/scala -> /invest/target/classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/main/resources -> /invest/target/classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/main/java -> /invest/target/classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/main/scala -> /invest/target/classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/test/resources -> /invest/target/test-classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/test/java -> /invest/target/test-classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2]    /invest/src/test/scala -> /invest/target/test-classes
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2] Deleting container org.scala-ide.sdt.launching.SCALA_CONTAINER.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#2] Ordering top level entries inside the .classpath.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#1] Configuring dependency classpath.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Configuring project settings.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Hacking .project symbolic links.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Applying Eclipse .project comment.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Ensuring project natures.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Ordering Eclipse .project builder entries.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Ordering Eclipse .project nature entries.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Configuring Scala IDE.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3] Resolving custom Scala installation.
1/16/18, 4:06:27 PM EST: [INFO] Update completed: 1 sec
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3+] Configuring Scala IDE (scheduled job).
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3+] Persisting custom Scala installation.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3+] Updating project Scala settings.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3+] Providing configured settings.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3+] Resetting preferences to default.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3+] Persisting compiler selection.
1/16/18, 4:06:27 PM EST: [INFO] [scaler:step#3+] Persisting configured settings.
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config] Using Eclipse platform plugins:
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config]    org.eclipse.core.resources_3.12.0.v20170417-1558 [122]
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config]    org.eclipse.m2e.core_1.8.2.20171007-0217 [572]
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config]    org.eclipse.m2e.core.ui_1.8.2.20171007-0217 [573]
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config] Configuring companion Eclipse plugin:
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config]    pluginId: com.carrotgarden.maven.scalor-maven-plugin_2.12_1.0.3.20180115180433
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config]    location: file:/Users/psnively/.m2/repository/com/carrotgarden/maven/scalor-maven-plugin_2.12/1.0.3.20180115180433/scalor-maven-plugin_2.12-1.0.3.20180115180433.jar
1/16/18, 4:06:32 PM EST: [INFO] [scalor:eclipse-config] Companion plugin is already installed: com.carrotgarden.maven.scalor-maven-plugin_2.12_1.0.3.20180115180433_0.0.0 [1973]
1/16/18, 4:06:32 PM EST: [WARN] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
1/16/18, 4:06:32 PM EST: [INFO] Copying 0 resource
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main] Detected scalajs-library: 2.11-0.6.21.
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main] Scala.js linker args:
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    --output
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    /Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    --fastOpt
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    --sourceMap
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    --debug
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    --prettyPrint
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    /Users/psnively/eclipse-workspace/invest/target/classes
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main]    /Users/psnively/.m2/repository/org/scala-js/scalajs-library_2.11/0.6.21/scalajs-library_2.11-0.6.21.jar
1/16/18, 4:06:32 PM EST: [INFO] [scalor:link-scala-js-main] Invoking Scala.js linker.
1/16/18, 4:06:34 PM EST: [WARN] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
1/16/18, 4:06:34 PM EST: [INFO] Copying 0 resource
1/16/18, 4:06:34 PM EST: [INFO] [scalor:link-scala-js-test] Missing scalajs-library, skipping execution.

I think it's correct. In particular, I have target/classes/tutorial/webapp/TutorialApp$.sjsir from compiling to JavaScript. What I don't see (or know how to look for?) is the linked .js combination of that and the runtime. Or is that what's meant by the argument to --output, i.e. /Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js is the linked program?

Thanks again! I think you can close this ticket, as the bug has clearly been fixed; the rest is just a gap in my understanding.

Andrei-Pozolotin commented 6 years ago
  1. log looks about right

  2. *.sjsir are scala classes compiled into IR - intermediate representation of JavaScript

  3. META-INF/resources/script/runtime.js is result of linking of these classes for deployment

  4. please try to test plugin now with M2E 1.9 https://repository.takari.io/content/sites/m2e.extras/m2e/1.9.0/N/LATEST/

  5. congratulations, you earned a badge: First Successful User :-)

PaulAtBanno commented 6 years ago

It also builds fine with Maven 3.5.2 and m2e 1.9, so I think it's good.

I'm still confused by one thing, though. If I have this source code:

package tutorial.webapp

object TutorialApp {
  def main(args: Array[String]): Unit = {
    println("Hello world!")
  }
}

shouldn't I then be able to say:

node runtime.js

in the target/classes/META-INF/resources/script directory, and see:

Hello world!

in the console?

Thanks so much!

Andrei-Pozolotin commented 6 years ago

sure, as long as you export https://www.scala-js.org/doc/interoperability/export-to-javascript.html

PaulAtBanno commented 6 years ago

No dice. Here's my source code now:

package tutorial.webapp

import scala.scalajs.js.annotation._

@JSExportTopLevel("TutorialApp")
object TutorialApp {
  @JSExport
  def main(args: Array[String]): Unit = {
    println("Hello world!")
  }
}

but

node runtime.js

still produces nothing:

⇒  node runtime.js
psnively@Ragnarok:~/eclipse-workspace/invest/target/classes/META-INF/resources/script|
⇒  

I think there's something I'm still missing about how to specify that tutorial.webapp.TutorialApp.main should be the entry point, as far as JavaScript is concerned.

Update: I think we need the equivalent of scalaJSUseMainModuleInitializer := true from sbt, somehow.

Andrei-Pozolotin commented 6 years ago

right. I am re-doing linker for incremental support, things will change. so, keep posting your wish list :-)

PaulAtBanno commented 6 years ago

OK, but... this seems kind of fundamental, right? It seems like the link-scala-js-main goal should produce a JavaScript file you can just run with any JavaScript runtime. In other words, the contents of the Basic tutorial from Scala.js should apply, maybe apart from having to run node.js manually (but it also seems like interop with the frontend-maven-plugin would be useful).

So I guess my immediate question is: what do I need to do to actually build a runnable JavaScript application with this plugin? This is admittedly mostly for validation purposes, as I do ultimately expect to be browser-based rather than standalone. I'm just trying to get from "Hello, world" to that point incrementally.

Andrei-Pozolotin commented 6 years ago
  1. I think not "very fundamental" - there is no main() convention in JavaScript

  2. in web context, you normally provide something to the effect A + B:

    
    <!-- A) inject runtime, must provide some global object, say "App" -->
    <script src="./server-provided-path/runtime.js"></script>
3. re: "to actually build a runnable " - you already have; 

a) try to run it with

node --eval "App.main()"


b) or, skip the `node.js` and try to make simple `index.html` with script example 
similar to the above, and open it in the browser, 
locally as url `file://...`, for example:
https://github.com/sjrd/scala-js-example-app/blob/master/index.html
PaulAtBanno commented 6 years ago

I think not "very fundamental" - there is no main() convention in JavaScript

Understood, hence my comment about maybe wanting to support something like sbt's scalaJSUseMainModuleInitializer := true. In other words, there apparently is a notion of "main module," and there apparently is some way it can be "initialized" such that the resulting JavaScript does expose an entry point in some sense that, e.g. node.js understands.

Now, you can certainly observe (and I could easily understand) that's specific to the sbt plugin and is out of scope for what you're trying to achieve. But you did encourage me to keep spelling out my wish list. :-)

Andrei-Pozolotin commented 6 years ago

sure, you will have some form of scalaJSUseMainModuleInitializer bring it in :-)

PaulAtBanno commented 6 years ago

In the meantime:

psnively@Ragnarok:~|⇒  node -e 'require("/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js"); TutorialApp.main()'
/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:213
  throw new $c_sjsr_UndefinedBehaviorError().init___jl_Throwable(
  ^

Error
    at $c_sjsr_UndefinedBehaviorError.$c_jl_Throwable.fillInStackTrace__jl_Throwable (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:1738:14)
    at $c_sjsr_UndefinedBehaviorError.fillInStackTrace__jl_Throwable (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:2756:67)
    at $c_sjsr_UndefinedBehaviorError.$c_jl_Throwable.init___T__jl_Throwable (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:1754:8)
    at $c_sjsr_UndefinedBehaviorError.init___T__jl_Throwable (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:2763:52)
    at $c_sjsr_UndefinedBehaviorError.init___jl_Throwable (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:2759:67)
    at $throwClassCastException (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:213:46)
    at $throwArrayCastException (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:222:3)
    at $asArrayOf_T (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:2289:64)
    at $c_Ltutorial_webapp_TutorialApp$.main (/Users/psnively/eclipse-workspace/invest/target/classes/META-INF/resources/script/runtime.js:1153:15)
    at [eval]:1:118

So the good news is the export annotations are working, compiling is working, and linking is working. But there's apparently still something I'm misunderstanding about how to actually use the result.

Andrei-Pozolotin commented 6 years ago

great. now try to reproduce same result with browser / index.html it is easier to debug with UI, i.e. https://developer.chrome.com/devtools

Andrei-Pozolotin commented 6 years ago

please try 1.1.0 release http://search.maven.org/#search%7Cga%7C1%7Cscalor-maven-plugin_2.12

use demo project as reference https://github.com/random-maven/scalor-maven-plugin/tree/master/demo

Andrei-Pozolotin commented 6 years ago

assume resolved

Andrei-Pozolotin commented 6 years ago

@PaulAtBanno FYI: Scala.js module initializes are now supported: https://random-maven.github.io/scalor-maven-plugin/2.12/scala-js-link-main-mojo.html#linkerMainInitializerList