-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
WIP: Modernize howler.js to use native ES modules, export TypeScript definitions, and use a modern build system #1518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Modernize howler.js to use native ES modules, export TypeScript definitions, and use a modern build system #1518
Conversation
...ll tests! TypeScript makes large refactors like this one so much easier!
...! Needs thorough testing for other browsers, but this is a promising start!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Muting with Web Audio API doesn't work in Firefox 93 for windows.
Interestingly enough, the 2.x version of the library + tests doesn't work in Firefox either!
In Chrome 94, both the 2.x and 3.x versions work as expected.
Could this be a general bug that is related to the implementation details, rather than the refactoring?
@profispojka By no means is howler.js dead. It is a mature library that doesn't need lots of changes all the time, but that doesn't mean work isn't continuing on it.
7ombie
commented
Jul 24, 2022
It is a mature library that doesn't need lots of changes all the time.
@goldfire - Six months later, and Howler still doesn't work properly in modern browsers. It clearly needs a lot of changes at this time.
Hey @profispojka - Nice work.
My issue was the lack of a modern ES6 module. Like many people, I'm a web developer, but not a JavaScript programmer. We don't really use Node, NPM, Webpack or anything like that.
It seemed odd for a project that promotes its use in the browser, but can't be imported (implying the need for a major refactoring), to claim that "it's a mature library that doesn't need changes all the time".
beefchimi
commented
Mar 25, 2023
In case it will be of interest to anyone in this thread:
I have my own library called earwurm, which is written in TypeScript and packaged for both umd.js and es.js. It does not have the full feature set that Howler has... one day I hope to implement more features. But for now, if all you need is a way to fetch and play .webm files, it is working really well.
AlexanderMelde
commented
Oct 5, 2023
@goldfire This feature would still be very useful when using howler in typescript projects, do you think there is any chance of implementing this into the main branch someday? :)
Noaber
commented
Feb 3, 2025
Dare to ask, what is the status of this ? I still get in Angular18 a warning about commonjs
Hi! Thanks for creating and maintaining this library for so many years! It's clear this has provided immense value to developers all over the world 😄
However, I need native ESM modules for one of my projects, which got me thinking. I didn't want to develop another library like howler.js from scratch (because of all the browser quirks you've already solved and tested here). But I couldn't stick to using the Common JS exports of
howler.js@2.x.So I spent this entire day refactoring the core
howler.jslibrary into native ES modules, ES classes, upgraded to a modern build system usingesbuild, slightly improved the test setup usingvite, added native TypeScript definition files, and kept the original public API as well as private implementation details almost entirely intact.And... After many many hours, on literally the second test run, I got the full test suite for both
Web AudioandHTML5to run successfully!!! This is a extremely promising start 😄This was made possible thanks to the mostly complete TS definitions from @types/howler, the JS Doc comments and good initial structure in the howler.js codebase, and most importantly - the immense value from using the TypeScript compiler to provide hints during refactoring projects like this one. TypeScript provided a clear progress to see what remained to fix, which was really nice.
Next steps
2.xbuild output in/dist.I'd be happy to keep improving this, but I'll need help to test, review and prepare for the 3.0 release. Any feedback and help would be greatly appreciated! :)