File tree Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ # Import TypeScript example
2+
3+ Install Development Snapshot toolchain ` DEVELOPMENT-SNAPSHOT-2024-07-08-a ` or later from [ swift.org/install] ( https://www.swift.org/install/ ) and run the following commands:
4+
5+ ``` sh
6+ $ (
7+ set -eo pipefail; \
8+ V=" $( swiftc --version | head -n1) " ; \
9+ TAG=" $( curl -sL " https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -e -r --arg v " $V " ' .[$v] | .[-1]' ) " ; \
10+ curl -sL " https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG .json" | \
11+ jq -r ' .["swift-sdks"]["wasm32-unknown-wasip1-threads"] | "swift sdk install \"\(.url)\" --checksum \"\(.checksum)\""' | sh -x
12+ )
13+ $ export SWIFT_SDK_ID=$(
14+ V=" $( swiftc --version | head -n1) " ; \
15+ TAG=" $( curl -sL " https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -e -r --arg v " $V " ' .[$v] | .[-1]' ) " ; \
16+ curl -sL " https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG .json" | \
17+ jq -r ' .["swift-sdks"]["wasm32-unknown-wasip1-threads"]["id"]'
18+ )
19+ ```
20+
21+ ## Ensure dependencies are installed:
22+ Install node.js separately, Then:
23+ ``` sh
24+ $ npm install
25+ $ ./build.sh
26+ $ npx serve
27+ ```
28+
29+ You should see <strong >Hello, World!</strong >, in your localhost at port 3000.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euxo pipefail
3+ export SWIFT_SDK_ID=6.1-RELEASE-wasm32-unknown-wasip1-threads
4+ JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package --swift-sdk $SWIFT_SDK_ID js
Original file line number Diff line number Diff line change 66</ head >
77
88< body >
9+ < script type ="importmap ">
10+ {
11+ "imports" : {
12+ "@bjorn3/browser_wasi_shim" : "./node_modules/@bjorn3/browser_wasi_shim/dist/index.js"
13+ }
14+ }
15+ </ script >
916 < script type ="module " src ="index.js "> </ script >
1017
1118 < div id ="exports-result "> </ div >
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " importts" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " ``` npm install typescript --save-dev ```" ,
5+ "main" : " index.js" ,
6+ "scripts" : {
7+ "test" : " echo \" Error: no test specified\" && exit 1"
8+ },
9+ "author" : " " ,
10+ "license" : " ISC" ,
11+ "devDependencies" : {
12+ "@bjorn3/browser_wasi_shim" : " ^0.3.0" ,
13+ "typescript" : " ^5.9.2"
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments