When our team tried to use tinify into a AWS Lambda function using Typescript the file node_modules/tinify/lib/data/cacert.pem
wasn't copied properly so the transpiled code could not find it and Tinify would fail.
Thanks to @shannonhochkins and his postinstall idea to inject the value of cacert.pem into Client.js.
- Create a
scripts/
folder on your project. - Create a file called
tinify-inject-cacertpem.js
inside thescripts/
folder. - Copy the contents from the file of this gist.
- Add a postinstall script into your
package.json
{
"scripts": {
"postinstall": "node ./scripts/tinify-inject-cacertpem.js"
}
}
With this script the cacert.pem will be injected into tinify/Client.js and it will not have issues when transpiting with Typescript.
Thank you for sharing it👍
This is a quick "optimization" by GitHub Copilot.