Prior99 / node-libpng

Unofficial bindings for node to libpng.
MIT License
19 stars 11 forks source link

Add an option to set the path to the node bindings. #26

Closed vicb closed 4 years ago

vicb commented 4 years ago

I do build my app with rollup so everything ends up bundled in an index.js at my project root.

When node-libpng tries to resolve the path to the the node bindings (const qualifiedName = path.resolve(__dirname, "..", baseName);, __dirname is the name of my project root folder and node-libpng looks for the file on level up and generates an error:

bundles frontend/src/viewer/flyxc.ts → frontend/static/js...
/usr/local/google/home/berchet/code/flyxc/run/index.js:53560
    throw new Error(`Unable to find native addon file "${fileName.qualifiedName}".`);
    ^

Error: Unable to find native addon file "/usr/local/google/home/berchet/code/flyxc/node-libpng-linux-x64-64.node".

It would be great to add an option to override path.resolve(__dirname, "..").

What I would do it then copy the .node files to my project root and override the folder ?

Does that make sense ?

vicb commented 4 years ago

Closing this issue as it seems there are further issues with dynamic require when I tried to force the path.