Skip to content

Commit

Permalink
Remove bundle cross target from stage task scope (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrdom authored Feb 16, 2024
1 parent c9b0ee9 commit da4cba5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object ScalaJSEsbuildElectronPlugin extends AutoPlugin {

val targetDirectory = (esbuildInstall / crossTarget).value
val outputDirectory =
(stageTask / esbuildBundle / crossTarget).value
(esbuildBundle / crossTarget).value
val path =
targetDirectory
.relativize(new File(outputDirectory, mainModule.jsFileName))
Expand Down Expand Up @@ -117,7 +117,7 @@ object ScalaJSEsbuildElectronPlugin extends AutoPlugin {
.mkString("[", ",", "]")
val targetDirectory = (esbuildInstall / crossTarget).value
val outputDirectory =
(stageTask / esbuildBundle / crossTarget).value
(esbuildBundle / crossTarget).value
val relativeOutputDirectory =
targetDirectory
.relativize(outputDirectory)
Expand Down Expand Up @@ -206,7 +206,7 @@ object ScalaJSEsbuildElectronPlugin extends AutoPlugin {
val targetDirectory = (esbuildInstall / crossTarget).value
val nodeRelativeOutputDirectoryJs = {
val outputDirectory =
(stageTask / esbuildBundle / crossTarget).value
(esbuildBundle / crossTarget).value
val nodeRelativeOutputDirectory = targetDirectory
.relativize(outputDirectory)
.getOrElse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ object ScalaJSEsbuildWebPlugin extends AutoPlugin {
entryPoints.map("'" + _ + "'").mkString("[", ",", "]")
val targetDirectory = (esbuildInstall / crossTarget).value
val outputDirectory =
(stageTask / esbuildBundle / crossTarget).value
(esbuildBundle / crossTarget).value
val relativeOutputDirectory =
targetDirectory
.relativize(outputDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ object ScalaJSEsbuildPlugin extends AutoPlugin {
"esbuild" /
(if (configuration.value == Compile) "main" else "test")
},
esbuildBundle / crossTarget := (esbuildInstall / crossTarget).value / "out",
esbuildCopyResources / fileInputs += (esbuildResourcesDirectory.value.toGlob / **),
esbuildCopyResources / fileInputExcludeFilter := (esbuildCopyResources / fileInputExcludeFilter).value || (esbuildResourcesDirectory.value.toGlob / "node_modules" / **),
esbuildCopyResources := {
Expand Down Expand Up @@ -185,16 +186,14 @@ object ScalaJSEsbuildPlugin extends AutoPlugin {

installFileChanges ++ stageTaskFileChanges
},
// TODO move out of `stageTask` scope
stageTask / esbuildBundle / crossTarget := (esbuildInstall / crossTarget).value / "out",
stageTask / esbuildBundleScript := {
val stageTaskReport = stageTask.value.data
val entryPoints = jsFileNames(stageTaskReport)
val entryPointsJs =
s"${entryPoints.map("'" + _ + "'").mkString("[", ",", "]")}"
val targetDirectory = (esbuildInstall / crossTarget).value
val outputDirectory =
(stageTask / esbuildBundle / crossTarget).value
(esbuildBundle / crossTarget).value
val relativeOutputDirectory =
targetDirectory
.relativize(outputDirectory)
Expand Down Expand Up @@ -238,7 +237,7 @@ object ScalaJSEsbuildPlugin extends AutoPlugin {
val fileChanges = (stageTask / esbuildCompile).value
val bundlingScript = (stageTask / esbuildBundleScript).value
val targetDir = (esbuildInstall / crossTarget).value
val outDir = (stageTask / esbuildBundle / crossTarget).value
val outDir = (esbuildBundle / crossTarget).value

if (fileChanges.hasChanges || !outDir.exists()) {
val scriptFileName = "sbt-scalajs-esbuild-bundle-script.cjs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ package object scalajsesbuild {
val mainModule = resolveMainModule(report)

val path =
((stageTask / esbuildBundle / crossTarget).value / mainModule.jsFileName).toPath
((esbuildBundle / crossTarget).value / mainModule.jsFileName).toPath
Seq(Input.Script(path))
}
}
Expand Down

0 comments on commit da4cba5

Please sign in to comment.