Skip to content

Commit

Permalink
Merge pull request #24 from asavelyev01/add-typescript
Browse files Browse the repository at this point in the history
Add TypeScript example
  • Loading branch information
vigoo authored Apr 3, 2024
2 parents f0c0195 + 92870e3 commit a1a5284
Show file tree
Hide file tree
Showing 10 changed files with 855 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ templates/**/*.wasm
/target
.idea
.DS_Store
node_modules
5 changes: 5 additions & 0 deletions examples/ts/INSTRUCTIONS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Compile the TypeScript project with npm:
npm install
npm run build

The `out/component_name.wasm` file is ready to be uploaded to Golem Cloud!
14 changes: 14 additions & 0 deletions examples/ts/ts-actor-minimal/componentize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { componentize } from "@bytecodealliance/componentize-js";
import { readFile, writeFile, mkdir } from "node:fs/promises";
import { resolve } from "node:path";

const jsSource = await readFile("dist/main.js", "utf8");

const { component } = await componentize(jsSource, {
witPath: resolve("wit"),
enableStdout: true,
preview2Adapter: "adapters/tier1/wasi_snapshot_preview1.wasm",
});

await mkdir("out", { recursive: true });
await writeFile("out/component_name.wasm", component);
8 changes: 8 additions & 0 deletions examples/ts/ts-actor-minimal/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"description": "A simple stateful Golem actor with no dependencies on external services",
"requiresAdapter": true,
"exclude": [
"out",
"node_modules"
]
}
Loading

0 comments on commit a1a5284

Please sign in to comment.