Usage
Examples
Arguments
JavaScript or TypeScript source file to compile
Output WebAssembly binary file path
Compilation Flags
Optimization level (0-3)
-O0: No optimizations, fastest compilation-O1: Basic optimizations (default)-O2: Advanced optimizations (partial evaluation)-O3: Maximum optimizations
Include debug information in output
- Preserves function and variable names
- Enables debug logs
- Larger binary size
Value type for numbers:
i32 or f64TypeScript Support
Force TypeScript parsing
Enable TypeScript type annotation parsing
Use type annotations for optimization hints
Advanced Options
JavaScript parser:
acorn, @babel/parser, meriyah, hermes-parserParse input as ES module
Enable secure mode (disable unsafe features like FFI)
Enable experimental Cyclone optimizer for aggressive constant evaluation
Enable profile-guided optimization
Log compiler performance metrics (enabled by default when compiling to file)
Output Examples
Wasm Proposals Used
Porffor-generated WebAssembly uses these proposals:- Multi-value (required) - Functions returning multiple values
- Non-trapping float-to-int conversions (required) - Safe number conversions
- Bulk memory operations (optional) - Efficient memory operations
- Exception handling (optional) - Error handling support
- Tail calls (opt-in, off by default) - Tail call optimization
Binary Size Optimization
Using the Output
The generated.wasm file is a spec-compliant WebAssembly module but requires specific imports for I/O operations.
Example: Loading in Node.js
For standalone executables, use
porf native instead to compile to native binaries.Inspecting Output
Troubleshooting
Compilation Errors
Large Binary Size
Runtime Errors
Performance Comparison
Next Steps
Native Compilation
Compile to standalone executables
C Output
Generate C source code
Profile Performance
Analyze compiled code performance
Lambda Deployment
Deploy to AWS Lambda