10000 unable to create share code in react js · Issue #1 · ch8n/kmm-full-stack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

unable to create share code in react js #1

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

Open
ch8n opened this issue Jul 7, 2024 · 1 comment
Open

unable to create share code in react js #1

ch8n opened this issue Jul 7, 2024 · 1 comment

Comments

@ch8n
Copy link
Owner
ch8n commented Jul 7, 2024

I'm working on sharing my models in a Ktor app, targeting the jsMain module, which will be called from a front-end written in React with Vite.
I used the KMP Wizard to generate the Ktor server and added the jsMain module manually. In the composeApp package's build.gradle.kts, I added this block to configure JavaScript:

js {
    useCommonJs()
    moduleName = "kotlinJs"
    browser {
        testTask {
            enabled = false
        }
        webpackTask {
            outputFileName = "kotlin.js"
            output.libraryTarget = COMMONJS2
        }
        @OptIn(ExperimentalDistributionDsl::class)
        distribution {
            outputDirectory.set(projectDir.resolve("output"))
        }
    }
    binaries.executable()
}

In the shared module's build.gradle.kts, I only added:

js {
    browser()
    binaries.executable()
}

When I run jsBrowserProductionWebpack, it creates the kotlin.js bundle. However, I’m having trouble importing this JS file into my React project.
Any help would be greatly appreciated!

@ch8n
Copy link
Owner Author
ch8n commented Jul 7, 2024

link to a thread in slack channel is available here Slack thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0