Sparticuz / chrome-aws-lambda

This package has been deprecated in favor of @sparticuz/chromium
https://www.github.com/sparticuz/chromium
MIT License
139 stars 21 forks source link

Add workaround to define __dirname when running via ESM #29

Closed landtechjoe closed 2 years ago

landtechjoe commented 2 years ago

When trying to use chrome-aws-lambda via serverless sst the default mode for compiling the files is to output them to ES modules. There's a reference to dirname in the code that fails as it isn't defined when code runs as an ES module. This is just a change to polyfill filename and __dirname if they don't exist.

I can't run this locally at the moment as I have an M1 mac. If you have any pointers on how to run chrome-aws-lambda locally on an M1 mac I can do some testing to verify the changes but am currently unable to do so.