question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't compile project with Ktor JS client because of webpack errors

See original GitHub issue

Ktor Version and Engine Used (client or server and name) io.ktor:ktor-client-js 1.3.0-beta-1 and 1.2.5

Describe the bug Webpack “Module not found” errors are thrown.

Logs:

  WARNING in .._imported/ktor-ktor-client-core/1.3.0-beta-1/ktor-ktor-client-core.js 12165:13-32
  Critical dependency: the request of a dependency is an expression
   @ ./kotlin/gaia.js
   @ multi ./kotlin/gaia.js source-map-support/browser-source-map-support.js
  
  WARNING in .._imported/ktor-ktor-client-core/1.3.0-beta-1/ktor-ktor-client-core.js
  Module not found: Error: Can't resolve 'ws' in 'C:\Users\Daan\code\gaia\build\js\packages_imported\ktor-ktor-client-core\1.3.0-beta-1'
   @ .._imported/ktor-ktor-client-core/1.3.0-beta-1/ktor-ktor-client-core.js
   @ ./kotlin/gaia.js
   @ multi ./kotlin/gaia.js source-map-support/browser-source-map-support.js
  
  ERROR in .._imported/ktor-ktor-io/1.3.0-beta-1/ktor-ktor-io.js
  Module not found: Error: Can't resolve 'text-encoding' in 'C:\Users\Daan\code\gaia\build\js\packages_imported\ktor-ktor-io\1.3.0-beta-1'
   @ .._imported/ktor-ktor-io/1.3.0-beta-1/ktor-ktor-io.js 20149:21-45 20217:21-45
   @ .._imported/ktor-ktor-client-json/1.3.0-beta-1/ktor-ktor-client-json.js
   @ ./kotlin/gaia.js
   @ multi ./kotlin/gaia.js source-map-support/browser-source-map-support.js

To Reproduce Steps to reproduce the behavior:

  1. Add the io.ktor:ktor-client-js dependency to a Kotlin multi-platform project
  2. Run ./gradlew jsBrowserWebpack
  3. See errors

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:10

github_iconTop GitHub Comments

4reactions
MMauro94commented, Apr 17, 2020

@edvorg Yep, that fixed it! Many thanks! I was able to perform a simple hello world with web sockets.

My build.gradle now looks like this:

kotlin {
    js {
        browser {
            dceTask {
                keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
            }
        }
    }
    //...
    sourceSets {
        //...
        jsMain {
            dependencies {
                implementation kotlin('stdlib-js')

                implementation "io.ktor:ktor-client-js:$ktor_version"
                implementation "io.ktor:ktor-client-websockets-js:$ktor_version"
                implementation(npm("text-encoding", "0.7.0"))
                implementation(npm("abort-controller", "3.0.0"))
            }
        }
    }
4reactions
bjonnhcommented, Dec 17, 2019

text-encoding is now unmaintained: https://www.npmjs.com/package/text-encoding

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack fails with 'Module not found' for Kotlin 1.5.0 and ktor ...
I'm getting the following error in my multiplatform project (see attached):. * What went wrong: Execution failed for task ':jsBrowserDevelopmentWebpack'.
Read more >
nextJS build fails on Vercel because of Webpack errors
When I attempted to import a Comment component into a page I was getting Vercel build errors: Failed to compile. ./pages/{mypage.js} Module not ......
Read more >
WhatsNew 1.6 | Ktor Framework
Infrastructure: Build with JDK 11 for all modules fails: Can't inline metric micrometer because it uses jvm target 8.
Read more >
GraphQL Code Libraries, Tools and Services
A simple JavaScript GraphQL client,Let the *.gql file be used as a module through webpack loader. Tools. GraphiQL. GitHubgraphql/ ...
Read more >
Migrating our Kotlin/JS app to the new IR compiler
The IR compiler for Kotlin/JS comes with a lot of benefits for ... all the libraries we are using in the project (including...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found