@@ -24,6 +24,8 @@ import sbt.PublishBinPlugin.autoImport._
24
24
import dotty .tools .sbtplugin .RepublishPlugin
25
25
import dotty .tools .sbtplugin .RepublishPlugin .autoImport ._
26
26
import dotty .tools .sbtplugin .ScalaLibraryPlugin
27
+ import dotty .tools .sbtplugin .DottyJSPlugin
28
+ import dotty .tools .sbtplugin .DottyJSPlugin .autoImport ._
27
29
28
30
import sbt .plugins .SbtPlugin
29
31
import sbt .ScriptedPlugin .autoImport ._
@@ -39,58 +41,6 @@ import sbttastymima.TastyMiMaPlugin.autoImport._
39
41
import scala .util .Properties .isJavaAtLeast
40
42
41
43
import org .portablescala .sbtplatformdeps .PlatformDepsPlugin .autoImport ._
42
- import org .scalajs .linker .interface .{ModuleInitializer , StandardConfig }
43
-
44
- object DottyJSPlugin extends AutoPlugin {
45
- import Build ._
46
-
47
- object autoImport {
48
- val switchToESModules : StandardConfig => StandardConfig =
49
- config => config.withModuleKind(ModuleKind .ESModule )
50
- }
51
-
52
- val writePackageJSON = taskKey[Unit ](
53
- " Write package.json to configure module type for Node.js" )
54
-
55
- override def requires : Plugins = ScalaJSPlugin
56
-
57
- override def projectSettings : Seq [Setting [_]] = Def .settings(
58
- commonBootstrappedSettings,
59
-
60
- /* #11709 Remove the dependency on scala3-library that ScalaJSPlugin adds.
61
- * Instead, in this build, we use `.dependsOn` relationships to depend on
62
- * the appropriate, locally-defined, scala3-library-bootstrappedJS.
63
- */
64
- libraryDependencies ~= {
65
- _.filter(! _.name.startsWith(" scala3-library_sjs1" ))
66
- },
67
-
68
- // Replace the JVM JUnit dependency by the Scala.js one
69
- libraryDependencies ~= {
70
- _.filter(! _.name.startsWith(" junit-interface" ))
71
- },
72
- libraryDependencies +=
73
- (" org.scala-js" %% " scalajs-junit-test-runtime" % scalaJSVersion % " test" ).cross(CrossVersion .for3Use2_13),
74
-
75
- // Typecheck the Scala.js IR found on the classpath
76
- scalaJSLinkerConfig ~= (_.withCheckIR(true )),
77
-
78
- Compile / jsEnvInput := (Compile / jsEnvInput).dependsOn(writePackageJSON).value,
79
- Test / jsEnvInput := (Test / jsEnvInput).dependsOn(writePackageJSON).value,
80
-
81
- writePackageJSON := {
82
- val packageType = scalaJSLinkerConfig.value.moduleKind match {
83
- case ModuleKind .NoModule => " commonjs"
84
- case ModuleKind .CommonJSModule => " commonjs"
85
- case ModuleKind .ESModule => " module"
86
- }
87
-
88
- val path = target.value / " package.json"
89
-
90
- IO .write(path, s """ {"type": " $packageType"}\n """ )
91
- },
92
- )
93
- }
94
44
95
45
object Build {
96
46
import ScaladocConfigs ._
@@ -1608,6 +1558,7 @@ object Build {
1608
1558
asDottyLibrary(Bootstrapped ).
1609
1559
enablePlugins(DottyJSPlugin ).
1610
1560
settings(
1561
+ commonBootstrappedSettings,
1611
1562
libraryDependencies +=
1612
1563
(" org.scala-js" %% " scalajs-library" % scalaJSVersion).cross(CrossVersion .for3Use2_13),
1613
1564
// NOTE: Until 3.8.0, we pin the source files to be used by the scala3 library
@@ -2055,6 +2006,7 @@ object Build {
2055
2006
enablePlugins(DottyJSPlugin ).
2056
2007
dependsOn(`scala3-library-bootstrappedJS`).
2057
2008
settings(
2009
+ commonBootstrappedSettings,
2058
2010
// Required to run Scala.js tests.
2059
2011
Test / fork := false ,
2060
2012
@@ -2072,6 +2024,7 @@ object Build {
2072
2024
enablePlugins(DottyJSPlugin ).
2073
2025
dependsOn(`scala3-library-bootstrappedJS`).
2074
2026
settings(
2027
+ commonBootstrappedSettings,
2075
2028
bspEnabled := false ,
2076
2029
scalacOptions --= Seq (" -Werror" , " -deprecation" ),
2077
2030
@@ -2315,12 +2268,15 @@ object Build {
2315
2268
lazy val `scaladoc-js-common` = project.in(file(" scaladoc-js/common" )).
2316
2269
enablePlugins(DottyJSPlugin ).
2317
2270
dependsOn(`scala3-library-bootstrappedJS`).
2318
- settings(libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 2.8.0" ))
2271
+ settings(
2272
+ commonBootstrappedSettings,
2273
+ libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 2.8.0" ))
2319
2274
2320
2275
lazy val `scaladoc-js-main` = project.in(file(" scaladoc-js/main" )).
2321
2276
enablePlugins(DottyJSPlugin ).
2322
2277
dependsOn(`scaladoc-js-common`).
2323
2278
settings(
2279
+ commonBootstrappedSettings,
2324
2280
scalaJSUseMainModuleInitializer := true ,
2325
2281
Test / fork := false
2326
2282
)
@@ -2329,6 +2285,7 @@ object Build {
2329
2285
enablePlugins(DottyJSPlugin ).
2330
2286
dependsOn(`scaladoc-js-common`).
2331
2287
settings(
2288
+ commonBootstrappedSettings,
2332
2289
Test / fork := false ,
2333
2290
scalaJSUseMainModuleInitializer := true ,
2334
2291
libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 2.8.0" )
0 commit comments