alixaxel / chrome-aws-lambda

Chromium Binary for AWS Lambda and Google Cloud Functions
MIT License
3.17k stars 289 forks source link

Add support for nodejs16.x #274

Open styfle opened 2 years ago

styfle commented 2 years ago

https://aws.amazon.com/about-aws/whats-new/2022/05/aws-lambda-adds-support-node-js-16/

shooit commented 2 years ago

@alixaxel It would be awesome to get this one merged so that we are able to run on the latest runtime 🙏

VesterDe commented 2 years ago

We would be really grateful if this can be merged, it's blocking us from upgrading our infra on Lambda. 🙏

bitconym commented 2 years ago

Please merge it, as it's crucial for to use it with Node.js v16.

turakvlad commented 2 years ago

We need this as well. It would be really great if @alixaxel could merge it. Thank you!

Spawnrad commented 2 years ago

It would be really great

bitconym commented 2 years ago

@alixaxel is this repo maintained? Any reason why so much delay with merging this update? Almost 2 months...

urish commented 1 year ago

Works like a charm. I use patch-package with the following patch file as a workaround for now:

diff --git a/node_modules/chrome-aws-lambda/build/index.js b/node_modules/chrome-aws-lambda/build/index.js
index f78e183..599af55 100644
--- a/node_modules/chrome-aws-lambda/build/index.js
+++ b/node_modules/chrome-aws-lambda/build/index.js
@@ -7,7 +7,7 @@ const fs_1 = require("fs");
 const lambdafs_1 = __importDefault(require("lambdafs"));
 const path_1 = require("path");
 const url_1 = require("url");
-if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
     if (process.env.FONTCONFIG_PATH === undefined) {
         process.env.FONTCONFIG_PATH = '/tmp/aws';
     }
@@ -145,7 +145,7 @@ class Chromium {
             lambdafs_1.default.inflate(`${input}/chromium.br`),
             lambdafs_1.default.inflate(`${input}/swiftshader.tar.br`),
         ];
-        if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+        if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
             promises.push(lambdafs_1.default.inflate(`${input}/aws.tar.br`));
         }
         return Promise.all(promises).then((result) => result.shift());

Save this file in your project as patches/chrome-aws-lambda+10.1.0.patch, install patch-package and add the following script to your package.json:

 "scripts": {
+  "postinstall": "patch-package"
 }
bitconym commented 1 year ago

@Edweis are you going to maintain this project since I see you approved the PR? Can you merge it? I switched using https://github.com/Sparticuz/chrome-aws-lambda since @Sparticuz currently maintains it.

shaunhurley commented 1 year ago

Works like a charm. I use patch-package with the following patch file as a workaround for now:

diff --git a/node_modules/chrome-aws-lambda/build/index.js b/node_modules/chrome-aws-lambda/build/index.js
index f78e183..599af55 100644
--- a/node_modules/chrome-aws-lambda/build/index.js
+++ b/node_modules/chrome-aws-lambda/build/index.js
@@ -7,7 +7,7 @@ const fs_1 = require("fs");
 const lambdafs_1 = __importDefault(require("lambdafs"));
 const path_1 = require("path");
 const url_1 = require("url");
-if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
     if (process.env.FONTCONFIG_PATH === undefined) {
         process.env.FONTCONFIG_PATH = '/tmp/aws';
     }
@@ -145,7 +145,7 @@ class Chromium {
             lambdafs_1.default.inflate(`${input}/chromium.br`),
             lambdafs_1.default.inflate(`${input}/swiftshader.tar.br`),
         ];
-        if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+        if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
             promises.push(lambdafs_1.default.inflate(`${input}/aws.tar.br`));
         }
         return Promise.all(promises).then((result) => result.shift());

Save this file in your project as patches/chrome-aws-lambda+10.1.0.patch, install patch-package and add the following script to your package.json:

 "scripts": {
+  "postinstall": "patch-package"
 }

Hi @urish, looking to try this approach in the short term till this gets commited. I get using patch-package, I'm a little confused on what constitutes "the following patch file" in your example - is it, literally, copying the code segment in your example to patches/chrome-aws-lambda+10.1.0.patch? Or copying the entire updated file from the commit on github?

Thanks!

tudorsandu commented 1 year ago

Would be great to merge this, is there anything blocking this PR? would be happy to help if there is

truuth-of-abhi commented 1 year ago

can we get this merged please?

bitconym commented 1 year ago

@truuth-of-abhi I don't think the repository is maintained anymore, better to switch to this fork: https://github.com/Sparticuz/chrome-aws-lambda

experionsachin commented 1 year ago

The latest repository is https://www.npmjs.com/package/@sparticuz/chromium. Working well with node 18 and AWS Lambda.