{"id":26496,"library":"tpwatson","title":"tpwatson","description":"A prototype transpiler for the WAT# language, compiling a lightweight high-level syntax to WebAssembly Text Format (WAT). Current stable version 0.1.3 (released 2024). The package is in early development with frequent bug fixes. Unlike raw WAT coding, WAT# adds familiar types (bool, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64), compound types (arrays, structs, pointers), control flow (if/else, while, for, do-while), expression evaluation, inline functions, and preprocessor directives (#include, #if, #define). It aims to simplify WebAssembly module creation without requiring a runtime.","status":"active","version":"0.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/Dotneteer/watson","tags":["javascript","WebAssembly","WATson","watson","Watson","Watson transpiler"],"install":[{"cmd":"npm install tpwatson","lang":"bash","label":"npm"},{"cmd":"yarn add tpwatson","lang":"bash","label":"yarn"},{"cmd":"pnpm add tpwatson","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-only; CommonJS require is not supported.","wrong":"const tpwatson = require('tpwatson'); tpwatson.transpile()","symbol":"transpile","correct":"import { transpile } from 'tpwatson'"},{"note":"Default export is the same as named 'transpile' in v0.1.3.","wrong":"const transpile = require('tpwatson').default","symbol":"default (transpile function)","correct":"import transpile from 'tpwatson'"},{"note":"version is exported as a string constant.","wrong":"require('tpwatson/package.json').version","symbol":"version","correct":"import { version } from 'tpwatson'"}],"quickstart":{"code":"import { transpile } from 'tpwatson';\n\nconst watSharpCode = `\n// WAT# example: add two numbers\nfunction add(a: i32, b: i32): i32 {\n    return a + b;\n}\n`;\n\ntry {\n    const watOutput = transpile(watSharpCode);\n    console.log('Generated WAT:\\n', watOutput);\n} catch (error) {\n    console.error('Transpilation failed:', error);\n}\n","lang":"typescript","description":"Shows how to import and use the transpile function to convert WAT# source code to WebAssembly Text Format."},"warnings":[{"fix":"Pin to a specific version and test thoroughly on upgrade.","message":"The package is in early prototype stage. APIs may change without notice. Do not use in production.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Wrap output in '(module ...)' or wait for future versions.","message":"Transpiler does not generate a complete WebAssembly module; you may need to wrap output in (module ... ) manually.","severity":"gotcha","affected_versions":"<0.2.0"},{"fix":"Use i32 with 0/1 values instead.","message":"The 'bool' type is not a standard WebAssembly type and may be removed in future versions.","severity":"deprecated","affected_versions":"<=0.1.3"},{"fix":"Ensure all includes are relative to the source file.","message":"Preprocessor directives (#include) currently only support local file paths; remote includes are not implemented.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Avoid relying on inlining behavior until implemented.","message":"The 'inline' keyword is parsed but not yet functional; inline functions are treated as regular functions.","severity":"gotcha","affected_versions":"<=0.1.2"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import instead: `import tpwatson from 'tpwatson'`","cause":"Using CommonJS require on an ESM-only package.","error":"TypeError: tpwatson is not a function"},{"fix":"Ensure the WAT# code is passed as a string to the transpile function, not executed directly.","cause":"WAT# uses TypeScript-like type annotations but JavaScript does not support them natively.","error":"SyntaxError: Unexpected token ':'"},{"fix":"Use an absolute path or ensure the file is relative to the working directory.","cause":"The #include directive cannot resolve the file path.","error":"Error: #include not found: mylib.wat#"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}