Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical dependency: the request of a dependency is an expression #6

Open
iva2k opened this issue Sep 19, 2021 · 4 comments
Open

Critical dependency: the request of a dependency is an expression #6

iva2k opened this issue Sep 19, 2021 · 4 comments

Comments

@iva2k
Copy link

iva2k commented Sep 19, 2021

Using [email protected] package (which has jazz-midi package as a dependency) in a React app (create-react-app), gets this warning:

./node_modules/jazz-midi/index.js
Critical dependency: the request of a dependency is an expression

The problem is any CI flow treats warnings as errors and chokes on it.

Looking into ./node_modules/jazz-midi/index.js:

var path='./bin/';
var v=process.versions.node.split('.');
if (v[0]<=10) path+='10_15/';
else if (v[0]<=11) path+='11_15/';
if(process.platform=="win32"&&process.arch=="ia32") path+='win32/jazz';
else if(process.platform=="win32"&&process.arch=="x64") path+='win64/jazz';
else if(process.platform=="darwin"&&process.arch=="x64") path+='macos64/jazz';
else if(process.platform=="linux"&&process.arch=="x64") path+='linux64/jazz';
else if(process.platform=="linux"&&process.arch=="arm") path+='linuxa7/jazz';
module.exports=require(path);
module.exports.package=require(__dirname + '/package.json');

... which has a dynamic require().

Webpack docs explain it here:
https://webpack.js.org/guides/dependency-management/#require-with-expression

@iva2k
Copy link
Author

iva2k commented Sep 19, 2021

A better approach is to use webpack require.context(). Will you accept a PR with such fix?

@jazz-soft
Copy link
Owner

This module is not required for browser applications.
It looks like a similar issue was addressed in https://github.com/tuzemec/jzz-webpack-test

@wookayin
Copy link

wookayin commented Nov 22, 2021

Electron applications that have webpack configured will be blocked by this. (For example, I was starting off from the boilerplate https://github.com/electron-react-boilerplate) Can we have this fixed?

@wookayin
Copy link

wookayin commented Nov 22, 2021

Although being a hack, I found this works well with webpack:

const require_dynamic = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
module.exports = require_dynamic(path);
module.exports.package = require_dynamic(__dirname + '/package.json');

Ref: https://stackoverflow.com/questions/42797313/webpack-dynamic-module-loader-by-require

thirtythreeforty added a commit to thirtythreeforty/jazz-midi that referenced this issue Oct 10, 2023
The pthread and lock are never created if the "if" in the constructor
fails, and the members are never initialized.  But the destructor
unconditionally destroys them.  Fix this by adding a guard flag.

This fixes a segfault I encountered on Arch with Pipewire as the ALSA
server.

    Thread 1 "node" received signal SIGSEGV, Segmentation fault.
    0x00007ffff428aebd in pthread_cancel () from /usr/bin/../lib/libc.so.6
    (gdb) bt
    #0  0x00007ffff428aebd in pthread_cancel () from /usr/bin/../lib/libc.so.6
    jazz-soft#1  0x00007ffff3b773ff in CMidiInHW::~CMidiInHW (this=0x55555572a430, __in_chrg=<optimized out>) at ../../midi/MidiALSA.cpp:366
    jazz-soft#2  0x00007ffff3b77452 in CMidiInHW::~CMidiInHW (this=0x55555572a430, __in_chrg=<optimized out>) at ../../midi/MidiALSA.cpp:369
    jazz-soft#3  0x00007ffff3b77105 in CMidiALSA::MidiInOpen[abi:cxx11](wchar_t const*, void*) (this=0x5555557b9880, name=0x5555556b3cf0 L"input", p=0x55555579e3a0) at ../../midi/MidiALSA.cpp:329
    jazz-soft#4  0x00007ffff3b6f0c8 in MidiInOpen (env=0x55555579e410, args=0x7fffffff9e20) at ../jazz-midi.cpp:461
    jazz-soft#5  0x00007ffff535bd33 in ?? () from /usr/bin/../lib/libnode.so.115
    jazz-soft#6  0x00007ffff5840d97 in ?? () from /usr/bin/../lib/libnode.so.115
    jazz-soft#7  0x00007ffff5841942 in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) () from /usr/bin/../lib/libnode.so.115
    jazz-soft#8  0x00007ffff56cadf6 in ?? () from /usr/bin/../lib/libnode.so.115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants