Thank you for your interest in contributing to WasmWorker! This document provides guidelines and instructions for contributing.
- Node.js >= 20.0.0
- pnpm >= 8.0.0
- Rust toolchain (for WASM examples)
- Install from: https://rustup.rs/
- Add wasm32 target:
rustup target add wasm32-unknown-unknown
-
Clone the repository
git clone https://github.com/yourusername/wasmworker.git cd wasmworker -
Install dependencies
pnpm install
-
Build all packages
pnpm build
-
Build WASM examples
cd examples/rust-add ./build.sh cd ../..
-
Run tests
pnpm test -
Run the demo
pnpm demo
wasmworker/
├── packages/sdk/ # Main SDK package
│ ├── src/
│ │ ├── index.ts # Public API
│ │ ├── bridge.ts # WasmWorker class
│ │ ├── types.ts # TypeScript definitions
│ │ └── worker/
│ │ └── runtime.ts # Worker runtime
│ └── tests/ # Unit tests
├── apps/demo/ # Demo application
├── examples/ # Example WASM modules
│ └── rust-add/ # Rust example
└── README.md
-
Create a new branch
git checkout -b feature/your-feature-name
-
Make your changes
- Follow the existing code style
- Write tests for new functionality
- Update documentation as needed
-
Run quality checks
# Type checking pnpm typecheck # Run tests pnpm test # Build packages pnpm build
-
Commit your changes
git add . git commit -m "feat: add your feature description"
We follow conventional commit format:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Adding or updating testsrefactor:- Code refactoringperf:- Performance improvementschore:- Build process or auxiliary tool changes
Examples:
feat: add streaming API support
fix: handle worker termination edge case
docs: update API reference with examples
test: add concurrency tests
-
Ensure all checks pass
- Tests pass
- TypeScript compiles without errors
- Code follows project style
-
Update documentation
- Update README.md if needed
- Add JSDoc comments for new public APIs
- Include examples for new features
-
Submit PR
- Provide clear description of changes
- Reference any related issues
- Include screenshots/demos for UI changes
- Use TypeScript strict mode
- Prefer
constandletovervar - Use descriptive variable names
- Add JSDoc comments for public APIs
- Use type annotations for function parameters and return values
Example:
/**
* Load a WASM module in a new WebWorker
* @param options - Configuration options
* @returns Promise that resolves to WasmWorker instance
*/
static async load(options: LoadOptions): Promise<WasmWorker> {
// implementation
}- Write unit tests for new functionality
- Use descriptive test names
- Follow AAA pattern (Arrange, Act, Assert)
- Mock external dependencies
Example:
describe('WasmWorker', () => {
describe('call', () => {
it('should throw error if worker not initialized', async () => {
// Arrange
const worker = createUninitializedWorker();
// Act & Assert
await expect(worker.call('test', {}))
.rejects.toThrow('Worker not initialized');
});
});
});- Add types to
packages/sdk/src/types.ts - Implement in appropriate file (
bridge.ts,worker/runtime.ts) - Export from
packages/sdk/src/index.ts - Add tests in
packages/sdk/tests/ - Update README.md with documentation
- Add example to demo app
- Create new directory in
examples/ - Add
Cargo.tomlfor Rust projects - Implement functions in
src/lib.rs - Add
build.shscript - Update
package.jsonwith build script - Document in example's README.md
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests for specific package
cd packages/sdk && pnpm test- Unit tests go in
packages/sdk/tests/ - E2E tests can be added to
apps/demo/ - Test file naming:
*.spec.ts
Update README.md when:
- Adding new public APIs
- Changing existing behavior
- Adding new examples
- Updating requirements
- Add JSDoc for all public APIs
- Use inline comments for complex logic
- Keep comments up-to-date with code changes
- Profile before optimizing
- Consider message passing overhead
- Use Transferables for large buffers
- Avoid unnecessary copies
- Test with realistic workloads
- Never commit sensitive data
- Validate all inputs
- Handle errors gracefully
- Follow OWASP guidelines
- Report security issues privately
- Open an issue for bugs or feature requests
- Ask questions in discussions
- Check existing issues before creating new ones
By contributing to WasmWorker, you agree that your contributions will be licensed under the MIT License.
- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Help others learn and grow
Thank you for contributing to WasmWorker!