Bradleycorn
05/14/2021, 7:30 PMpackage.json
files have a few problems:
1. they have dependencies with “hardcoded” absolute file paths, like: "kotlin": "file:/Users/brad.ball/dev/multiplatform/new/wager-utils/build/js/packages_imported/kotlin/1.5.0",
2. the dependencies list contains entries for kotlin-test-js-runner
and kotlin-test
. Why would those be dependencies for a published package? Seems like at best they should be devDependencies.
With the hard coded file paths, you can’t really publish the package or use it anywhere but on the machine where it was generated…
The full package.json output is included in the replies thread…
Am I doing something wrong? I have a pretty standard gradle config, haven’t really changed much from what was produced by IntelliJ when creating the project. (edited)Bradleycorn
05/14/2021, 7:30 PM{
"name": "wager-utils",
"version": "1.1.6",
"main": "kotlin/wager-utils.js",
"devDependencies": {},
"dependencies": {
"kotlin": "file:/Users/brad.ball/dev/multiplatform/new/wager-utils/build/js/packages_imported/kotlin/1.5.0",
"kotlin-test-js-runner": "file:/Users/brad.ball/dev/multiplatform/new/wager-utils/build/js/packages_imported/kotlin-test-js-runner/1.5.0",
"kotlin-test": "file:/Users/brad.ball/dev/multiplatform/new/wager-utils/build/js/packages_imported/kotlin-test/1.5.0"
},
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": []
}
turansky
05/14/2021, 7:34 PMpackageJson
tasks existsBradleycorn
05/14/2021, 7:43 PM./gradlew jsPublicPackageJson
and it produced this package.json
:
{
"name": "wager-utils",
"version": "1.1.6",
"main": "wager-utils.js",
"types": "wager-utils.d.ts",
"devDependencies": {},
"dependencies": {},
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": []
}
There’s no dependencies listed at all, so I presume the wager-utils.js
that it references is supposed to have all the dependencies bundled in (and webpack’d??). But, there’s no wager-utils.js
file in the directory with the package.json … I’m not sure where to find the appropriate wager-utils.js
?turansky
05/14/2021, 7:45 PMI’m not sure where to find the appropriatewager-utils.js
build/distributions
?Bradleycorn
05/14/2021, 7:46 PM/build/distributions/wager-utils.js
but that seems WAY too small to have everything bundled; it’s only 560 bytes?turansky
05/14/2021, 7:46 PMBradleycorn
05/14/2021, 7:46 PMturansky
05/14/2021, 7:47 PMBradleycorn
05/14/2021, 7:48 PMBradleycorn
05/14/2021, 7:50 PMjs(IR) {
browser {
commonWebpackConfig {
cssSupport.enabled = false
}
}
binaries.executable()
}
turansky
05/14/2021, 7:50 PM@JsExport
annotation, if you want to export type or functionBradleycorn
05/14/2021, 7:50 PMturansky
05/14/2021, 7:50 PMBradleycorn
05/14/2021, 7:51 PMBradleycorn
05/14/2021, 7:53 PMBradleycorn
05/14/2021, 8:08 PMturansky
05/14/2021, 8:32 PMBradleycorn
05/14/2021, 9:38 PMpackage com.myLib
@JsExport
class MyClass internal constructor(private val myProp: Int) {
// .. some methods and properties ...
companion object {
fun create(value: Int): MyClass {
return MyClass(value * 2)
}
}
}
Bradleycorn
05/14/2021, 9:45 PMimport { com } from '../../myLib'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'web';
public test() {
let temp = com.myApp.MyClass.Companion.create(1);
}
}
it fails and says Property ‘Companion’ does not exist on type ‘typeof MyClass’turansky
05/14/2021, 9:57 PM1.5.0
Bradleycorn
05/14/2021, 9:58 PMplugins {
kotlin("multiplatform") version "1.5.0"
1.5.0turansky
05/14/2021, 10:04 PMcom.myApp.
package via Webpack 🙂
Looks like you need root export. 🙂Bradleycorn
05/14/2021, 10:05 PMturansky
05/14/2021, 10:24 PMBradleycorn
05/14/2021, 10:27 PMturansky
05/14/2021, 11:17 PM@JsStatic
:)