andrewreitz
05/05/2020, 10:07 PMturansky
05/05/2020, 11:36 PM1.4-M1
?andrewreitz
05/06/2020, 12:37 AMturansky
05/06/2020, 12:54 AMturansky
05/06/2020, 12:57 AMbuild/distributions
( location of optimized JS without dependencies)andrewreitz
05/06/2020, 1:10 AMproduceExecutable
do?turansky
05/06/2020, 1:10 AMturansky
05/06/2020, 1:10 AMandrewreitz
05/06/2020, 1:12 AMandrewreitz
05/06/2020, 1:13 AMkotlin.js.compiler=ir
turansky
05/06/2020, 1:13 AMturansky
05/06/2020, 1:14 AM@JsExport
turansky
05/06/2020, 1:14 AMandrewreitz
05/06/2020, 1:14 AMandrewreitz
05/06/2020, 1:15 AMandrewreitz
05/06/2020, 1:15 AMandrewreitz
05/06/2020, 1:15 AMturansky
05/06/2020, 1:17 AMmain
method inside?andrewreitz
05/06/2020, 1:18 AMexternal val exports: dynamic
to make exportsturansky
05/06/2020, 1:20 AMturansky
05/06/2020, 1:23 AMandrewreitz
05/06/2020, 1:25 AMandrewreitz
05/06/2020, 1:25 AMandrewreitz
05/06/2020, 1:27 AMandrewreitz
05/06/2020, 1:27 AMandrewreitz
05/06/2020, 1:27 AMTypeError: controller is not a constructor
at AbortController_0
andrewreitz
05/06/2020, 1:29 AMturansky
05/06/2020, 1:36 AMandrewreitz
05/06/2020, 1:36 AMkeep("ktor-ktor-io.\$\$importsForInline\$\$.<http://ktor-ktor-io.io.ktor.utils.io|ktor-ktor-io.io.ktor.utils.io>")
in the docs didn’t seem to helpandrewreitz
05/06/2020, 1:37 AMturansky
05/06/2020, 1:38 AMturansky
05/06/2020, 1:39 AMkeep
andrewreitz
05/06/2020, 1:39 AMandrewreitz
05/06/2020, 1:40 AMdceOptions.devMode = true
I had that set and was seeing all sorts of funny issues too so I think it might just be the setupturansky
05/06/2020, 1:44 AMturansky
05/06/2020, 1:45 AMAbortController
for browser only?andrewreitz
05/06/2020, 1:48 AMandrewreitz
05/06/2020, 1:50 AMturansky
05/06/2020, 1:51 AMandrewreitz
05/06/2020, 1:52 AMandrewreitz
05/06/2020, 1:53 AMproduceExecutable
end up producing? And binary file?turansky
05/06/2020, 1:54 AMturansky
05/06/2020, 1:55 AMbuild/distributions
andrewreitz
05/06/2020, 1:55 AMandrewreitz
05/06/2020, 1:55 AMturansky
05/06/2020, 2:01 AMandrewreitz
05/06/2020, 2:03 AMturansky
05/06/2020, 2:05 AMandrewreitz
05/06/2020, 2:05 AMandrewreitz
05/06/2020, 2:06 AMandrewreitz
05/06/2020, 2:06 AMturansky
05/06/2020, 2:07 AMandrewreitz
05/06/2020, 2:07 AMturansky
05/06/2020, 2:09 AMand I dont’ think there is a way for me to tell webpack to not use thoseIt’s possible in common case 🙂
turansky
05/06/2020, 2:10 AMbrowser
target as pseudo-node
turansky
05/06/2020, 2:11 AMandrewreitz
05/06/2020, 2:11 AMandrewreitz
05/06/2020, 2:13 AMnode-fetch
turansky
05/06/2020, 2:15 AMturansky
05/06/2020, 2:15 AMnode-fetch
- NPM dependency?andrewreitz
05/06/2020, 2:15 AMThe Js engine, uses the fetch API internally(and node-fetch for node.js runtime).
They must do something to swap those, maybe dce/webpack is removing the node path?andrewreitz
05/06/2020, 2:16 AMturansky
05/06/2020, 2:17 AMnode-fetch
declared in your Gradle script?andrewreitz
05/06/2020, 2:19 AMandrewreitz
05/06/2020, 2:25 AMandrewreitz
05/06/2020, 2:25 AMdceOptions.devMode = true
andrewreitz
05/06/2020, 2:33 AMkeep("abort-controller.AbortController")
should hopefully fix itturansky
05/06/2020, 2:35 AMandrewreitz
05/06/2020, 2:41 AMandrewreitz
05/06/2020, 2:42 AM@JsModule("abort-controller")
external object AbortController {
fun constructor(): dynamic
}
fun main() {
val a = AbortController.constructor()
requireNotNull(a)
}
added this to my code and it works fineandrewreitz
05/06/2020, 2:42 AMandrewreitz
05/06/2020, 2:54 AMval controller = js("require('abort-controller')")
js("new controller()")
turansky
05/06/2020, 3:05 AM// valid declaration
@JsModule("abort-controller")
external class AbortController()
turansky
05/06/2020, 3:05 AMandrewreitz
05/06/2020, 3:09 AMandrewreitz
05/06/2020, 3:10 AMfunction main() {
var controller = __webpack_require__(/*! abort-controller */ "../../node_modules/abort-controller/dist/abort-controller.mjs");
console.log(controller)
new controller();
}
that’s the output with webpack set to development mode
this is the output of the log statment
> Object [Module] {
> AbortController: [Getter],
> AbortSignal: [Getter],
> default: [Function: AbortController]
> }
andrewreitz
05/06/2020, 3:11 AMdceOptions.devMode = true
andrewreitz
05/06/2020, 3:14 AM@JsModule("abort-controller")
external class AbortController
fun main() {
val c = AbortController()
}
has the same issue!andrewreitz
05/06/2020, 3:15 AMDavid Eriksson
05/06/2020, 6:44 AMIlya Goncharov [JB]
05/06/2020, 7:29 AMimplementation(npm(“abort-controller”))
turansky
05/06/2020, 9:34 AMIlya Goncharov [JB]
05/06/2020, 9:38 AMtext-encoding
As I remember, these 2 npm dependencies enough.Ilya Goncharov [JB]
05/06/2020, 9:39 AMpackage.json
and will include information about npm dependencies.andrewreitz
05/06/2020, 10:48 AMandrewreitz
05/06/2020, 12:53 PMturansky
05/06/2020, 2:47 PMandrewreitz
05/06/2020, 2:50 PMandrewreitz
05/06/2020, 2:51 PMandrewreitz
05/06/2020, 4:32 PMturansky
05/06/2020, 5:02 PMnodejs
-> nodejs()
turansky
05/06/2020, 5:06 PMMain.kt
turansky
05/06/2020, 5:07 PMkeep("ktor-abort-controller-issue")
andrewreitz
05/06/2020, 5:21 PMdceOptions.devMode = true
but on top of all that, that implementation has the same issue. 😞turansky
05/06/2020, 5:29 PMandrewreitz
05/06/2020, 5:52 PMturansky
05/06/2020, 5:57 PMandrewreitz
05/06/2020, 6:25 PMandrewreitz
05/06/2020, 6:25 PMturansky
05/06/2020, 6:27 PMturansky
05/06/2020, 6:30 PMid("com.github.turansky.kfc.webpack") version "0.8.5"
2. Add custom abort-handler.js
to src/main/resources
3. PROFIT - local abort-handler.js
used by webpackandrewreitz
05/06/2020, 6:32 PMandrewreitz
05/06/2020, 6:32 PMandrewreitz
05/06/2020, 6:41 PMturansky
05/06/2020, 6:44 PMturansky
05/06/2020, 6:45 PMis there a way to tell webpack the one to use that’s in the dist folder of abort-controler/distYou can copy it for test
andrewreitz
05/06/2020, 6:45 PMandrewreitz
05/06/2020, 6:45 PMturansky
05/06/2020, 6:49 PMturansky
05/06/2020, 6:52 PMtasks.compileKotlinJs {
doLast {
// copy abort-controller.js
// to `build/js/packages/ktor-abort-controller-issue/kotlin-dce`
// first webpack folder
}
}
andrewreitz
05/06/2020, 6:59 PMturansky
05/06/2020, 7:06 PMandrewreitz
05/07/2020, 12:00 PMIlya Goncharov [JB]
05/07/2020, 12:11 PMDavid Eriksson
05/07/2020, 12:12 PMIlya Goncharov [JB]
05/07/2020, 12:15 PMandrewreitz
05/07/2020, 1:00 PMandrewreitz
05/08/2020, 2:09 PMturansky
05/08/2020, 2:12 PMandrewreitz
05/08/2020, 7:09 PMandrewreitz
05/17/2020, 4:38 PMDarren Bell
05/24/2021, 10:43 AM