This is a demonstration project showcasing how to use JSII to build cross-language libraries with TypeScript. The project highlights key steps to configure, build, and package a TypeScript library that can be used in multiple languages like Python, Java, C#, and more.
- Cross-Language Support: Write once in TypeScript, use in multiple languages.
- Integration with npm Packages: Demonstrates how to bundle and use external npm packages.
- Sample Implementation: Includes a
Greeter
class with basic and styled text output.
For a detailed step-by-step guide, check out the article:
Getting Started with JSII: Build Cross-Language Libraries Using TypeScript
Ensure you have the following tools installed:
- Node.js (Recommended versions: ^18.0.0, ^20.0.0, ^22.0.0)
- Target language-specific tools:
- Python: Python 3.8+ and
pip
- .NET: .NET 6.0+
- Java: JDK 8+ and Maven 3.6+
- Go: Go 1.18+
- Python: Python 3.8+ and
-
Clone the repository:
git clone https://github.com/kevinypfan/jsii-demo.git cd jsii-demo
-
Install dependencies:
npm install
-
Build the project:
npm run build
-
Package the library:
npm run package
-
Use the library in your target language. For example, in Python:
pip install targets/python/jsii_demo.core-1.0.0-py3-none-any.whl
Test the functionality with the provided
Greeter
class.
from jsii_demo.core import Greeter
greeter = Greeter(greetee="Kevin")
print(greeter.greet())
const { Greeter } = require('./dist');
const greeter = new Greeter({ greetee: "Kevin" });
console.log(greeter.greet());