Closed yilihjy closed 3 years ago
Hi @yilihjy,
Thanks for taking a swing at it. I think we can do this without the extra dependencies and just minor config changes to rollup.config.js. You can see how we handled in MidiPlayerJS:
You want to give that a shot?
Hi @grimmdude , I have trid your former advice. But when I had reomved the dependence of @rollup/plugin-replace
, some bad things happened.
In my vue nuxt project (a webpack project), some error occured , like below:
ERROR Failed to compile with 1 errors friendly-errors 11:01:43
This dependency was not found: friendly-errors 11:01:43
friendly-errors 11:01:43
* fs in ./node_modules/midi-writer-js/browser/midiwriter.js friendly-errors 11:01:43
friendly-errors 11:01:43
To install it, you can run: npm install --save fs friendly-errors 11:01:43
To deal with it, I created a rollup.config.browser.js for browser build.
Now, there are three new files in brower folder.
brower/index.mjs
It is a esm file for webpack project. Just use import MidiWriter from 'midi-writer-js'
to use in webpack project.
midiwriter.bundle.js
and midiwriter.bundle.min.js
for Githubissues.
Hello, I have did a little work to support this lib to run in browser. This change only add a browser.js file in build folder. When somebody want to use this lib to create a .mid file in browser, use this new file. For example, I use this lib in a vue project like below:
These code run well!