James Mulholland
10/23/2020, 10:16 AMkotlin
NPM package; updates were carried out by building and then copying the output of ./build/js/packages/ThisPackage/kotlin/ThisPackage.js
into our Next.js project).
However, now we have added a dependency on another internal Kotlin project, I can’t get anything build properly, even in a hacky way. ./build/distributions/ThisPackage.js
contains references to window
(despite the fact that I have used the node.js build option in build.gradle.kts
) and the output in ./build/js/package
does not correctly import our other package.
Does anyone know how I might do the following:
• Get a working amount of code exported using both of our packages (Essential)
• Build a single file to copy across (Highly desirable)
• Get a node_module on GitHub’s package registry (Nice to have)
I’ve tried using the new IR backend which looks like it will get us to where we want to go at some point in the future but, unfortunately, it seems to be either buggy or missing features for the time being.
I’ve got the current setup (with mobile config omitted).
plugins {
kotlin("multiplatform") version "1.4.0"
`maven-publish`
// ...mobile plugins
id("org.jlleitschuh.gradle.ktlint") version "9.3.0"
}
repositories {
mavenCentral()
maven {
url = uri("<https://maven.pkg.github.com/our/dependency>") // another internal kotlin project
credentials(PasswordCredentials::class)
}
}
kotlin {
js {
nodejs {
}
useCommonJs()
binaries.executable()
}
// ...mobile config
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.our.dependency:kotlin:0.1") // another internal kotlin project
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
// ...mobile config
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
publishing {
repositories {
maven {
setUrl("<https://maven.pkg.github.com/our/this-repository>")
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
James Mulholland
10/23/2020, 10:17 AMBig Chungus
10/23/2020, 10:17 AMBig Chungus
10/23/2020, 10:17 AMBig Chungus
10/23/2020, 10:18 AMJames Mulholland
10/23/2020, 10:18 AMBig Chungus
10/23/2020, 10:20 AMJames Mulholland
10/23/2020, 10:21 AMBig Chungus
10/23/2020, 10:23 AMBig Chungus
10/23/2020, 10:27 AMBig Chungus
10/23/2020, 10:28 AMJames Mulholland
10/23/2020, 10:45 AMNpmAccess
is undefined?
* What went wrong:
Script compilation error:
Line 114: access = NpmAccess.RESTRICTED
^ Unresolved reference: NpmAccess
Big Chungus
10/23/2020, 10:46 AMJames Mulholland
10/23/2020, 10:46 AMnpmPublishing {
readme = file("README.MD")
organization = "orgnamehere" // (Optional) Used as default scope for all publications
access = NpmAccess.RESTRICTED
bundleKotlinDependencies = true
repositories {
repository("npm-pkg-github") {
registry = uri("<https://npm.pkg.github.com>")
authToken = "sometokenxxxxxx"
}
}
}
James Mulholland
10/23/2020, 10:47 AMBig Chungus
10/23/2020, 10:49 AMBig Chungus
10/23/2020, 10:50 AMimport lt.petuska.npm.publish.dsl.NpmAccess
James Mulholland
10/23/2020, 10:50 AMBig Chungus
10/23/2020, 10:51 AMJames Mulholland
10/23/2020, 10:53 AMBig Chungus
10/23/2020, 11:23 AMBig Chungus
10/23/2020, 11:24 AMJames Mulholland
10/23/2020, 11:24 AMBig Chungus
10/23/2020, 11:25 AMBig Chungus
10/23/2020, 11:25 AMJames Mulholland
10/23/2020, 11:26 AMBig Chungus
10/23/2020, 11:26 AMJames Mulholland
10/23/2020, 11:27 AMBig Chungus
10/26/2020, 1:15 PM