Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected object 'SharedRes' has no actual declaration in module <package_name:site> for JS #576

Closed
EchoEllet opened this issue Sep 11, 2023 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@EchoEllet
Copy link

I have created kobweb project which is a framework built on top of compose web

I add moko-resouces as plugin, library and define the versions in libs.versions.toml

[versions]
jetbrains-compose = "1.5.1"
kobweb = "0.14.0"
kotlin = "1.9.10"
multiplatform-resources = "0.23.0"

[libraries]
kobweb-api = { module = "com.varabyte.kobweb:kobweb-api", version.ref = "kobweb" }
kobweb-core = { module = "com.varabyte.kobweb:kobweb-core ", version.ref = "kobweb" }
kobweb-silk-core = { module = "com.varabyte.kobweb:kobweb-silk", version.ref = "kobweb" }
kobweb-silk-icons-fa = { module = "com.varabyte.kobweb:kobweb-silk-icons-fa", version.ref = "kobweb" }
kobweb-silk-icons-mdi = { module = "com.varabyte.kobweb:kobweb-silk-icons-mdi", version.ref = "kobweb" }
#kobwebx-markdown = { module = "com.varabyte.kobwebx:kobwebx-markdown", version.ref = "kobweb" }
multiplatform-resources = { module = "dev.icerock.moko:resources", version.ref = "multiplatform-resources" }

[plugins]
jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "jetbrains-compose" }
kobweb-application = { id = "com.varabyte.kobweb.application", version.ref = "kobweb" }
kobweb-library = { id = "com.varabyte.kobweb.library", version.ref = "kobweb" }
#kobwebx-markdown = { id = "com.varabyte.kobwebx.markdown", version.ref = "kobweb" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
multiplatform-resources = { id = "dev.icerock.mobile.multiplatform-resources", version.ref = "multiplatform-resources" }

build.gradle.kts:

import com.varabyte.kobweb.gradle.application.util.configAsKobwebApplication

plugins {
    alias(libs.plugins.kotlin.multiplatform)
    alias(libs.plugins.jetbrains.compose)
    alias(libs.plugins.kobweb.application)
    alias(libs.plugins.multiplatform.resources)
//    id("dev.icerock.mobile.multiplatform-resources")
//    alias(libs.plugins.kobwebx.markdown)
}

group = "com.ahmedhnewa.landing_page"
version = "1.0-SNAPSHOT"

kobweb {
    app {
        index {
            description.set("Powered by Kobweb")
        }
    }
}

kotlin {
    configAsKobwebApplication("landing_page", includeServer = false)

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(compose.runtime)
//                api("dev.icerock.moko:resources:0.23.0")
                api(libs.multiplatform.resources)
//                api("dev.icerock.moko:resources-compose:0.23.0") // for compose multiplatform

            }
        }

        val jsMain by getting {
            dependencies {
                implementation(compose.html.core)
                implementation(libs.kobweb.core)
                implementation(libs.kobweb.silk.core)
                implementation(libs.kobweb.silk.icons.fa)
//                implementation(libs.kobwebx.markdown)
            }
        }

//        val jvmMain by getting {
//            dependencies {
//                implementation(libs.kobweb.api)
//            }
//        }
    }
}

multiplatformResources {
    multiplatformResourcesPackage = "com.ahmedhnewa.landing_page"
    multiplatformResourcesClassName = "SharedRes" // optional, default MR
}

I want to use it only for js browser
but I get this error

Execution failed for task ':site:compileKotlinJs'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

The generated SharedRes:
Expected object 'SharedRes' has no actual declaration in module <com.ahmedhnewa.landing_page:site> for JS

code:

package com.ahmedhnewa.alrayada_landing_page

import dev.icerock.moko.resources.AssetResource
import dev.icerock.moko.resources.ColorResource
import dev.icerock.moko.resources.FileResource
import dev.icerock.moko.resources.FontResource
import dev.icerock.moko.resources.ImageResource
import dev.icerock.moko.resources.PluralsResource
import dev.icerock.moko.resources.ResourceContainer
import dev.icerock.moko.resources.StringResource

public expect object SharedRes {
  public object strings : ResourceContainer<StringResource> {
    public val hello_world: StringResource
  }

  public object plurals : ResourceContainer<PluralsResource>

  public object images : ResourceContainer<ImageResource>

  public object fonts : ResourceContainer<FontResource>

  public object files : ResourceContainer<FileResource>

  public object colors : ResourceContainer<ColorResource>

  public object assets : ResourceContainer<AssetResource>
}

@luangs7
Copy link

luangs7 commented Sep 13, 2023

same here
downgrade Kotlin to 1.8.20 and Compose to 1.5.0 works here
unfortunately, it affects another lib

@EchoEllet
Copy link
Author

EchoEllet commented Sep 13, 2023

same here
downgrade Kotlin to 1.8.20 and Compose to 1.5.0 works here
unfortunately, it affects another lib

I just created my own solution to localization. It's much better for kotlin and kmp with only the web, in my opinion, at least for strings

@luangs7
Copy link

luangs7 commented Sep 25, 2023

expect 1.9.0 support?

@CaelumF
Copy link

CaelumF commented Oct 5, 2023

FYI as a workaround you can ensure that the sourcesets have dependsOn(commonMain) and kotlin.srcDir("build/generated/moko/desktopMain/src") where desktopMain is replaced with the appropriate directory to match the source set

@Alex009 Alex009 added this to the 0.24.0 milestone Jan 14, 2024
@Alex009
Copy link
Member

Alex009 commented Jan 14, 2024

fix in #575

@ExNDY
Copy link
Contributor

ExNDY commented Apr 17, 2024

will be fixed in 0.24.0, please check in 0.24.0-alpha-6

@Alex009 Alex009 added the bug Something isn't working label Apr 19, 2024
@Alex009
Copy link
Member

Alex009 commented Apr 19, 2024

should be fixed in 0.24.0-beta-1

@Alex009 Alex009 closed this as completed Apr 19, 2024
@Alex009 Alex009 mentioned this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants