Skip to main content

detect_language

Function detect_language 

Source
pub fn detect_language(context: impl AsRef<Path>) -> Result<WasmLanguage>
Expand description

Detect the source language from files in the given directory

This function examines project files to determine which language should be used for WASM compilation.

§Detection Order

  1. Cargo.toml with cargo-component -> RustComponent
  2. Cargo.toml -> Rust
  3. go.mod -> Go (TinyGo)
  4. pyproject.toml or requirements.txt -> Python
  5. package.json with assemblyscript -> AssemblyScript
  6. package.json -> TypeScript
  7. build.zig -> Zig
  8. Makefile with *.c files -> C

§Errors

Returns an error if no supported WASM language project is detected in the context directory.