Skip to content

KT-72838: [Gradle] Support websockets in webpack devServer proxy #5453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4686,21 +4686,23 @@ public final class org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackC
}

public final class org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackConfig$DevServer$Proxy : java/io/Serializable {
public fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;)V
public synthetic fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)V
public synthetic fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/List;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/util/Map;
public final fun component4 ()Ljava/lang/Boolean;
public final fun component5 ()Ljava/lang/Boolean;
public final fun copy (Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lorg/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackConfig$DevServer$Proxy;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackConfig$DevServer$Proxy;Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackConfig$DevServer$Proxy;
public final fun component6 ()Ljava/lang/Boolean;
public final fun copy (Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lorg/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackConfig$DevServer$Proxy;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackConfig$DevServer$Proxy;Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackConfig$DevServer$Proxy;
public fun equals (Ljava/lang/Object;)Z
public final fun getChangeOrigin ()Ljava/lang/Boolean;
public final fun getContext ()Ljava/util/List;
public final fun getPathRewrite ()Ljava/util/Map;
public final fun getSecure ()Ljava/lang/Boolean;
public final fun getTarget ()Ljava/lang/String;
public final fun getWs ()Ljava/lang/Boolean;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ data class KotlinWebpackConfig(
val pathRewrite: MutableMap<String, String>? = null,
val secure: Boolean? = null,
val changeOrigin: Boolean? = null,
val ws: Boolean? = null,
) : Serializable
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.jetbrains.kotlin.gradle.targets.js.webpack

import org.gradle.api.model.ObjectFactory
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.kotlin.gradle.targets.js.dsl.WebpackRulesDsl.Companion.webpackRulesContainer
import org.junit.Before
import org.junit.Test
import kotlin.test.assertContains

class KotlinWebpackConfigTest {
private lateinit var objects: ObjectFactory

@Before
fun setUp() {
val project = ProjectBuilder.builder().build()
objects = project.objects
}

@Test
fun testWebpackConfigOutputWithDefaults() {
val config = KotlinWebpackConfig(rules = objects.webpackRulesContainer())

val builder = StringBuilder()
config.appendTo(builder)

assertContains(
builder.toString(), """
let config = {
mode: 'development',
resolve: {
modules: [
"node_modules"
]
},
plugins: [],
module: {
rules: []
},

};
""".trimIndent()
)
}

@Test
fun testWebpackConfigOutputWithDevServerProxy() {
val config = KotlinWebpackConfig(
devServer = KotlinWebpackConfig.DevServer(
proxy = mutableListOf(
KotlinWebpackConfig.DevServer.Proxy(
context = mutableListOf("testContext"),
target = "testTarget",
ws = true,
changeOrigin = true,
)
),
), rules = objects.webpackRulesContainer()
)

val builder = StringBuilder()
config.appendTo(builder)

assertContains(
builder.toString(), """
// dev server
config.devServer = {
"open": true,
"proxy": [
{
"context": [
"testContext"
],
"target": "testTarget",
"changeOrigin": true,
"ws": true
}
]
};
""".trimIndent()
)
}
}