Skip to content

Kotlin/js-export-sample

Repository files navigation

official project

Kotlin JsExport Sample

This project demonstrates how to export Kotlin code as native TypeScript modules using JetBrains' Kotlin Multiplatform. The sample consists of three modules: :shared, :module-a, and :module-b, showcasing how to configure the export via annotations.

⚠️ Experimental Feature Notice

JsExport Export is an experimental feature and subject to change in any future releases.

Project Structure

  • :shared - The main shared module that aggregates and exports the other modules (:module-a and :module-b) as native TypeScript modules.
  • :module-a - A sample Kotlin module to be exported as ModuleA in TypeScript.
  • :module-b - Another sample Kotlin module to be exported as ModuleB in TypeScript.

Running the Project

  1. Clone this repository.
  2. Open the project in your favorite IDE/editor.
  3. Run ./gradlew shared:jsBrowserProductionLibraryDistribution in the terminal.
  4. Install dependencies using npm install in the repository root.
  5. Run the webApp using npm start --workspace=webApp or run tests with npm test --workspace=webApp in the repository root.

Key Features

  • outputModuleName: Allows setting a custom module name for the exported Kotlin module.
  • packageJson: Allows setting a custom property for the package.json, so that we set up kmp-lib name for the exported Kotlin library.
  • kotlin.js.ir.output.granularity: Allows compiling the Kotlin code per-file, which is natural for JavaScript.

Learn More

About

Kotlin to TypeScript technology preview

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors