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

how to optimize so that next js can see it after deployment in vercel? #48

Open
sabrenda opened this issue Feb 13, 2024 · 2 comments
Open

Comments

@sabrenda
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/tinify/lib/tinify/Client.js b/node_modules/tinify/lib/tinify/Client.js
index 09b1eb7..e9d4064 100644
--- a/node_modules/tinify/lib/tinify/Client.js
+++ b/node_modules/tinify/lib/tinify/Client.js
@@ -7,7 +7,7 @@ const proxyAgent = require("proxying-agent");
 const package_json_1 = require("../../package.json");
 const tinify_1 = require("../tinify");
 const boundaries = /-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----\n/g;
-const data = fs.readFileSync(`${__dirname}/../data/cacert.pem`).toString();
+const data = fs.readFileSync(`${process.cwd()}/cacert.pem`).toString();
 class Client {
     /** @internal */
     constructor(key, appIdentifier, proxy) {

This issue body was partially generated by patch-package.

@sabrenda sabrenda changed the title this is in order for the code to work in next js, you can make a separate branch how to optimize so that next js can see it after deployment in vercel? Feb 13, 2024
@sabrenda sabrenda reopened this Feb 13, 2024
@rkoopmans
Copy link
Contributor

Hi Sabrenda,

Thanks for the patch. I understand that __dirname can be '/' on development (vercel/next.js#14341). Is that why it was not working for you?

The approach of getting the current working dir (process.cwd()) might break the library for other people. We will have to implement a solution that works for both.

@rkoopmans
Copy link
Contributor

Would you be able to share with me how you are using the Tinify client with Vercel? That would help us reproduce the issue.

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

2 participants