Skip to content

Drop Node.js addon API, use WASM backend exclusively#720

Merged
K20shores merged 19 commits intomainfrom
copilot/drop-node-addon-api
Jan 5, 2026
Merged

Drop Node.js addon API, use WASM backend exclusively#720
K20shores merged 19 commits intomainfrom
copilot/drop-node-addon-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 24, 2025

This PR

  • removes node addon api code and setup in favor of wasm
  • converts all of the code to be compliant with ES6 modules
  • Updates the example.html to show how musica can be run directly in the browser (image below)
Screenshot 2025-12-24 at 6 58 23 PM

Now we are well on our way to replacing the server-side component of musica box interactive.

Copilot AI changed the title [WIP] Remove node addon API and simplify JavaScript structure Drop Node.js addon API, use WASM backend exclusively Dec 24, 2025
Copilot AI requested a review from K20shores December 24, 2025 21:24
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 24, 2025

Codecov Report

❌ Patch coverage is 97.20280% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.63%. Comparing base (a5e0f2a) to head (8467baf).

Files with missing lines Patch % Lines
javascript/backend.js 94.73% 2 Missing ⚠️
javascript/micm/state.js 71.42% 2 Missing ⚠️
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     
Flag Coverage Δ
cpp_fortran 69.60% <ø> (ø)
javascript 94.00% <97.20%> (+8.89%) ⬆️
python 82.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@K20shores
Copy link
Copy Markdown
Collaborator

@copilot there are 2 index files

  • javascript/index.js
  • javascript/wasm/index.js

I only want one. Update package.json accordingly

There are also two micm tests:

  • javascript/tests/unit/micm/micm.test.js
  • javascript/tests/unit/micm_wasm.test.js

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]>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 24, 2025

@copilot there are 2 index files

  • javascript/index.js
    ...

Done in 171fcb5. Consolidated into single javascript/index.js with WASM functionality merged in. Removed javascript/wasm/index.js and updated package.json to remove the ./wasm export. Combined test files by removing javascript/tests/unit/micm_wasm.test.js (all tests covered in main test files).

@K20shores K20shores marked this pull request as ready for review December 25, 2025 00:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@K20shores K20shores merged commit 74d0f12 into main Jan 5, 2026
46 of 53 checks passed
@K20shores K20shores deleted the copilot/drop-node-addon-api branch January 5, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop node addon api

5 participants