ESM Compiler is a Rust-based compiler for the esm.sh playground, leveraging swc for JavaScript/TypeScript/JSX transformation and lightningcss for CSS. Built as a WebAssembly module, it compiles modern frontend code into ESM-compatible output with import maps. Version 0.9.2 is the current stable release; it is actively developed as part of the esm.sh ecosystem. Key differentiators include its Wasm-first architecture, Rust performance, and tight integration with esm.sh's import map resolution, making it suitable for in-browser code transformation without a server.
npm install esm-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes the Wasm compiler, transforms a React JSX component with an import map, and logs the compiled ESM output.
Ensure init() is awaited once at the start of your application.
Use the full esm.sh URL (https://esm.sh/esm-compiler) instead of a local or npm import.
Use the async transform function returned after init().
Use 'import type { ... }' for type imports to avoid bundling errors.Always specify the JSX import source in the import map imports object.
Call await init() before calling transform, and check network requests for the .wasm file.
Wrap your transform calls in an async function and ensure init() is awaited.
Use a bundler like Vite or configure webpack to support WebAssembly and esm.sh imports.