Closed snrostov closed 5 years ago
Fixes #117
Similar problem. JsMainApi, JsMainImplementation ... configuration (test configuration i thing too) dependencies are not added to package.json. Therefore, i get build failures like:
ERROR` in ./shared-common.js
Module not found: Error: Can't resolve 'kotlinx-serialization-runtime-js' in '/home/michel/project/scape-system/shared/shared-common/build/js'
@ ./shared-common.js 970:37-80
@wem Can you please share your project? It is working in PR's example and test: kotlin
and kotlin-test
dependencies are added to build/package.json
.
I just started to migrate. You can use the Gradle project under shared/shared-common. That's the project i tested.
FYI ... I did merge my PR's too, but there should be no difference i think.
Thanks for sharing. I have verified your project with kotlin-frontend-plugin
from this branch and it is working as expected:
{
"name": "shared-common",
"version": "0.0.0",
"description": "simple description",
"main": "shared-common",
"dependencies": {
"uuidv5": "*",
"kotlinx-serialization-runtime-js": "0.9.1",
"kotlin-logging": "1.6.22",
"kotlin": "1.3.10",
"kotlin-test": "1.3.10"
},
"devDependencies": {
"karma": "*",
"karma-webpack": "*",
"webpack": "*",
"karma-chrome-launcher": "*",
"karma-teamcity-reporter": "*",
"webpack-cli": "*",
"webpack-dev-server": "*"
}
}
(I replaced your repositories with mavenLocal()
, mavenCentral()
, and maven { url "https://kotlin.bintray.com/kotlinx"}
).
Note that settings you are applу to compileKotlinJs
/compileTestKotlinJs
will not be applied to compile tasks that are created by kotlin-multiplatform
. To do that you should write something like this:
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js') {
configure(compilations.main) {
tasks.getByName(compileKotlinTaskName).kotlinOptions {
metaInfo = !production
outputFile = "${project.buildDir}/js/${project.name}.js"
sourceMap = !production
moduleKind = 'commonjs'
main = "call"
sourceMapEmbedSources = "always"
}
}
configure(compilations.test) {
tasks.getByName(compileKotlinTaskName).kotlinOptions {
metaInfo = true
sourceMap = true
moduleKind = 'commonjs'
sourceMapEmbedSources = "always"
}
}
}
}
...
Damn :) ... i forgot the compile task names. Thx!