in playground/tree-sitter/build.py [0:0]
def build_concrete_syntax_wasm(repo_root: Path) -> Path:
"""Build WASM files for concrete-syntax crate."""
concrete_syntax_dir = repo_root / "crates" / "concrete-syntax"
pkg_web_dir = concrete_syntax_dir / "pkg-web"
print("Building concrete syntax WASM package...")
# Check if WASM files need to be built (simple existence check)
wasm_files = [
pkg_web_dir / "concrete_syntax.js",
pkg_web_dir / "concrete_syntax_bg.wasm"
]
if all(f.exists() for f in wasm_files):
print("✓ Concrete syntax WASM files already exist, skipping build...")
else:
print("Building WASM package for web target...")
# Build the WASM target first
run_command([
"cargo", "build",
"--target", "wasm32-unknown-unknown",
"--no-default-features",
"--features", "wasm"
], cwd=concrete_syntax_dir)
# Generate WASM bindings
run_command([
"wasm-pack", "build",
"--target", "web",
"--out-dir", "pkg-web",
"--no-default-features",
"--features", "wasm"
], cwd=concrete_syntax_dir)
print("✅ WASM package built successfully")
# Verify files exist
for wasm_file in wasm_files:
if not wasm_file.exists():
raise FileNotFoundError(f"Required WASM file not found: {wasm_file}")
return pkg_web_dir