Skip to content

Commit

Permalink
Be more intelligent about running webpack with NODE_OPTIONS=--openssl…
Browse files Browse the repository at this point in the history
…-legacy-provider
  • Loading branch information
nafg committed Nov 27, 2022
1 parent 8ce5490 commit e08d6bd
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ trait ScalaJSWebpackModule extends ScalaJSBundleModule {

def webpackConfigFilename = T("webpack.config.js")

def webpackEnv: Target[Map[String, String]] = T {
val nodeMajorVersion = os
.proc("node", "--version")
.call()
.out
.text()
.trim
.stripPrefix("v")
.split('.')
.head
.toInt
val webpackMajorVersion = webpackVersion().split('.').head.toInt
Option
.when(nodeMajorVersion == 18 && webpackMajorVersion == 4)(
"NODE_OPTIONS" -> "--openssl-legacy-provider"
)
.toMap
}

override protected def bundle = T.task { params: BundleParams =>
copySources()
val bundleName = bundleFilename()
Expand All @@ -82,7 +101,7 @@ trait ScalaJSWebpackModule extends ScalaJSBundleModule {
"--config",
webpackConfigFilename()
),
envArgs = Map("NODE_OPTIONS" -> "--openssl-legacy-provider"),
envArgs = webpackEnv(),
workingDir = dir
)
catch {
Expand Down

0 comments on commit e08d6bd

Please sign in to comment.