Skip to content

kevinypfan/jsii-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSII Demo Project

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.

Features

  • 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.

Related Article

For a detailed step-by-step guide, check out the article:
Getting Started with JSII: Build Cross-Language Libraries Using TypeScript

Getting Started

Prerequisites

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+

Installation

  1. Clone the repository:

    git clone https://github.com/kevinypfan/jsii-demo.git
    cd jsii-demo
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build
  4. Package the library:

    npm run package
  5. 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.

Example Usage

Python Example

from jsii_demo.core import Greeter

greeter = Greeter(greetee="Kevin")
print(greeter.greet())

Node.js Example

const { Greeter } = require('./dist');
const greeter = new Greeter({ greetee: "Kevin" });
console.log(greeter.greet());

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published