Gathering detailed insights and metrics for modern-wasm-starter
Gathering detailed insights and metrics for modern-wasm-starter
Gathering detailed insights and metrics for modern-wasm-starter
Gathering detailed insights and metrics for modern-wasm-starter
🛸 Run C++ code on web and create blazingly fast websites! A starter template to easily create WebAssembly packages using type-safe C++ bindings with automatic TypeScript declarations.
npm install modern-wasm-starter
Typescript
Module System
Node Version
NPM Version
TypeScript (47.19%)
CMake (29.91%)
C++ (22.29%)
C (0.61%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Unlicense License
250 Stars
36 Commits
13 Forks
8 Watchers
3 Branches
1 Contributors
Updated on Apr 09, 2025
Latest Version
0.0.25
Package Id
modern-wasm-starter@0.0.25
Unpacked Size
562.72 kB
Size
179.29 kB
File Count
12
NPM Version
6.14.15
Node Version
12.22.6
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
5
A starter template to easily create WebAssembly packages for npm using type-safe C++ code with automatic declarations. This project should take care of most of the boilerplate code required to create a modern and type-safe WebAssembly project.
Use this repo as a template to quickly start your own projects!
To be able to build WebAssembly code from C++ using Emscripten, you must first install and activate the emsdk. To compile the C++ code to WebAssembly, run the following command from the project's root directory.
1npm install
This will create the files source/WasmModule.js
and source/WasmModule.d.ts
from the C++ code in the wasm directory and transpile everything into a JavaScript module in the dist
directory.
To build your code as wasm, add it as a CPM.cmake dependency in the CMakeLists.txt file and define the bindings in the wasmGlue.cpp source file.
To update the wasm and TypeScript declarations, you can run npm run build:wasm
.
The following command will build and run the test suite.
1npm test
For rapid developing, tests can also be started in watch mode, which will automatically run on any code change to the TypeScript or JavaScript sources.
1npm start
The following command will run prettier on the TypeScript and clang-format on the C++ source code.
npm run fix:style
This starter uses the Glue project to create bindings and declarations. Update the wasmGlue.cpp source files to expose new classes or functions. See the Glue or EmGlue projects for documentation and examples.
As JavaScript has no destructors, any created C++ objects must be deleted manually, or they will be leaked. To simplify this, the project introduces memory scopes that semi-automatically take care of memory management. The usage is illustrated below.
1import { withGreeter } from "modern-wasm-starter";
2
3// `withGreeter()` will run the callback asynchronously in a memory scope and return the result in a `Promise`
4withGreeter(greeterModule => {
5 // construct a new C++ `Greeter` instance
6 const greeter = new greeterModule.Greeter("Wasm");
7
8 // call a member function
9 console.log(greeter.greet(greeterModule.LanguageCode.EN));
10
11 // any created C++ objects will be destroyed after the function exits, unless they are persisted
12});
To see additional techniques, such as synchronous scopes or persisting and removing values outside of the scope, check out the tests or API.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More