Automattic / Automattic/node-canvas

Reduce size of Build for AWS Lambda Layer

Open
#2,130 2 comments 6 reactions 0 assignees View on GitHub
Binaries
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

- [x] If this is an issue with installation, I have read the [troubleshooting guide](https://github.com/Automattic/node-canvas/issues/1511).

I am working on a project that uses Canvas in multiple AWS lambda functions. We created a Lambda Layer that included Canvas, and a few other packages as they were all being used in these functions. Previously we were using canvas `v2.6.1` and node 12.

Recently, we upgraded our lambda runtimes to Node 16. Once we did this, we saw the `NODE_MODULE_VERSION` that was discussed in [the troubleshooting guide](https://github.com/Automattic/node-canvas/issues/1511).

So, I installed 2.7.0 as it was the closest version to 2.6.1 that had a prebuild for Node 16.

NOTE: I have the same issues with 2.10 as well so I'm sure this is not a canvas version issue.

But now the `node_modules` folder size exceeds Lambda Layer's size limit of 250MB.

Looking through the prebuilds, I see that there is a significant jump in file size between `canvas-v2.7.0-node-v79-linux-glibc-x64.tar.gz` and any node version above `79`. The unzipped folder for 2.7.0 with Node version 79 (node 13), was around 95MB, and that with Node Version 93 (Node 16) was 165MB.

I would like some assistance on creating a build smaller than 150MB (The other libraries in this layer are 100MB). Since we are not supporting SVGs in our project, I tried deleting `librsvg-2.so.2` but I then get an error `librsvg-2.so.2: cannot open shared object file: No such file or directory`. I am not sure what else to do.

## Steps to Reproduce
* `npm init -y`
* `npm install canvas@2.7.0`
* Check size of `node_modules`

## Your Environment
* Version of node-canvas (output of `npm list canvas` or `yarn list canvas`): 2.7.0, but I see this in other versions too
* Node version: 16.14.0
* OS: Fedora 36

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.