What is the new syntax after "commonWebpackConfig"...
# javascript
d
What is the new syntax after "commonWebpackConfig" deprecation?
g
Passing an
Action
-Object with the lambda as a parameter worked for me:
Copy code
commonWebpackConfig(Action {
  cssSupport {
    enabled.set(true)
  })
d
Any idea how to specify the outputFileName in this case?
g
I haven’t done that before – the look at the webpack documentation. The
KotlinWebpackConfig
-Object should copy the original values. At least it was like this in case of the
DevServer
-Object.
e
I wonder why they went with the
Action
wrapping, it makes the DSL more "difficult"
a
@Ilya Goncharov [JB] ^^
v
It's not so much wrapping, it is for the meantime when both methods are still there, one that takes
body: KotlinWebpackConfig.() -> Unit)
and one that takes
body: Action<KotlinWebpackConfig>)
. With just the OP code, both could be satisfied and the first one wins. If the first one is deleted, i.e. like on
master
, the second one would be used automatically. But while both are there, the deprecated one wins.
i
It was done for compatibility’s sake, but since
1.9.20
only variant with
Action
will be left. Because Gradle generates accessors for Kotlin, it will not be mandatory to write
Action {}
And we need to use only function with
Action
input parameter because it can be used as Input parameter for Gradle
e
Thanks, good to know!
a
@Ilya Goncharov [JB], and what about the
outputFileName
?
👍 1
t
AFAIK It will be calculated:
moduleName
+
".js"
// default
moduleName
+
".mjs"
// ESM
d
@turansky I tried to remove the
commonWebpackConfig
and the
outputFileName
explicitely:
Copy code
js(IR) {
    moduleName = "cms"
    browser()
    binaries.executable()
}
but the name of the compiled js file became "jsApp.js", and not "cms.js" as you expected. It would be great if it worked the way you said, but unfortunately it doesn't.
t
Check result - I also do it in 2 places 😞
👍 1
And
outputFileName
works for me (except ESM)
d
Ok, it works like this:
Copy code
js(IR) {
    moduleName = "cms"
    browser {
        commonWebpackConfig (Action {
            outputFileName = "cms.js"
        })
    }
    binaries.executable()
}