Drop Node.js addon API, use WASM backend exclusively#720
Conversation
Co-authored-by: K20shores <[email protected]>
Co-authored-by: K20shores <[email protected]>
Co-authored-by: K20shores <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #720 +/- ##
==========================================
+ Coverage 75.66% 76.63% +0.96%
==========================================
Files 107 108 +1
Lines 7990 7849 -141
==========================================
- Hits 6046 6015 -31
+ Misses 1944 1834 -110
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot there are 2 index files
I only want one. Update package.json accordingly There are also two micm tests:
Combine them into one |
- Merged javascript/wasm/index.js into javascript/index.js - Removed javascript/wasm/index.js - Updated package.json to remove ./wasm export - Updated all imports to use main index.js - Deleted redundant javascript/tests/unit/micm_wasm.test.js - All tests covered in main test files Co-authored-by: K20shores <[email protected]>
Done in 171fcb5. Consolidated into single |
- using a backend loader - bundling filesystem
There was a problem hiding this comment.
Pull request overview
This PR modernizes the MUSICA JavaScript interface by removing the Node.js native addon in favor of a WebAssembly-only backend and migrating the entire codebase to ES6 modules. This simplifies the build process and enables consistent behavior across Node.js and browser environments.
Key Changes:
- Removes Node.js addon API dependencies (
node-addon-api,bindings,cmake-js) and all associated C++ code - Converts all JavaScript files from CommonJS (
require/module.exports) to ES6 modules (import/export) - Consolidates backend initialization through a single
initModule()function that uses WASM exclusively - Updates example.html to demonstrate in-browser simulation capabilities with ES6 module imports
Reviewed changes
Copilot reviewed 38 out of 39 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Removed Node.js addon dependencies, simplified build scripts to WASM-only, added "type": "module" |
| package-lock.json | Cleaned up removed dependencies (cmake-js, bindings, node-addon-api and their transitive deps) |
| javascript/wasm/index.js | Removed (WASM initialization now in backend.js) |
| javascript/wasm/example.html | Enhanced with ES6 module imports and in-browser simulation demo |
| javascript/tests/**/*.test.js | Converted all tests to ES6 imports and added initModule() calls |
| javascript/src/**/*.cpp | Removed all Node.js addon C++ source files |
| javascript/micm/*.js | Converted to ES6 exports, removed backend switching logic |
| javascript/mechanism_configuration/*.js | Converted to ES6 module syntax |
| javascript/backend.js | New unified backend loader with NODEFS mounting for Node.js |
| javascript/index.js | Simplified to ES6 exports with async version functions |
| javascript/CMakeLists.txt | Simplified to WASM-only build with NODEFS support |
| .github/workflows/javascript.yml | Removed Node.js addon job, kept WASM-only testing |
| javascript/README.md | Updated documentation for WASM-only workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This PR
example.htmlto show how musica can be run directly in the browser (image below)Now we are well on our way to replacing the server-side component of musica box interactive.