Skip to content

Hello world example in Typescript #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions hello-world/wrapper/typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
build
yarn-error.log
coverage
.vscode
*.log
.polywrap
.DS_Store
src/wrap
report.*
.env
bundled
1 change: 1 addition & 0 deletions hello-world/wrapper/typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TS Wrap Template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since TS wraps work a bit differently, it would be nice to get some brief explanation of the nuances here (or a link to docs).

15 changes: 15 additions & 0 deletions hello-world/wrapper/typescript/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
collectCoverage: false,
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/**/?(*.)+(spec|test).[jt]s?(x)"],
globals: {
"ts-jest": {
tsconfig: "tsconfig.json",
diagnostics: false,
},
},
testPathIgnorePatterns: [
"/.polywrap/"
],
};
29 changes: 29 additions & 0 deletions hello-world/wrapper/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "hello-world-demo-ts",
"description": "",
"private": true,
"version": "0.11.4",
"main": "build/index.js",
"scripts": {
"bundle": "rollup -c",
"codegen": "polywrap codegen --verbose",
"build": "yarn bundle && npx polywrap build --no-codegen --strategy=image",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add yarn codegen to the yarn build script?

yarn codegen && yarn bundle && npx polywrap build --no-codegen --strategy=image

"test": "jest --passWithNoTests --runInBand --verbose",
"deploy": "polywrap deploy"
},
"dependencies": {
"tslib": "^2.6.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-node-resolve": "^15.2.0",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.2",
"@types/jest": "26.0.8",
"jest": "26.6.3",
"ts-jest": "26.5.4",
"polywrap": "0.11.4",
"rollup": "^3.28.0",
"typescript": "^5.1.6"
}
}
5 changes: 5 additions & 0 deletions hello-world/wrapper/typescript/polywrap.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import { Module } into Logger from "wrap://ens/wraps.eth:[email protected]"

type Module {
logMessage(message: String!): Boolean!
}
7 changes: 7 additions & 0 deletions hello-world/wrapper/typescript/polywrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
format: 0.5.0
project:
name: hello-world-ts
type: wasm/typescript
source:
schema: ./polywrap.graphql
module: ./bundled/wrap.js
21 changes: 21 additions & 0 deletions hello-world/wrapper/typescript/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import typescript from "@rollup/plugin-typescript";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import terser from "@rollup/plugin-terser";
import shims from "./shims/shims.js";

export default {
input: "src/wrap/entry.ts",
output: {
file: "bundled/wrap.js",
format: "cjs",
},
plugins: [
typescript(),
resolve(),
commonjs(),
shims(),
terser()
],
treeshake: false,
};
Loading