feross / timidity

Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity
https://bitmidi.com
MIT License
368 stars 38 forks source link

Is the brfs browserify transform not applied in the published build? #3

Closed captbaritone closed 5 years ago

captbaritone commented 5 years ago

I spent some time last night looking into how feasible it would be to setup timidity as a sort of "codec" for webamp.org. I've tried importing timidity and I'm getting this error in my webpack build:

ERROR in ./node_modules/timidity/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/jeldredge/projects/webamp/node_modules/timidity'
 @ ./node_modules/timidity/index.js 3:11-24
 @ ./js/index.js

Looking at the source I see the comment: // Inlined at build time by 'brfs' browserify transform right above that line.

I'm seeing this in both version 1.0.0 and 1.0.1.

Am I expected to run the brfs browserify transform in my own project?

Any guidance would be appreciated. Thanks for the awesome project. I'm enjoying the JSParty podcast talking about bitmidi!

feross commented 5 years ago

I'm not sure what it takes to get brfs to work in webpack. I think you need to teach webpack about the "browser" field in package.json somehow? There may be an option or a plugin to do that.

https://github.com/defunctzombie/package-browser-field-spec

captbaritone commented 5 years ago

Got it. Thanks.