My Kotlin/JS projects don't work after upgrade fro...
# javascript
r
My Kotlin/JS projects don't work after upgrade from Kotlin 1.5.0 to Kotlin 1.5.10 because
build.gradle.kts
doesn't compile. What happened?
Copy code
* What went wrong:
Script compilation errors:

  Line 35:                     proxy = mapOf(
                                       ^ Type mismatch: inferred type is Map<String, Any> but MutableMap<String, Any>? was expected

  Line 39:                     contentBase = listOf("$buildDir/processedResources/js/main")
                                             ^ Type mismatch: inferred type is List<String> but MutableList<String>? was expected

2 errors
I'm on Gradle 6.9
It works fine when I go back to 1.5.0
It fails on DevServer configuration in gradle:
Copy code
devServer = KotlinWebpackConfig.DevServer(
                    open = false,
                    port = 3000,
                    proxy = mapOf(
                        "/kv/*" to "<http://localhost:8080>",
                        "/kvws/*" to mapOf("target" to "<ws://localhost:8080>", "ws" to true)
                    ),
                    contentBase = listOf("$buildDir/processedResources/js/main")
                )
It compiles when I remove both
proxy
and
contentBase
options.
c
i think DevServer is private, i had that problem months ago
r
Change mapOf to mutableMapOf and listOf to mutableListOf at the indicated lines.
1
The types changed in the gradle dsl there for some reason
c
the supported way to do what you want is via webpack.config.d
something like
Copy code
config.devServer = Object.assign(
    {},
    config.devServer || {},
    {
        port: 3000,
        proxy: {
            '/api': {
                target: '<http://localhost:8080>',
                logLevel: 'debug'
            }
        }
    }
)
r
It's not private
but it's now annotated
@Suppress("unused")
t
It works fine with following patch
r
A breaking change for my projects in the patch release ... ;-(
t
New major dev-server release required for this issue
And it must work without patches
cc @Ilya Goncharov [JB]
Looks like port configuration required only. Issue already exists
Also I see invalid
static
parameter configuration. Unexisted folder declared
r
Do I understand correctly I need to replace
contentBase = listOf(...)
with
static = mutableListOf(...)
in my build.gradle.kts and it should work again with new dev server version?
👌 1
I love documenting breaking changes in my migration guide every minor release 😉
t
1 Kotlin release ~= 20 Webpack releases
1.5.10
- second step of migration to Webpack 5, but not final. Dev server API isn’t stable