Skip to content

Commit

Permalink
chore: Add some hello world examples
Browse files Browse the repository at this point in the history
Fixes #203

Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Dec 7, 2023
1 parent bd41149 commit 69a9dcf
Show file tree
Hide file tree
Showing 12 changed files with 793 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/typescript/hello-world/commonjs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
index.js
49 changes: 49 additions & 0 deletions examples/typescript/hello-world/commonjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Hello World Example - CommonJS

This example shows how to use the `@hpcc-js/wasm` package within a legacy commonjs TypeScript project.

## Steps to build and test

1. Install dependencies

```bash
npm install
```

2. Build the project

```bash
npm run build
```

3. Execute in Node

```bash
node index.js
```

## How this project was created

1. Create a generic typescript project

```bash
mkdir hello-world
cd hello-world
npm init -y
npm install --save-dev typescript
npm install --save @types/node
npx tsc --init
```

2. Edit package.json

```json
{
...
"scripts": {
"build": "tsc -p tsconfig.json",
"test": "npm run build && node ."
},
...
}
```
7 changes: 7 additions & 0 deletions examples/typescript/hello-world/commonjs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
async function render() {
const { Graphviz } = await import("@hpcc-js/wasm");
const graphviz = await Graphviz.load();
console.log(graphviz.dot('digraph G { Hello -> World }'));
}

render();
204 changes: 204 additions & 0 deletions examples/typescript/hello-world/commonjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions examples/typescript/hello-world/commonjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "commonjs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc -p tsconfig.json",
"test": "npm run build && node ."
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@hpcc-js/wasm": "^2.15.0"
},
"devDependencies": {
"typescript": "^5.3.3"
}
}
Loading

0 comments on commit 69a9dcf

Please sign in to comment.