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

Can't resolve 'fs', brfs browserify problem? #20

Open mohkoma opened 3 years ago

mohkoma commented 3 years ago

I'm having hard time to make this package work, I'm keep getting that fs and a modules are missing, I found similar one in the previous issues but I still can't solve it. I'm using Nuxtjs SSR/webpack and I have never used the browserify.

Is there any clear way to get it work?

image

I appreciate it and thank you in advance 🙏

connorjclark commented 2 years ago

Some bundlers handle this automatically (example: parcel will inline fs.readFile, but esbuild requires a plugin to do so). If you can't or don't want to configure your bundler to inline this, do what I did:

npx brfs node_modules/timidity/index.js > node_modules/timidity/index.js.tmp
mv node_modules/timidity/index.js.tmp node_modules/timidity/index.js

Put that code in your build script, and then your bundler will only see a file that has already inlined that big file.