Hi, I have a problem with webpack build within a m...
# javascript
k
Hi, I have a problem with webpack build within a multiplatform project. The frontend build fails with the following error:
Copy code
Execution failed for task ':jsBrowserProductionWebpack'.
>                 Process 'webpack' returns 2
I've narrowed the problem down to the usage of
io.ktor.client.HttpClient
class. This error appears if I instantiate it or obtain its reflection descriptor in any part of the js source set and goes away if I remove all references of this class from the source set. My Kotlin multiplatform plugin version is
1.3.71
and Ktor version is
1.3.2
. I have dependencies on both
io.ktor:ktor-client-core
and
io.ktor:ktor-client-js
in my jsMain source set. Any help is appreciated - maybe anyone has ideas on why this is happening or at least how to gain more insight into what is happening during the webpack build.
I was able to reproduce this problem in a smaller test project, and for some reason I've got a detailed output from webpack there. It turned out to be the same as described here https://github.com/ktorio/ktor/issues/961#issuecomment-602081220.
I was able to get rid of most of these errors by adding explicit npm dependencies for
text-encoding
,
bufferutil
,
utf-8-validate
and
abort-controller
. But one more error still remains and I don't know what to do about it:
Copy code
ERROR in C:/Projects/Spike/build/js/node_modules/node-gyp-build/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\Projects\Spike\build\js\node_modules\node-gyp-build'
 @ C:/Projects/Spike/build/js/node_modules/node-gyp-build/index.js 1:9-22
 @ C:/Projects/Spike/build/js/node_modules/utf-8-validate/index.js
 @ C:/Projects/Spike/build/js/node_modules/ws/lib/Validation.js
 @ C:/Projects/Spike/build/js/node_modules/ws/lib/Receiver.js
 @ C:/Projects/Spike/build/js/node_modules/ws/index.js
 @ ./kotlin-dce/ktor-ktor-client-core.js
 @ ./kotlin-dce/Spike.js
 @ multi ./kotlin-dce/Spike.js
r
Sounds similar to what I was seeing here https://github.com/ktorio/ktor/issues/1724
k
Yep, looks the same. Looks like ktor http client just doesn't work with js target currently, so I'll look for alternatives
i
fs
is module related with file system, and available only with usage in NodeJS environment