djipco / webmidi

Tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.).
Apache License 2.0
1.53k stars 115 forks source link

jazz-midi critical dependancy #210

Closed glend1 closed 2 years ago

glend1 commented 2 years ago

everytime I load a page I get the following warning in the browser(chrome) ./node_modules/jazz-midi/index.js Critical dependency: the request of a dependency is an expression.

I am running on a Next.js development server. I don't know why this is happening. Doesn't seem to occur while running a production server.

djipco commented 2 years ago

Yes, I am aware of the warning but, so far, I haven't bee able to work around it. I'm guessing Next.js is using webpack, am I right?

glend1 commented 2 years ago

yes

djipco commented 2 years ago

I made a little progress on that front. Here are the details (this is as much a reference for me as it is a follow-up to the issue):

A solution would be to tell Webpack to not include the jzz module at all (it is NOT needed in the browser). According to the Webpack documentation, this should be possible by using the externals configuration option.

If you simply ignore the warning, what happens is that the jzz module will unnecessarily be included in the bundle even though it will never be used. This is not a problem per-se but will result in an unnecessarily larger bundle size.

glend1 commented 2 years ago

If i don't use jzz then there isn't any way (that i've been able to find) to write tests for my application.

I'm not sure if I install jzz seperately if webmidi would pick up on it.

djipco commented 2 years ago

For testing purposes, I simply use the CommonJS version (webmidi.cjs.js). I also use the midi package to create virtual MIDI ports (if you need that). Check out the test folder for examples.

djipco commented 2 years ago

This is fixed in v3.0.8.