Sean Keane
03/03/2020, 2:32 PMSebastian Aigner
03/03/2020, 3:23 PMSean Keane
03/03/2020, 3:33 PMval
and cannot be reassigned. Im trying to point it to my webpack.config.d but not sure where to place it or how to even override its location.
At the moment my webpack file is located in src -> jsMain -> resources
This is the method im using to update the dir, but I think I should be using the Entry
var instead
open val configDirectory: File?
@Optional @InputDirectory get() = project.projectDir.resolve("webpack.config.d").takeIf { it.isDirectory }
Sebastian Aigner
03/03/2020, 3:42 PMwebpack.config.d
folder goes into the root of your project, with the additions you want to have for your target, with a file called 01.projectname.js
– you could try if it works the same for multiplatform (as I infer from your jsMain
. @Ilya Goncharov [JB] – is it possible to set the webpack.config.d
location via Gradle DSL already?Ilya Goncharov [JB]
03/03/2020, 3:45 PMwebpack.config.d
is hardcoded yetSean Keane
03/03/2020, 3:45 PMwebpack.config.d
file there for nowturansky
03/03/2020, 4:09 PMSean Keane
03/03/2020, 4:13 PMcommon.js
lib. What I have noticed since, is webpack seems to be creating its own config and ignoreing the one I have placed in the path. I would like to know how I can override it so I can then point webpack to use the unpack’d jar libs and then treeshake those or use the DCE’d version.Sean Keane
03/03/2020, 4:20 PMturansky
03/03/2020, 4:22 PMcommonjs
by default) https://github.com/turansky/kfc-plugins#librarySean Keane
03/03/2020, 4:24 PMturansky
03/03/2020, 4:24 PMdistribution
for npm.Sean Keane
03/03/2020, 4:24 PMturansky
03/03/2020, 4:24 PM1.3.70
Sean Keane
03/03/2020, 4:25 PMturansky
03/03/2020, 4:25 PMturansky
03/03/2020, 4:26 PMmaven-publish
for publication?Sean Keane
03/03/2020, 4:27 PMSean Keane
03/03/2020, 4:27 PMSean Keane
03/03/2020, 4:29 PMturansky
03/03/2020, 4:30 PMturansky
03/03/2020, 4:31 PMIlya Goncharov [JB]
03/03/2020, 4:35 PMumd
library target, so you may not need some additional configuration to use it as JavaScript library. It is consistent with webpack atricle about Authoring libraries
Sean Keane
03/03/2020, 4:37 PM.js
files?Ilya Goncharov [JB]
03/03/2020, 4:39 PMbuild/distributions
and it is compatible to run as an application, and as using as js librarySean Keane
03/03/2020, 4:40 PMbuild/distributions
block? When I tried that I was getting issues earlier. I will retrySean Keane
03/03/2020, 4:41 PMturansky
03/03/2020, 4:43 PMlibrary
extension now enabled for js
plugin onlySean Keane
03/03/2020, 4:44 PMIlya Goncharov [JB]
03/03/2020, 4:44 PMSo I can just npm publishYou need add some kind of
package.json
and another npm stuff, but js is compatible to be npm package, yesturansky
03/03/2020, 4:44 PM1.3.70
, than DCE plugin is redundant in your exampleSean Keane
03/03/2020, 4:46 PMturansky
03/03/2020, 4:47 PMjs.map
is biggest?Sean Keane
03/03/2020, 4:47 PMturansky
03/03/2020, 4:48 PMSean Keane
03/03/2020, 4:48 PMturansky
03/03/2020, 4:49 PMSean Keane
03/03/2020, 4:50 PMturansky
03/03/2020, 4:50 PMSean Keane
03/03/2020, 4:51 PMturansky
03/03/2020, 4:51 PMIlya Goncharov [JB]
03/03/2020, 4:54 PMSean Keane
03/03/2020, 4:54 PMUncaught TypeError: m is not a function
at Object.l (WebSocketSession.kt:24)
at Object.<anonymous> (Chars.kt:35)
at e (bootstrap:19)
at Object.<anonymous> (collections.kt:15)
at e (bootstrap:19)
at Object.<anonymous> (_Collections.kt:1408)
at e (bootstrap:19)
at Object.<anonymous> (_Collections.kt:1408)
at e (bootstrap:19)
at bootstrap:83
Ilya Goncharov [JB]
03/03/2020, 4:56 PMSean Keane
03/03/2020, 4:56 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.multiplatform")
id("org.jetbrains.kotlin.native.cocoapods")
}
kotlin {
cocoapods {
summary = "Shared Code for Android and iOS"
homepage = "Link to a Kotlin/Native module homepage"
}
android()
js() {
targets {
browser {
@Suppress("EXPERIMENTAL_API_USAGE")
dceTask {
keep("kotlin.defineModule")
}
}
}
}
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
compilations {
val main by getting {
kotlinOptions.freeCompilerArgs = listOf("-Xobjc-generics")
}
}
}
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Versions.coroutinesCore}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Versions.serializationCommon}")
implementation("io.ktor:ktor-client-core:${Versions.ktor}")
implementation("io.ktor:ktor-client-json:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization:${Versions.ktor}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
}
sourceSets["iosMain"].dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.coroutinesCore}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.serializationCommon}")
implementation("io.ktor:ktor-client-ios:${Versions.ktor}")
implementation("io.ktor:ktor-client-json-native:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization-native:${Versions.ktor}")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
sourceSets["jsMain"].dependencies {
implementation(kotlin("stdlib-js"))
implementation("io.ktor:ktor-client-js:${Versions.ktor}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Versions.coroutinesCore}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Versions.serializationCommon}")
implementation(npm("text-encoding"))
}
}
android {
compileSdkVersion(App.compileSdk)
sourceSets {
getByName("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
java.srcDirs("src/androidMain/kotlin")
res.srcDirs("src/androidMain/res")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutinesCore}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.serializationCommon}")
implementation("io.ktor:ktor-client-android:${Versions.ktor}")
implementation("io.ktor:ktor-client-json-jvm:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization-jvm:${Versions.ktor}")
implementation("androidx.lifecycle:lifecycle-extensions:${Versions.lifecycleVersion}")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.lifecycleVersion}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("androidx.core:core-ktx:+")
}
Ilya Goncharov [JB]
03/03/2020, 4:57 PMSean Keane
03/03/2020, 4:57 PMSean Keane
03/03/2020, 4:59 PMSean Keane
03/03/2020, 5:23 PMSean Keane
03/03/2020, 5:35 PM/*!*****************************************!*\
!*** ./kotlin-dce/common.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) {
if (true)
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(/*! kotlin */ "./kotlin-dce/kotlin.js"), __webpack_require__(/*! ktor-ktor-client-core */ "./kotlin-dce/ktor-ktor-client-core.js"), __webpack_require__(/*! kotlinx-coroutines-core */ "./kotlin-dce/kotlinx-coroutines-core.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
else {}
}(this, function (_, Kotlin, $module$ktor_ktor_client_core, $module$kotlinx_coroutines_core) {
'use strict';
var $$importsForInline$$ = _.$$importsForInline$$ || (_.$$importsForInline$$ = {});
var Kind_CLASS = Kotlin.Kind.CLASS;
var Kind_INTERFACE = Kotlin.Kind.INTERFACE;
var getKClass = Kotlin.getKClass;
var createKType = Kotlin.createKType;
var Unit = Kotlin.kotlin.Unit;
var COROUTINE_SUSPENDED = Kotlin.kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED;
var CoroutineImpl = Kotlin.kotlin.coroutines.CoroutineImpl;
var coroutines = $module$kotlinx_coroutines_core.kotlinx.coroutines;
var lazy = Kotlin.kotlin.lazy_klfg04$;
var takeFrom = $module$ktor_ktor_client_core.$$importsForInline$$['ktor-ktor-http'].io.ktor.http.takeFrom_jl1sg7$;
var utils = $module$ktor_ktor_client_<http://core.io|core.io>.ktor.client.utils;
var url = $module$ktor_ktor_client_<http://core.io|core.io>.ktor.client.request.url_3rzbk2$;
var HttpMethod = $module$ktor_ktor_client_core.$$importsForInline$$['ktor-ktor-http'].io.ktor.http.HttpMethod;
var HttpRequestBuilder_init = $module$ktor_ktor_client_<http://core.io|core.io>.ktor.client.request.HttpRequestBuilder;
var HttpStatement_init = $module$ktor_ktor_client_<http://core.io|core.io>.ktor.client.statement.HttpStatement;
var throwCCE = Kotlin.throwCCE;
var equals = Kotlin.equals;
var HttpResponse = $module$ktor_ktor_client_<http://core.io|core.io>.ktor.client.statement.HttpResponse;
var complete = $module$ktor_ktor_client_<http://core.io|core.io>.ktor.client.statement.complete_abn2de$;
var call = $module$ktor_ktor_client_core.io.ktor.client.call;
var TypeInfo_init = $module$ktor_ktor_client_core.io.ktor.client.call.TypeInfo;
var to = Kotlin.kotlin.to_ujzrz7$;
var mapOf = Kotlin.kotlin.collections.mapOf_qfcya0$;
var listOf = Kotlin.kotlin.collections.listOf_i5x0yv$;
var copyToArray = Kotlin.kotlin.collections.copyToArray;
var hello;
var testMap;
var testList;
var testType;
$$importsForInline$$['ktor-ktor-client-core'] = $module$ktor_ktor_client_core;
hello = 'HELLO WORLD';
testMap = mapOf([to('char', 'x'), to('char2', 'y'), to('string', 'zz')]);
testList = listOf(['Hello', 'World']);
testType = ['hello', 'javascript'];
return _;
}));
turansky
03/03/2020, 5:39 PMSean Keane
03/03/2020, 6:20 PMSean Keane
03/03/2020, 8:48 PMEivind Nilsbakken
03/03/2020, 9:00 PMkeep("kotlin.defineModule")
with keep("multiplatform-lib.hello")
.Eivind Nilsbakken
03/03/2020, 9:02 PMkeep("multiplatform-lib")
will work too. They updated the docs on this now: https://kotlinlang.org/docs/reference/javascript-dce.html#excluding-declarations-from-dceIlya Goncharov [JB]
03/03/2020, 9:02 PMkeep(“test-multiplatform-lib.hello”)
In usual case, you don’t need to keep <http://Kotlin.de|Kotlin.de>fineModule
It can be safely removed by DCESean Keane
03/03/2020, 9:45 PMSean Keane
03/04/2020, 9:30 AMEivind Nilsbakken
03/04/2020, 9:41 AMfactory(module.exports, require('kotlin'), require('kotlinx-serialization-kotlinx-serialization-runtime'), require('ktor-ktor-client-core'), require('kotlinx-coroutines-core'), require('ktor-ktor-client-json'), require('ktor-ktor-client-serialization'));
DCE-ed versions of those libraries are in the same directory, but not used at all, it seems.Sean Keane
03/04/2020, 10:39 AMEivind Nilsbakken
03/04/2020, 10:42 AMwebpack.config.js
adds the kotlin-dce
directory to config.resolve.modules
. In theory, that should work. 🤔Eivind Nilsbakken
03/04/2020, 10:43 AMIlya Goncharov [JB]
03/04/2020, 10:44 AMSean Keane
03/04/2020, 10:44 AMwebpack.config.js
file in the root and override the methods from there.Sean Keane
03/04/2020, 10:44 AM