Skip to content

Commit

Permalink
Drop node 14 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparticuz committed May 3, 2023
1 parent ffc8ec4 commit 0786301
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 51 deletions.
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ For Playwright-specific bugs, please refer to: https://github.com/microsoft/play
-->

## Environment
* `chromium` Version:
* `puppeteer` / `puppeteer-core` Version:
* Node.js Version: <!-- 14.x | 16.x -->
* Lambda / GCF Runtime: <!-- `nodejs8.10` | `nodejs10.x` | `nodejs12.x` -->

- `chromium` Version:
- `puppeteer` / `puppeteer-core` Version:
- Node.js Version: <!-- 16.x | 18.x -->
- Lambda / GCF Runtime: <!-- `nodejs16` | `nodejs18.x` -->

## Expected Behavior

Expand Down
12 changes: 0 additions & 12 deletions _/amazon/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,9 @@ Resources:
LayerName: sparticuz-chromium
ContentUri: code/
CompatibleRuntimes:
- nodejs14.x
- nodejs16.x
- nodejs18.x

node14:
Type: AWS::Serverless::Function
Properties:
Layers:
- !Ref layer
Handler: handlers/index.handler
Runtime: nodejs14.x
Policies:
- AWSLambdaBasicExecutionRole
- AWSXRayDaemonWriteAccess
Tracing: Active
node16:
Type: AWS::Serverless::Function
Properties:
Expand Down
39 changes: 23 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@
"tar-fs": "^2.1.1"
},
"devDependencies": {
"@tsconfig/node14": "^1.0.3",
"@tsconfig/node16": "^1.0.3",
"@tsconfig/strictest": "^2.0.1",
"@types/follow-redirects": "^1.14.1",
"@types/node": "^18.15.7",
"@types/node": "^18.16.3",
"@types/tar-fs": "^2.0.1",
"clean-modules": "^2.0.6",
"typescript": "^5.0.2"
"typescript": "^5.0.4"
},
"engines": {
"node": ">= 14.18.0"
"node": ">= 16"
}
}
4 changes: 2 additions & 2 deletions source/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const isValidUrl = (input: string) => {
*/
export const isRunningInAwsLambda = () => {
if (
process.env.AWS_EXECUTION_ENV &&
/^AWS_Lambda_nodejs/.test(process.env.AWS_EXECUTION_ENV) === true
process.env["AWS_EXECUTION_ENV"] &&
/^AWS_Lambda_nodejs/.test(process.env["AWS_EXECUTION_ENV"]) === true
) {
return true;
}
Expand Down
29 changes: 17 additions & 12 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,20 @@ interface Viewport {
}

if (isRunningInAwsLambda()) {
if (process.env.FONTCONFIG_PATH === undefined) {
process.env.FONTCONFIG_PATH = "/tmp/aws";
if (process.env["FONTCONFIG_PATH"] === undefined) {
process.env["FONTCONFIG_PATH"] = "/tmp/aws";
}

if (process.env.LD_LIBRARY_PATH === undefined) {
process.env.LD_LIBRARY_PATH = "/tmp/aws/lib";
} else if (process.env.LD_LIBRARY_PATH.startsWith("/tmp/aws/lib") !== true) {
process.env.LD_LIBRARY_PATH = [
...new Set(["/tmp/aws/lib", ...process.env.LD_LIBRARY_PATH.split(":")]),
if (process.env["LD_LIBRARY_PATH"] === undefined) {
process.env["LD_LIBRARY_PATH"] = "/tmp/aws/lib";
} else if (
process.env["LD_LIBRARY_PATH"].startsWith("/tmp/aws/lib") !== true
) {
process.env["LD_LIBRARY_PATH"] = [
...new Set([
"/tmp/aws/lib",
...process.env["LD_LIBRARY_PATH"].split(":"),
]),
].join(":");
}
}
Expand All @@ -77,12 +82,12 @@ class Chromium {
* Downloads or symlinks a custom font and returns its basename, patching the environment so that Chromium can find it.
*/
static font(input: string): Promise<string> {
if (process.env.HOME === undefined) {
process.env.HOME = "/tmp";
if (process.env["HOME"] === undefined) {
process.env["HOME"] = "/tmp";
}

if (existsSync(`${process.env.HOME}/.fonts`) !== true) {
mkdirSync(`${process.env.HOME}/.fonts`);
if (existsSync(`${process.env["HOME"]}/.fonts`) !== true) {
mkdirSync(`${process.env["HOME"]}/.fonts`);
}

return new Promise((resolve, reject) => {
Expand All @@ -91,7 +96,7 @@ class Chromium {
}

const url = new URL(input);
const output = `${process.env.HOME}/.fonts/${url.pathname
const output = `${process.env["HOME"]}/.fonts/${url.pathname
.split("/")
.pop()}`;

Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "@tsconfig/node14/tsconfig.json",
"extends": [
"@tsconfig/node16/tsconfig",
"@tsconfig/strictest"
],
"compilerOptions": {
"declaration": true,
"lib": [
Expand Down

0 comments on commit 0786301

Please sign in to comment.