Skip to content

Conversation

@eatsjobs
Copy link

3.0.0 Migration to typescript and esm, modern build workflow

Howler.js v3.0, major rewrite that migrates the library to TypeScript and introduces a modern plugin architecture.
Uses tsdown, publint @arethetypeswrong/cli tool

Breaking Changes

  • ES Modules Only: Howler.js v3.0+ is distributed exclusively as ES Modules. For CommonJS/UMD support, use v2.x.
  • TypeScript: The library is now written in TypeScript with full type definitions included.
  • Spatial Plugin: The spatial audio functionality has been moved to a plugin that must be explicitly registered.
  • Browser Support: Requires modern browsers with ES Module support (Chrome 61+, Firefox 67+, Safari 11.1+, Edge 79+). https://caniuse.com/?search=esm

New Features

  • ADDED Complete TypeScript rewrite with full type definitions
  • ADDED Modern plugin system with hook-based architecture (HowlerPlugin, PluginManager)
  • ADDED Spatial audio plugin refactored to use the new plugin system
  • ADDED Lightweight UA parser for consistent browser/device detection
  • ADDED TypeScript types exported: SpatialHowler, SpatialHowl, SpatialHowlOptions
  • ADDED Plugin lifecycle hooks: onHowlerInit, onHowlCreate, onSoundCreate, onHowlLoad, onHowlDestroy, onUnregister
  • ADDED Howler.addPlugin() and Howler.removePlugin() methods for plugin management
  • ADDED Howler.hasPlugin() method to check if a plugin is registered
  • ADDED Import map examples in documentation for cleaner CDN usage
  • ADDED Comprehensive TypeScript examples throughout documentation

Improvements

  • CHANGED All user agent detection now uses centralized light-ua-parser functions
  • CHANGED Spatial plugin properly cleans up state when unregistered
  • CHANGED Plugin hooks execute correctly for both HTML5 and WebAudio backends
  • CHANGED Improved error handling in plugin system
  • CHANGED Better separation of concerns with modular architecture
  • CHANGED All code examples migrated to TypeScript with proper types

eatsjobs and others added 24 commits November 22, 2025 02:49
Since plugins are enabled by default when registered and automatically
removed when unregistered, the enable/disable/isEnabled methods add
unnecessary complexity. Plugins now have a simpler lifecycle: registered
means active, unregistered means inactive.

Changes:
- Remove enable/disable/isEnabled methods from PluginManager
- Remove enabled flag from RegisteredPlugin interface
- Simplify _executeHooks to always execute for registered plugins
- Update README documentation to remove enable/disable examples

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

Co-Authored-By: Claude <[email protected]>
- Added comprehensive details about the breaking changes, new features, and improvements in the CHANGELOG for the first alpha release of Howler.js v3.0, including the migration guide from v2.x.
- Updated README to reflect the new TypeScript support, plugin registration, and usage examples, including HTML import maps for cleaner module imports.
- Enhanced documentation with TypeScript type annotations and examples for better developer experience.
…consistency

- Removed the `init` method from HowlerGlobal and directly initialized properties in the constructor for clarity.
- Replaced `self` references with `this` for consistency across methods.
- Simplified the plugin registration process by removing the `onRegister` hook from the PluginHooks interface, streamlining the plugin lifecycle.
- Enhanced documentation comments for better understanding of plugin initialization behavior.

This refactor aims to enhance code maintainability and readability while ensuring existing functionality remains intact.
- Expanded TypeScript types in `types.ts` to include custom interfaces for HTML5 audio elements and audio nodes, improving type safety and clarity.
- Updated `HowlerGlobal` and `Sound` classes in `howler.core.ts` to utilize new types, ensuring better type checking and reducing potential runtime errors.
- Refined audio handling logic to incorporate type guards for audio nodes, enhancing the robustness of audio playback and manipulation.
- Improved error handling in `audio-loader.ts` by creating a more descriptive error event for XMLHttpRequest failures.
- Adjusted spatial plugin connections to ensure compatibility with the new type definitions.

These changes aim to enhance the overall developer experience and maintainability of the codebase while ensuring existing functionality remains intact.
- Introduced a new `biome.json` configuration file to manage project settings, including VCS, file includes, formatter, and linter options.
- Updated `package.json` to include `@biomejs/biome` as a development dependency, ensuring compatibility with the new configuration.
- Modified `package-lock.json` to reflect the addition of the new dependency and its associated metadata.
- Ensured consistent formatting across various files by standardizing indentation and style.

These changes aim to enhance project configuration management and maintain consistency in code formatting.
- Added `sideEffects: false` to `package.json` for better tree-shaking.
- Introduced a new `size` script in `package.json` to check the bundle sizes using `check-size.js`.
- Created `check-size.js` to calculate and log the sizes of core and plugin files, including gzip sizes.
- Added `howl.ts`, `howler-global.ts`, `howler.core.ts`, `sound.ts`, and related type definitions to improve audio handling and maintainability.

These changes aim to improve project configuration management and provide developers with tools to monitor bundle sizes effectively.
- Replaced XMLHttpRequest with Fetch API in `audio-loader.ts` for improved performance and modern browser support.
- Updated the `headers` property in the `Howl` class to use `HeadersInit` type for better type safety.
- Enhanced documentation in `types.ts` to clarify the use of fetch options for loading audio files.

These changes aim to modernize the audio loading process and improve type definitions for better maintainability.
… for Howler.js v3.0.0-alpha.1

- Eliminated old license comments from multiple source files to streamline code.
- Updated version information in `index.ts` to reflect the new alpha release.
- Ensured consistency in code formatting and improved readability across various files.

These changes aim to modernize the codebase in preparation for the upcoming release.
- Modified `package.json` to change the repository URL format and added new development dependencies: `@arethetypeswrong/core` and `publint`.
- Updated `package-lock.json` to reflect changes in dependencies and their versions.
- Adjusted `tsdown.config.ts` to specify entry points for bundling, disable unbundling for plugins, and enhance minification settings.
- Revised `check-size.js` to reflect changes in file structure due to bundling configuration.

These updates aim to improve project configuration, enhance dependency management, and streamline the build process.
- Changed section headers from '###' to '##' for improved readability and uniformity in the pull request template.
- Ensured the template aligns with standard markdown practices for better presentation.

These updates aim to enhance the clarity and usability of the pull request template.
- Introduced a new `cache.ts` file to implement a global cache for decoded audio buffers, allowing multiple Howl instances to share audio data.
- Updated imports in `howl.ts`, `howler.core.ts`, and `audio-loader.ts` to utilize the new cache implementation, enhancing audio data management and performance.

These changes aim to improve audio handling efficiency and reduce memory usage across Howl instances.
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.

1 participant