Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ private[scalajslib] trait ScalaJSWorkerApi extends AutoCloseable {
outputPatterns: OutputPatterns,
minify: Boolean,
importMap: Seq[ESModuleImportMapping],
experimentalUseWebAssembly: Boolean
experimentalUseWebAssembly: Boolean,
parallel: Boolean
): Either[String, Report]

def run(config: JsEnvConfig, report: Report): Unit
Expand Down
19 changes: 15 additions & 4 deletions libs/scalajslib/src/mill/scalajslib/ScalaJSModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ trait ScalaJSModule extends scalalib.ScalaModule with ScalaJSModuleApi { outer =
override def esFeatures = outer.esFeatures()
override def jsEnvConfig: T[JsEnvConfig] = outer.jsEnvConfig()
override def scalaJSOptimizer: T[Boolean] = outer.scalaJSOptimizer()
override def scalaJSParallel: T[Boolean] = outer.scalaJSParallel()
}

def scalaJSBinaryVersion = Task { JvmWorkerUtil.scalaJSBinaryVersion(scalaJSVersion()) }
Expand Down Expand Up @@ -133,7 +134,8 @@ trait ScalaJSModule extends scalalib.ScalaModule with ScalaJSModuleApi { outer =
outputPatterns = scalaJSOutputPatterns(),
minify = scalaJSMinify(),
importMap = scalaJSImportMap(),
experimentalUseWebAssembly = scalaJSExperimentalUseWebAssembly()
experimentalUseWebAssembly = scalaJSExperimentalUseWebAssembly(),
parallel = scalaJSParallel()
)
}

Expand Down Expand Up @@ -185,7 +187,8 @@ trait ScalaJSModule extends scalalib.ScalaModule with ScalaJSModuleApi { outer =
outputPatterns: OutputPatterns,
minify: Boolean,
importMap: Seq[ESModuleImportMapping],
experimentalUseWebAssembly: Boolean
experimentalUseWebAssembly: Boolean,
parallel: Boolean
)(using ctx: mill.api.TaskCtx): Result[Report] = {
val outputPath = ctx.dest

Expand All @@ -207,7 +210,8 @@ trait ScalaJSModule extends scalalib.ScalaModule with ScalaJSModuleApi { outer =
outputPatterns = outputPatterns,
minify = minify,
importMap = importMap,
experimentalUseWebAssembly = experimentalUseWebAssembly
experimentalUseWebAssembly = experimentalUseWebAssembly,
parallel = parallel
)
}

Expand Down Expand Up @@ -281,6 +285,12 @@ trait ScalaJSModule extends scalalib.ScalaModule with ScalaJSModuleApi { outer =

def scalaJSOptimizer: T[Boolean] = Task { true }

/**
* Whether Scala.js operations that can be parallelized should be parallelized.
* On the JavaScript platform, this does not have any effect.
*/
def scalaJSParallel: T[Boolean] = Task { true }

def scalaJSImportMap: T[Seq[ESModuleImportMapping]] = Task {
Seq.empty[ESModuleImportMapping]
}
Expand Down Expand Up @@ -382,7 +392,8 @@ trait TestScalaJSModule extends ScalaJSModule with TestModule {
outputPatterns = scalaJSOutputPatterns(),
minify = scalaJSMinify(),
importMap = scalaJSImportMap(),
experimentalUseWebAssembly = scalaJSExperimentalUseWebAssembly()
experimentalUseWebAssembly = scalaJSExperimentalUseWebAssembly(),
parallel = scalaJSParallel()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ private[scalajslib] class ScalaJSWorker(jobs: Int)
outputPatterns: api.OutputPatterns,
minify: Boolean,
importMap: Seq[api.ESModuleImportMapping],
experimentalUseWebAssembly: Boolean
experimentalUseWebAssembly: Boolean,
parallel: Boolean
): Result[api.Report] = {
withValue(toolsClasspath) { case (_, bridge) =>
bridge.link(
Expand All @@ -224,7 +225,8 @@ private[scalajslib] class ScalaJSWorker(jobs: Int)
outputPatterns = toWorkerApi(outputPatterns),
minify = minify,
importMap = importMap.map(toWorkerApi),
experimentalUseWebAssembly = experimentalUseWebAssembly
experimentalUseWebAssembly = experimentalUseWebAssembly,
parallel = parallel
) match {
case Right(report) => Result.Success(fromWorkerApi(report))
case Left(message) => Result.Failure(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ScalaJSWorkerImpl(jobs: Int) extends ScalaJSWorkerApi {
outputPatterns: OutputPatterns,
minify: Boolean,
dest: File,
experimentalUseWebAssembly: Boolean
experimentalUseWebAssembly: Boolean,
parallel: Boolean
)
private def minorIsGreaterThanOrEqual(number: Int) = ScalaJSVersions.current match {
case s"1.$n.$_" if n.toIntOption.exists(_ < number) => false
Expand Down Expand Up @@ -104,6 +105,7 @@ class ScalaJSWorkerImpl(jobs: Int) extends ScalaJSWorkerApi {
.withModuleKind(scalaJSModuleKind)
.withESFeatures(scalaJSESFeatures)
.withSourceMap(input.sourceMap)
.withParallel(input.parallel)

def withModuleSplitStyle_1_3_plus(config: StandardConfig): StandardConfig = {
config.withModuleSplitStyle(
Expand Down Expand Up @@ -192,7 +194,8 @@ class ScalaJSWorkerImpl(jobs: Int) extends ScalaJSWorkerApi {
outputPatterns: OutputPatterns,
minify: Boolean,
importMap: Seq[ESModuleImportMapping],
experimentalUseWebAssembly: Boolean
experimentalUseWebAssembly: Boolean,
parallel: Boolean
): Either[String, Report] = ScalaJSLinker.withValue(LinkerInput(
isFullLinkJS = isFullLinkJS,
optimizer = optimizer,
Expand All @@ -203,7 +206,8 @@ class ScalaJSWorkerImpl(jobs: Int) extends ScalaJSWorkerApi {
outputPatterns = outputPatterns,
minify = minify,
dest = dest,
experimentalUseWebAssembly = experimentalUseWebAssembly
experimentalUseWebAssembly = experimentalUseWebAssembly,
parallel = parallel
)) { (linker, irFileCacheCache) =>
// On Scala.js 1.2- we want to use the legacy mode either way since
// the new mode is not supported and in tests we always use legacy = false
Expand Down