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

version loading throws an error when bundled #88

Open
mfulton26 opened this issue Jan 18, 2024 · 0 comments
Open

version loading throws an error when bundled #88

mfulton26 opened this issue Jan 18, 2024 · 0 comments

Comments

@mfulton26
Copy link

I'm using prest-client in a project that bundles code using Webpack and the following line throws:

lib.version = JSON.parse(fs.readFileSync(__dirname + '/package.json')).version;

I've created a patch locally using yarn but others might run into this too. Node.js and Webpack support importing package.json directly which should be well supported by other bundlers that support Node.js:

diff --git a/index.js b/index.js
index 0f5fe1cb2b9ce459711f1eb29eaa002405f0fd60..e77aed24d74cf5b5eb3e3c9a4d14b2631516ce9f 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,6 @@
 var fs = require('fs');
 
 var lib = require('./lib/presto-client');
-lib.version = JSON.parse(fs.readFileSync(__dirname + '/package.json')).version;
+lib.version = require('./package.json').version;
 
 exports.Client = lib.Client;
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

1 participant