Overview
Scriptc is an experimental Vercel Labs project that transforms your TypeScript and JavaScript code into highly efficient native executables and WebAssembly modules. It leverages the power of the TypeScript compiler for robust parsing and type-checking, producing a variety of output formats from typed Intermediate Representation (IR) and readable C to LLVM IR, native assembly, object files, standalone executables, and WebAssembly. This allows you to run your JavaScript/TypeScript code natively without the need for a Node.js runtime, opening up new possibilities for performance-critical applications and cross-platform development.
Key Features
- Versatile Compilation Targets: Compile to typed IR, C, LLVM IR, native assembly, objects, native executables, and WebAssembly.
- Leverages TypeScript Compiler: Utilizes the familiar TypeScript compiler for accurate parsing and type-checking.
- Statically Linked Binaries: Generate self-contained executables that do not require a Node.js or JavaScript engine at runtime.
- Node.js API Support: Many common Node.js APIs are supported and compiled to the native runtime.
- WebAssembly Compilation: Build portable WASI Preview 1 modules for cross-platform compatibility.
- npm Package Integration: Seamlessly embed npm packages into your compiled binaries using the
--dynamicflag. - Static Coverage Analysis: Analyze your code to understand its static compilation potential and identify dynamic elements.
- Experimental Cross-Platform Support: Targets macOS, Linux, Windows, and WebAssembly (WASI Preview 1).
Typical Use Cases
- Performance-Critical CLI Tools: Create fast, standalone command-line interfaces that don't depend on Node.js.
- Serverless Functions & Edge Compute: Develop highly optimized code for environments where minimizing startup time and resource usage is crucial.
- Desktop Applications: Build native applications using familiar JavaScript/TypeScript syntax.
- WebAssembly Modules: Generate efficient WebAssembly modules for use in web browsers or other WASI-compatible environments.
- Native Libraries: Compile TypeScript/JavaScript code into native object files for integration with other languages.
- Exploring Beyond the VM: Unlock new deployment scenarios and performance characteristics for your JavaScript and TypeScript projects by compiling them to native code.
