Skip to content

Conversation

@pcarranzav
Copy link
Member

Summary

This PR migrates the json-encoder-web build system from wasm-pack to using wasm-bindgen directly, addressing maintenance concerns with wasm-pack and giving us more control over the build process.

Changes

  • Build System Migration:

    • Created build-wasm.js script that directly calls cargo build and wasm-bindgen
    • Removed dependency on @wasm-tool/wasm-pack-plugin and wasm-loader
    • Updated webpack config to use Webpack 5's native asyncWebAssembly support
  • CI/CD Updates:

    • Updated GitHub Actions workflow to install Rust toolchain with wasm32-unknown-unknown target
    • Added wasm-bindgen-cli installation step (v0.2.100)
  • Import Path Update:

    • Changed import from './pkg' to './pkg/json_encoder_web' to match wasm-bindgen output
  • Housekeeping:

    • Added .gitignore for generated files (pkg/, dist/, target/)
    • Cleaned up package.json dependencies

Benefits

  1. More Control: Direct control over compilation flags and build process
  2. Better Error Messages: Direct access to cargo and wasm-bindgen output
  3. No External Dependencies: No need to install wasm-pack globally
  4. Modern Webpack Integration: Uses Webpack 5's native WebAssembly support

Testing

  • ✅ Build process works correctly (npm run build)
  • ✅ Development server works (npm run serve)
  • ✅ WASM functionality verified in browser
  • ✅ CI/CD workflow updated

Migration Notes

Developers will need to install:

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli --version "0.2.100"

🤖 Generated with Claude Code

- Replace wasm-pack with direct wasm-bindgen CLI usage
- Create build-wasm.js script to handle Rust compilation and bindings generation
- Update webpack config to use native asyncWebAssembly support
- Remove @wasm-tool/wasm-pack-plugin and wasm-loader dependencies
- Update GitHub Actions CI to install Rust toolchain and wasm-bindgen
- Add .gitignore for generated files (pkg/, dist/, target/)
- Update import path in index.ts to match wasm-bindgen output

This migration gives us more control over the build process and removes
dependency on wasm-pack which had maintenance concerns.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
tmigone
tmigone previously approved these changes Aug 4, 2025
@pcarranzav pcarranzav merged commit 158234c into main Aug 4, 2025
5 checks passed
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.

3 participants