Open tatban opened 2 years ago
Hi @tatban, sorry for the long delay. I plan to add a fully compiled bundle to all my open source packages since this was requested by a couple of people. I just need some time to figure out the "right" format.
chrisguttandin/automation-events#49
In the meantime we could try to solve your specific problem. It looks like you don't reference the browserify bundle in the HTML code you posted above. Could that maybe be the problem? Which code do you use to generate the bundle?
I would love to know how this turned out, as my experiment has a similar structure to tatban's.
I also used browserify. I attached to html script tag as
the js i used as my test bundle source for browserify was:
var extendableMediaRecorder=require('extendable-media-recorder');
var extendableMediaRecorderWavEncoder=require('extendable-media-recorder-wav-encoder');
and I used the following import statements in my main source js:
import { MediaRecorder, register } from './wavBundle.js';
import { connect } from './wavBundle.js';
getting the following error:
Uncaught SyntaxError: The requested module './wavBundle.js' does not provide an export named 'MediaRecorder'
Hi @siriusrex,
I would expect that you need to re-export MediaRecorder
, register
and connect
from './wavBundle.js' in order to import them elsewhere. Where is the error coming from? Is it thrown by Browserify or the browser itself?
Any updates on a pre-bundled version of this library? Like a dist.js? I'm using the code in a script tag in my index.html like this:
<script type="module">
import { MediaRecorder, register } from 'https://dev.jspm.io/npm:extendable-media-recorder';
import { connect } from 'https://dev.jspm.io/npm:extendable-media-recorder-wav-encoder';
</script>
but I really need to be able to import it like a normal npm library to use this code. This appears to be the only library that does what I need, so it would be really helpful for myself and others to be able to use this without requiring the addition of a bundler into a project's pipeline.
edit: if it helps, i got it working in react by bundling it in rollup. keep in mind i have never used rollup before now and barely know what i'm doing, so this is probably hot garbage. I also had to add lint ignore comments in the files after bundling. below is my rollup config:
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
export default {
input: 'node_modules/extendable-media-recorder/build/es2019/module.js',
// input: 'node_modules/extendable-media-recorder-wav-encoder/build/es2019/module.js',
output: {
file: 'extendable-media-recorder.dist.js',
// file: 'extendable-media-recorder-wav-encoder.dist.js',
format: 'umd', // Use UMD or CJS for compatibility with Node.js module system
// name: 'extendable-media-recorder-wav-encoder', // Name of the global variable when scripts is included in a HTML page
name: 'extendable-media-recorder', // Name of the global variable when scripts is included in a HTML page
exports: 'named',
globals: {
react: 'React'
}
},
plugins: [
resolve(),
commonjs()
],
external: ['react']
};
and in my react component (files are in src/lib): import { MediaRecorder, register } from '../lib/extendable-media-recorder.dist.js'; import { connect } from '../lib/extendable-media-recorder-wav-encoder.dist.js';
I am quite new to js and I am struggling to build a simple browser based audio recording prototype using html and js in front end and python flask as backend. I would like to use your MediaRecorder seamlessly in place of default MediaRecorder to get the output in WAV format (which is currently not happening due to lack of browser support for wav in default MediaRecorder). I don't want to use jspm, so I tried compiling your module using browserify, but could not make it work ultimately. So, could you please provide a compiled bundle.js and also let me know how do I integrate it with my existing code as follows? (I mean what are the minimal changes required to use your MediaRecorder?):