Giter Site home page Giter Site logo

Comments (5)

rjaros avatar rjaros commented on July 28, 2024

This is the main reason: https://youtrack.jetbrains.com/issue/KTOR-1084/Kotlin-JS-Ktor-client-adds-too-much-size-to-a-compiled-JS-file

from kvision.

CodeServant avatar CodeServant commented on July 28, 2024

I did some tests and this seems not an issue now.

the size of my bundle.js is:
2 032 KB my own project without modifications (with kvsion stuff, kotlinx-datetime, kotlin-serialization)
2 338 KB after creating empty ktor Client
2 362 KB after adding auth and configuration of basic auth
2 444 KB after defining cookies and cache and Charsets
2 479 KB after installing logging

my methodology

requirements:

windows 10
kotlin = 2.0.0-Beta4
kvision = 7.4.3
ktor client = 2.3.9
gradle wrapper = 8.6

gradle command

.\gradlew clean jsBrowserDistribution

the added script looks like this

private suspend fun createFuss() {
    val client = HttpClient(Js) {
        install(Auth) {
            basic {
                credentials {
                    BasicAuthCredentials(username = "jetbrains", password = "foobar")
                }
                realm = "Access to the '/' path"
            }
        }
        install(HttpCookies) {
            storage = ConstantCookiesStorage(Cookie(name = "user_name", value = "jetbrains", domain = "0.0.0.0"))
        }
        install(HttpCache)
        Charsets {
            register(Charsets.UTF_8)
            register(Charsets.ISO_8859_1, quality = 0.1f)
        }
        install(Logging)
    }
}

gradle dependencies

...
val ktorVersion = "2.3.9"
implementation("io.ktor:ktor-client-js:$ktorVersion")
implementation("io.ktor:ktor-client-logging-js:$ktorVersion")
implementation("io.ktor:ktor-client-auth:$ktorVersion")
...

and here are imports I've added

import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.logging.*
import io.ktor.client.engine.js.*
import io.ktor.client.plugins.Charsets
import io.ktor.client.plugins.auth.*
import io.ktor.client.plugins.auth.providers.*
import io.ktor.client.plugins.cache.*
import io.ktor.client.plugins.cookies.*
import io.ktor.http.*
import io.ktor.utils.io.charsets.*
...

other test

did the test with this too, and my bundle.js is 422 KB so it's pretty decent.

What do you think? Are the tests valid for KVision?

from kvision.

rjaros avatar rjaros commented on July 28, 2024

In general nothing stops you from using Ktor client. KVision REST client is totally optional. If you prefer Ktor and don't mind a bit larger bundle size, you can use it without any problems. So the question is - what kind of integration do you think of?

from kvision.

CodeServant avatar CodeServant commented on July 28, 2024

I thought it would enable more feature out of the box and limit those that are actually duplicated like rest api calls. Since it is Jetbrains, this will get official support and in the end it should be easier to maintain.

from kvision.

rjaros avatar rjaros commented on July 28, 2024

But KVision doesn't use rest api calls internally. So there is nothing to replace. Of course we could drop kvision-rest module, but it would only break compatibility with existing apps.

The fullstack interfaces are based on fetch api directly and it would be probably to complicated to use ktor client instead.

So in the end I think currently there is nothing to do with this issue. Everyone is free to use Ktor client with KVision apps.

from kvision.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.