It seems once again Kotlin/JS is broken because of some new npm dependency.
r
It seems once again Kotlin/JS is broken because of some new npm dependency.
đŸ€” 3
😿 6
Copy code
[webpack-cli] Unable to load '@webpack-cli/serve' command
[webpack-cli] TypeError: options.forEach is not a function
[webpack-cli] TypeError: options.forEach is not a function
    at WebpackCLI.makeCommand (/home/rjaros/git/kt47832/build/js/node_modules/webpack-cli/lib/webpack-cli.js:173:21)
Anyone can confirm?
This seems to be a workaround for Kotlin/JS projects:
Copy code
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
    rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().apply {
        resolution("@webpack-cli/serve", "1.5.2")
    }
}
🙏 1
👍 5
đŸ‘đŸ» 1
e
Can confirm, started to error for me roughly 10 hours ago
➕ 3
p
Happened to me right now, the workaround helped.
i
@Robert Jaros Thank you for the information! I will create an issue in YT and add your workaround
p
shouldn't some kind of lockfile prevent such situations?
are NPM dependencies closed/locked like in Maven Central, so that noone can change it without bumping versions? it would also prevent such cases
r
You can't do anything about this on Kotlin side, as this is a bug in the
webpack-cli
project.
We just have to continue to love the JS ecosystem 😉
đŸ€Ł 6
p
FTR, the lockfile approach to avoid such surprises is somewhat possible (not perfect, but still it's there), see https://youtrack.jetbrains.com/issue/KT-34014
p
@Robert Jaros Thank you for providing the work-around. How would you translate this snippet to a groovy gradle.build? Thanks in advance!
Ok figured it out myself:
Copy code
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin) {
    var ext = rootProject.extensions.findByType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension)
    ext.resolution("@webpack-cli/serve", "1.5.2")
}
Works for the moment...
t