
Company News
Socket Named to Rising in Cyber 2026 List of Top Cybersecurity Startups
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.
@bytecodealliance/jco-transpile
Advanced tools
WebAssembly Component transpilation functionality for Jco
@bytecodealliance/jco-transpileThis @bytecodealliance/jco sub-project enables transpilation of WebAssembly Components into ES modules
that can be run in Javascript environments like NodeJS and the browser (experimental).
@bytecodealliance/jco-transpile is used primarily when only transpilation functionality of jco is needed,
and jco derives it's use of transpilation from this library.
[!WARNING] Browser support is considered experimental, and not currently suitable for production applications.
To use @bytecodealliance/jco-transpile as a library in your own code, you can use some of the exported functions.
Check out our examples on GitHub.
To transpile an existing WebAssembly component (path on disk, Buffer):
import { transpile, writeFiles } from '@bytecodealliance/jco-transpile';
async function example() {
// Transpile a given WebAssembly component into JS runnabe in NodeJS
const { files, imports, exports } = await transpile('path/to/component.wasm', { outDir: 'path/to/output/dir' });
// Write out the files that have been generated to disk
await writeFiles(files);
}
[!NOTE]
transpiletakes many options -- consulttranspile.d.tsfor more detailed type information.
outDircontrols the prefix of generated file paths, so it is specified, despite the fact that no files are actually written to disk.
If you write a component with the given WIT:
package docs:adder@0.1.0;
interface add {
add: func(x: u32, y: u32) -> u32;
}
world adder {
export add;
}
After tranpsilation of that component, you should see output like the following:
dist
βββ transpiled
βββ add.core.wasm
βββ add.d.ts
βββ adder.core.wasm
βββ adder.d.ts
βββ adder.js
βββ add.js
βββ add.mjs
βββ interfaces
βββ docs-adder-add.d.ts
3 directories, 8 files
dist/transpiled/adder.js is the entrypoint that can be used from "host" code:
import { add } from './dist/transpiled/adder.js';
console.log('1 + 2 = ' + add.add(1, 2));
You can try this example for yourself in GitHub.
When writing components, you can generate the Typescript declarations that correspond to your WebAssembly Interface Types (WIT) imports and exports by generating guest tyeps:
import { generateGuestTypes, writeFiles } from '@bytecodealliance/jco-transpile';
async function example() {
const files = await generateGuestTypes('path/to/wit/dir-or-file, { outDir: 'path/to/output/dir' });
// NOTE: Files is a serialization of the files produced of the following type:
// type FileBytes = { [filepath: string]: Uint8Array; };
//
// You can use the code below to write out all files to a given directory
await Promise.all(
Object.entries(files).map(async ([filePath, bytes]) => {
await mkdir(dirname(filePath), { recursive: true });
await writeFile(filePath, bytes);
})
);
}
Guest types are the implementations of WIT interfaces that are used by JS components -- i.e. JS code that is
turned into a component (by jco componentize/componentize-js) and performing useful work.
For a given import in a WIT world, this type generation would enable calling/using the interface.
For example, given the following WIT interface:
package docs:adder@0.1.0;
interface add {
add: func(x: u32, y: u32) -> u32;
}
world adder {
export add;
}
The Typescript declaration produced is:
declare module 'docs:adder/add@0.1.0' {
export function add(x: number, y: number): number;
}
When building platforms that run transpiled components, you can generate Typescript declarations that correspond to the WebAssembly Interface Types (WIT) imports (that the component requires) by generating host types:
import { generateHostTypes, writeFiles } from '@bytecodealliance/jco-transpile';
async function example() {
// Generate types for a host binding (i.e. supplying imports to a transpiled component)
const files = await generateHostTypes('path/to/wit/dir-or-file, { outDir: 'path/to/output/dir' });
// Write out the files that have been generated to disk
await writeFiles(files);
}
Host types are the implementations of WIT interfaces that are used by post-transpilation JS code, i.e. on the "host" (NodeJS + V8 or the browser), to make platform imports work.
For a given import in a WIT world, this type generation would enable implementation of the imported functionality interface.
For example, given the following WIT interface:
package docs:adder@0.1.0;
interface add {
add: func(x: u32, y: u32) -> u32;
}
world adder {
export add;
}
The Typescript declaration produced is:
/** @module Interface docs:adder/add@0.1.0 **/
export function add(x: number, y: number): number;
This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
FAQs
WebAssembly Component transpilation functionality for Jco
The npm package @bytecodealliance/jco-transpile receives a total of 40,197 weekly downloads. As such, @bytecodealliance/jco-transpile popularity was classified as popular.
We found that @bytecodealliance/jco-transpile demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.

Research
Socket detected 84 compromised TanStack npm package artifacts modified with suspected CI credential-stealing malware.

Security News
A dispute over fsnotify maintainer access set off supply chain alarms around one of Goβs most widely used filesystem libraries.