Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit b982a0d

Browse files
author
Bender
committed
ref(sharp): remove sharp for now in favor of simplicity, todo added to return later
1 parent 38062fe commit b982a0d

File tree

6 files changed

+12
-614
lines changed

6 files changed

+12
-614
lines changed

Diff for: README.md

+2-29
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ This library uses Cloudfront, S3, ApiGateway and Lambdas to deploy easily in sec
1515
- [Image handler](#image-handler)
1616
- [Via CDK](#via-cdk)
1717
- [Benchmark](#benchmark)
18-
- [Sharp layer](#sharp-layer)
19-
- [Next layer](#next-layer)
2018
- [Packaging](#packaging)
2119
- [Server handler](#server-handler-1)
2220
- [Static assets](#static-assets)
@@ -46,6 +44,7 @@ This library uses Cloudfront, S3, ApiGateway and Lambdas to deploy easily in sec
4644
- [ ] [ISR and fallbacks](https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration)
4745
- [ ] [Streaming](https://nextjs.org/docs/advanced-features/react-18/streaming)
4846
- [ ] Custom babel configuration
47+
- [ ] Bundle Sharp together with image optimizer so Next uses it.
4948

5049

5150
## Usage
@@ -103,39 +102,13 @@ Update of stack:
103102

104103
We are looking at 6-8min for creation and 1-3min for update. This is a huge improvement over existing Lambda@Edge implementation.
105104

106-
### Sharp layer
107-
108-
Besides handler (wrapper) itself, underlying NextJS also requires sharp binaries.
109-
To build those, we use `npm install` with some extra parametes. Then we zip all sharp dependencies and compress it to easily importable zip file.
110-
111-
```
112-
import { sharpLayerZipPath } from '@sladg/nextjs-lambda'
113-
114-
const sharpLayer = new LayerVersion(this, 'SharpDependenciesLayer', {
115-
code: Code.fromAsset(sharpLayerZipPath)
116-
})
117-
```
118-
119-
### Next layer
120-
121-
To provide both image and server handlers with all depdencies (next is using `require.resolve` inside, so it cannot be bundled standalone for now).
122-
123-
We pre-package this layer so it can be included in Lambda without hassle.
124-
```
125-
import { nextLayerZipPath } from '@sladg/nextjs-lambda'
126-
127-
const nextLayer = new LayerVersion(this, 'NextDependenciesLayer', {
128-
code: Code.fromAsset(nextLayerZipPath)
129-
})
130-
```
131-
132105
## Packaging
133106

134107
In order to succefully deploy, you firstly need to include `target: 'standalone'` in your `next.config.js` setup.
135108
Make sure to use NextJS in version 12 or above so this is properly supported.
136109

137110
Once target is set, you can go on and use your `next build` command as you normally would.
138-
To package everything, make sure to be in your project root folder and next folder `.next` and `public` exist. Packaging is done via NPM CLI command of `@slack/nextjs-lambda package`.
111+
To package everything, make sure to be in your project root folder and next folder `.next` and `public` exist. Packaging is done via NPM CLI command of `@slack/nextjs-lambda pack`.
139112

140113
It will create `next.out/` folder with 3 zip packages. One zip Lambda's code, one is dependencies layer and one is assets layer.
141114

Diff for: lib/consts.ts

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as path from 'path'
33
export const sharpLayerZipPath = path.resolve(__dirname, './sharp-layer.zip')
44
export const imageHandlerZipPath = path.resolve(__dirname, './image-handler.zip')
55
export const serverHandlerZipPath = path.resolve(__dirname, './server-handler.zip')
6-
export const nextLayerZipPath = path.resolve(__dirname, './next-layer.zip')
76
export const cdkFolderPath = path.resolve(__dirname, '../cdk')
87

98
export const skipCiFlag = '[skip ci]'

0 commit comments

Comments
 (0)