-
Notifications
You must be signed in to change notification settings - Fork 263
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
Comments
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. |
I actually experience the following error with webpack:
Coming from I think it's suggested to wrap |
I have eventually sorted it out, as far as I'm concerned. |
+1
|
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. |
If anyone comes here looking for a solution for Webpack, this fixed the problem for us:
Simply replace |
This pull request #622 solves the main problem that prevents @mapbox/node-pre-gyp from working with webpack. webpack needs to know where package.json and the .node file are located during the build process. Right now both locations are determined at run-time instead of during the build process. Using @springmeyer a couple reasons webpack is useful include
You could argue that webpack isn't necessary (it's much more useful for front-end development than back-end development), but you might be stuck using a node framework that depends on webpack. |
To add why we use webpack, it's for deployment in lambda. |
@springmeyer any chance you can merge #622 ? |
any workaround for this ? |
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 thefind(package_json_path, opts)
function inlib/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:Any thoughts?
References
The text was updated successfully, but these errors were encountered: