From the kotlin-frontend-plugin new-mpp example.
If i use a webpack config, webpack pukes on the multiplatform imports.
build.gradle
plugins {
id 'kotlin-multiplatform' version '1.3.21'
id 'org.jetbrains.kotlin.frontend' version '0.0.45'
}
repositories {
jcenter()
maven { url "https://dl.bintray.com/kotlin/ktor" }
mavenCentral()
}
def ktor_version = '1.0.0'
def logback_version = '1.2.3'
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js') {
configure([compilations.main, compilations.test]) {
tasks.getByName(compileKotlinTaskName).kotlinOptions {
sourceMap = true
moduleKind = "commonjs"
metaInfo = true
}
}
configure(compilations.main) {
tasks.getByName(compileKotlinTaskName).kotlinOptions {
main = "call"
}
}
}
}
sourceSets {
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
}
commonTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-common'
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
}
}
jvmMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation "io.ktor:ktor-server-jetty:$ktor_version"
implementation "io.ktor:ktor-html-builder:$ktor_version"
implementation "ch.qos.logback:logback-classic:$logback_version"
}
}
jvmTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
jsMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
}
}
jsTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-js'
}
}
}
}
kotlinFrontend {
npm {
dependency("css-loader")
dependency("style-loader")
dependency("gl-matrix", "3.0.0")
dependency("common-js", "0.3.8")
dependency("react-mapbox-gl-cluster", "0.1.10")
dependency("webpack-cli", "v2.0.12")
/* dependency("firebase", "^4.6.2")*/
dependency("react", "16.6.0")
dependency("react-dom", "16.6.0")
dependency("react-router-dom", "4.2.2")
dependency("axios", "0.18.0")
dependency("react-modal", "^3.6.1")
dependency("react-quill", "^1.3.2")
dependency("react-mapbox-gl", "4.2.0")
dependency("html-react-parser", "^0.4.7")
dependency("react-map-gl", "4.0.10")
dependency("uuid")
dependency("query-string", "^6.2.0")
dependency("geolocation", "0.2.0")
}
sourceMaps = true
webpackBundle {
bundleName = "main"
proxyUrl = "http://localhost:8080"
webpackConfigFile = "webpack.config.js"
}
}
ktor {
port = 8080
mainClass = "io.ktor.server.jetty.EngineMain"
}
webpack.config.js
config = require('./build/WebPackHelper.js');
var path = require('path');
module.exports = {
entry: config.moduleName,
output: {
path: path.resolve('./bundle'),
publicPath: '/build/',
filename: 'main.bundle.js'
},
resolve: {
modules: [ path.resolve('js'), path.resolve('..', 'src'), path.resolve('.'), path.resolve('node_modules') ],
extensions: ['.js', '.css']
},
module: {
rules: [
{ test: /\.css$/, use: [ 'style-loader', 'css-loader' ] }
]
},
devtool: '#source-map',
};
console.log(module.exports.resolve.modules);
any ideas on how to get this working?