Thank you for your interest in contributing to this plugin! This guide will help you set up your development environment and test your changes.
- Node.js (version 18 or higher recommended)
- npm or yarn
- Git
git clone https://github.com/nolway/wa-map-optimizer-vite.git
cd wa-map-optimizer-vitenpm installnpm run buildThis compiles the TypeScript source files from src/ to dist/.
-
Create a new branch for your feature or bugfix:
git checkout -b feature/my-new-feature
-
Edit the source code in
src/index.ts -
Build the plugin to check for TypeScript errors:
npm run build
-
Lint and format your code:
npm run lint npm run format
-
Run the tests:
npm test
Before committing your changes, ensure all checks pass:
- No TypeScript errors:
npm run buildcompletes successfully - Linting passes:
npm run linthas no errors - Code is formatted:
npm run formathas been run - Tests pass:
npm testverifies the plugin works correctly
The project uses:
- ESLint for code linting
- Prettier for code formatting
- Husky for git hooks (automatically runs lint-staged on commit)
- Integration tests in the
test/directory
The plugin includes automated integration tests in the test/ directory.
# Run all tests (builds plugin, runs test build, verifies output)
npm test
# Or manually:
npm run build # Build the plugin
cd test
npm install # Install test dependencies
npm run build # Build test project
npm test # Verify the outputThe test suite verifies:
- ✅ Compiled JS files are generated
- ✅ HTML wrapper files are created
- ✅ HTML wrappers include
iframe_api.js - ✅ HTML wrappers reference the correct JS files
- ✅ TMJ maps are optimized
- ✅ TMJ script properties point to HTML files
- ✅ Hash matching between JS and HTML files
See test/README.md for more details on the test structure.
Since this is a Vite plugin, you can also test it manually with a real project.
The easiest way to manually test the plugin is with the official WorkAdventure map starter kit, which already has the proper structure and dependencies.
- Clone the map-starter-kit in a separate directory:
cd ~/projects # or wherever you keep your projects
git clone https://github.com/workadventure/map-starter-kit.git wa-plugin-test
cd wa-plugin-test- Install dependencies:
npm install- Link your local plugin (from your plugin development directory):
# First, create a global link from the plugin directory
cd /path/to/wa-map-optimizer-vite
npm link
# Then, link it in the map-starter-kit
cd ~/projects/wa-plugin-test
npm link wa-map-optimizer-vite- Rebuild to test your changes:
npm run build- Test with the development server:
npm run devOpen the provided URL in your browser and verify that:
- The map loads correctly
- Scripts are executed
- The WorkAdventure API is available
When you're done testing, unlink the plugin:
cd ~/projects/wa-plugin-test
npm unlink wa-map-optimizer-vite
npm install # Reinstall the published versionWhen you make changes to the plugin:
-
Rebuild the plugin:
cd /path/to/wa-map-optimizer-vite npm run build -
Rebuild the test project:
cd ~/projects/wa-plugin-test npm run build
-
Verify the changes in
dist/
Tip: Keep two terminal windows open - one in the plugin directory and one in the test project for faster iteration.
This project follows conventional commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting, etc.)refactor:- Code refactoringtest:- Adding or updating testschore:- Maintenance tasks
Examples:
feat: add support for custom HTML template in wrapper
fix: correct hash extraction regex for script filenames
docs: update CONTRIBUTING.md with map-starter-kit instructions