npm init
npm i -S typescript @types/node assemblyscript
npx tsc --init
npx asinit .
- In tsconfig.json add
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./"
},
"exclude": [
"node_modules",
"assembly"
]
- In package.json add
"start": "node --experimental-modules --experimental-wasm-modules ./dist/index.js",
"build": "npm run asbuild && tsc -p ./tsconfig.json && npm run copy",
"copy": "rm -rf dist/build/ && cp -r build dist/build/",
- Rename index.js to loader.ts, add any missing types and export the webassembly instance to be used from other files
npm run build
npm start
https://docs.assemblyscript.org/quick-start
https://www.joyent.com/blog/improved-wasm-support-coming-to-node