Skip to content

Commit 96d73a2

Browse files
[skip ci] Add Plugins/PackageToJS/README.md
1 parent 738b02d commit 96d73a2

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

Diff for: CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,18 @@ Thank you for considering contributing to JavaScriptKit! We welcome contribution
5959

6060
### Running Tests
6161

62+
Unit tests running on WebAssembly:
63+
6264
```bash
6365
make unittest SWIFT_SDK_ID=wasm32-unknown-wasi
6466
```
6567

68+
Tests for `PackageToJS` plugin:
69+
70+
```bash
71+
swift test --package-path ./Plugins/PackageToJS
72+
```
73+
6674
### Editing `./Runtime` directory
6775

6876
The `./Runtime` directory contains the JavaScript runtime that interacts with the JavaScript environment and Swift code.

Diff for: Plugins/PackageToJS/README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# PackageToJS
2+
3+
A Swift Package Manager plugin that facilitates building and packaging Swift WebAssembly applications for JavaScript environments.
4+
5+
## Overview
6+
7+
PackageToJS is a command plugin for Swift Package Manager that simplifies the process of compiling Swift code to WebAssembly and generating the necessary JavaScript bindings. It's an essential tool for SwiftWasm projects, especially those using JavaScriptKit to interact with JavaScript from Swift.
8+
9+
## Features
10+
11+
- Build Swift packages for WebAssembly targets
12+
- Generate JavaScript wrapper code for Swift WebAssembly modules
13+
- Support for testing Swift WebAssembly code
14+
- Diagnostic helpers for common build issues
15+
- Options for optimization and debug information management
16+
17+
## Requirements
18+
19+
- Swift 6.0 or later
20+
- A compatible WebAssembly SDK
21+
22+
## Internal Architecture
23+
24+
PackageToJS consists of several components:
25+
- `PackageToJSPlugin.swift`: Main entry point for the Swift Package Manager plugin (Note that this file is not included when running unit tests for the plugin)
26+
- `PackageToJS.swift`: Core functionality for building and packaging
27+
- `MiniMake.swift`: Build system utilities
28+
- `ParseWasm.swift`: WebAssembly binary parsing
29+
- `Preprocess.swift`: Preprocessor for `./Templates` files
30+
31+
## Internal Testing
32+
33+
To run the unit tests for the `PackageToJS` plugin, use the following command:
34+
35+
```bash
36+
swift test --package-path ./Plugins/PackageToJS
37+
```
38+
39+
Please define the following environment variables when you want to run E2E tests:
40+
41+
- `SWIFT_SDK_ID`: Specifies the Swift SDK identifier to use
42+
- `SWIFT_PATH`: Specifies the `bin` path to the Swift toolchain to use
43+

0 commit comments

Comments
 (0)