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

Compatibility with bundling tools like webpack and rollup #308

Closed
raviqqe opened this issue Jun 20, 2017 · 5 comments

Comments

@raviqqe
Copy link

commented Jun 20, 2017

A way to find binaries by contents of package.json files seems to be needed for compatibility with JS bundlers.

As this code in gRPC's repo, we need to pass paths to package.json to the find(package_json_path, opts) function in lib/pre-binding.js currently.
However, when the paths to package.json are hard-coded in source files like the one of gRPC, bundling tools, such as webpack and rollup, cannot detect the dynamic loading of external files and end up creating bundled files which don't work.

So, we need some function like findByPackageInfo(package_json_content, opts). Then, we can change the code of gRPC like:

var binary = require('node-pre-gyp/lib/pre-binding');
var path = require('path');
var binding_path = binary.findByPackageInfo(require('../../../package.json'));
var binding = require(binding_path);

Any thoughts?

References

@dperetti

This comment has been minimized.

Copy link

commented May 28, 2018

Is node-pre-gyp supposed to work with Webpack... or not ? I've been spending hours on getting a third party library to work, and it seems to boil down to this "package.json does not exist" issue.

@pronebird

This comment has been minimized.

Copy link

commented May 31, 2018

I actually experience the following error with webpack:

Error: Can't resolve 'aws-sdk'

Coming from ./node_modules/node-pre-gyp/lib/unpublish.js

I think it's suggested to wrap require calls for devDependencies in try+catch but I may be wrong.

@dperetti

This comment has been minimized.

Copy link

commented May 31, 2018

I have eventually sorted it out, as far as I'm concerned.
Please read my comment here.

@whisper-bye

This comment has been minimized.

Copy link

commented Aug 14, 2018

+1

./node_modules/fsevents/node_modules/node-pre-gyp/lib/info.js
Module not found: Can't resolve 'aws-sdk' in '/tmp/demo/node_modules/fsevents/node_modules/node-pre-gyp/lib'
@springmeyer

This comment has been minimized.

Copy link
Member

commented Aug 16, 2018

Is node-pre-gyp supposed to work with Webpack... or not ?

No. I designed node-pre-gyp and I've never used webpack nor do I understand what it is. So, its definitely not supposed to work. That said if it is feasible to get it working, I'd review a PR with tests. Until then I'll close this issue to avoid confusion/the assumption that things should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.