1
1
package sri .sbt .platform
2
2
3
+ import org .scalajs .core .tools .linker .backend .ModuleKind
3
4
import sbt .Keys ._
4
5
import sbt ._
5
6
import org .scalajs .sbtplugin .ScalaJSPlugin .AutoImport ._
6
7
import org .scalajs .sbtplugin .ScalaJSPluginInternal
8
+ import org .scalajs .sbtplugin .ScalaJSPluginInternal .scalaJSProjectBaseSettings
7
9
8
10
object ConfigBuilder {
9
11
@@ -70,8 +72,15 @@ object ConfigBuilder {
70
72
dev := {
71
73
val indexFile = baseDirectory.value / entryFile
72
74
val indexContent = IO .read(indexFile)
73
- (fastOptJS in config).value.data
74
- val launcher = s """ require("./ $aPath"); """
75
+ println(s " value : ${scalaJSUseMainModuleInitializer.value}" )
76
+ (fastOptJS).value.data
77
+ val mainClassRef = (mainClass in Compile ).value
78
+ .getOrElse(" " )
79
+ .split('.' )
80
+ .map(s => s """ [" $s"] """ )
81
+ .mkString(" " )
82
+ .concat(" ().main()" )
83
+ val launcher = s """ require("./ $aPath") ${mainClassRef}; """
75
84
if (! indexContent.contains(launcher)) IO .append(indexFile, launcher)
76
85
// if (!isServerStarted) {
77
86
// if ((npmStart !) == 0) {
@@ -84,7 +93,13 @@ object ConfigBuilder {
84
93
val indexFile = baseDirectory.value / entryFile
85
94
val indexContent = IO .read(indexFile)
86
95
(fullOptJS in config).value.data
87
- val launcher = s """ require("./ $aPath"); """
96
+ val mainClassRef = (mainClass in Compile ).value
97
+ .getOrElse(" " )
98
+ .split('.' )
99
+ .map(s => s """ [" $s"] """ )
100
+ .mkString(" " )
101
+ .concat(" ().main()" )
102
+ val launcher = s """ require("./ $aPath") ${mainClassRef}; """
88
103
if (! indexContent.contains(launcher)) IO .append(indexFile, launcher)
89
104
}
90
105
))
0 commit comments