Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version 17 or higher recommended
Yarn
Version 3.0.1 (managed via packageManager)
Git
For cloning the repository
Code Editor
VSCode or your preferred editor with ESLint support
Installation
Install Dependencies
Install all package dependencies using Yarn:
The
postinstall script will automatically run after installation to set up the environment and apply patches.Development Build
Running the Development Server
Start the development build with hot-reloading:The
yarn dev command is an alias for yarn watch-dev, which includes inline source maps for better debugging.What Happens During Development Build?
When you run the development command:- Webpack compiles the extension in development mode
- Watch mode monitors file changes for hot-reloading
- Source maps are generated for debugging
- Build output is placed in
packages/extension-koni/build/
Loading the Extension in Browser
- Chrome/Edge
- Firefox
Production Build
Full Build Process
Create a production-ready build:Individual Build Commands
Build UI Only
Build UI Only
Build just the UI components in production mode:This runs Webpack in production mode for the extension UI.
Build Internationalization
Build Internationalization
Build i18n locale files:
Build ZIP Files
Build ZIP Files
Create distribution ZIP archives:This creates:
master-build.zip- Chrome/Edge buildmaster-build-firefox.zip- Firefox buildmaster-src.zip- Source code archive
Build for Release
Build for Release
Create a GitHub Actions release build:
Output Directories
After building, you’ll find compiled files in:packages/extension-koni/build/- Chrome/Edge extensionpackages/extension-koni/build-firefox/- Firefox extensionmaster-build.zip- Packaged Chrome/Edge extensionmaster-build-firefox.zip- Packaged Firefox extension
Code Quality
Linting
SubWallet Extension enforces code quality with ESLint:Setting Up ESLint in Your Editor
For the best development experience, configure ESLint in your editor:- VSCode
- Other Editors
Install the ESLint extension:
- Open Extensions (Ctrl+Shift+X)
- Search for “ESLint”
- Install the official ESLint extension
- Reload VSCode
.eslintrc.js will be automatically detected.Testing
Running Tests
SubWallet uses Jest for testing:Writing Tests
Create test files with the.spec.ts extension:
Tests are automatically discovered by Jest. Files matching
*.spec.ts or *.test.ts patterns will be executed, except those in node_modules or matching ignore-* patterns.Cleaning Build Artifacts
Remove all build artifacts and start fresh:packages/extension-koni/build/packages/extension-koni/build-firefox/- Other generated files
Internationalization (i18n)
SubWallet supports multiple languages. Here are the i18n-related commands:Scan for Translation Keys
Scan for Translation Keys
Combine Locale Files
Combine Locale Files
Update Extension Translations
Update Extension Translations
Update Web/Mobile Translations
Update Web/Mobile Translations
Updating Dependencies
Polkadot Libraries
Update all Polkadot-related dependencies:- @polkadot/api
- @polkadot/util
- @polkadot/util-crypto
- And other Polkadot ecosystem packages
SubWallet Libraries
Update SubWallet-specific dependencies:- @subwallet/chain-list
- @subwallet/keyring
- @subwallet/ui-keyring
Development Workflow Best Practices
Troubleshooting
Yarn Version Mismatch
Yarn Version Mismatch
If you encounter version issues, ensure you’re using the correct Yarn version:The project uses Yarn 3.0.1 as specified in
packageManager.Build Errors After Pull
Build Errors After Pull
After pulling new changes, clean and reinstall:
Extension Not Loading in Browser
Extension Not Loading in Browser
- Ensure the build completed successfully
- Check the correct directory is selected (
build/for Chrome,build-firefox/for Firefox) - Try removing and re-adding the extension
- Check browser console for errors
Port Already in Use
Port Already in Use
If Webpack dev server fails to start, check if another process is using the port:
Next Steps
Now that your development environment is set up:Understand the Architecture
Learn about the extension’s architecture and components
View Contributing Guidelines
Read the contribution guidelines
Explore the Codebase
Browse the source code on GitHub
Join the Community
Report issues and engage with developers