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

Commit 1f757d1

Browse files
committed
chore: resolve conflicts
2 parents d9417b8 + 7372bf2 commit 1f757d1

File tree

41 files changed

+367
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+367
-199
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [10.x, 12.x]
19+
node-version: [12.x, 14.x]
2020

2121
steps:
2222
- uses: actions/checkout@v2

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
yarn docs
1919
2020
- name: Deploy 🚀
21-
uses: JamesIves/[email protected].1
21+
uses: JamesIves/[email protected].2
2222
with:
2323
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}
2424
BRANCH: gh-pages # The branch the action should deploy to.

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ jobs:
123123
run: |
124124
cd packages/e2e-tests/$APP_NAME
125125
yarn --frozen-lockfile
126+
sleep $[($RANDOM % 15) + 1]s # Sleep 1-15 seconds to try to avoid throttling
126127
yarn e2e:ci
127128
128129
- name: Mark end-to-end tests as failed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"@types/react": "^16.9.41",
4848
"@types/react-dom": "^16.9.8",
4949
"@types/webpack": "^4.41.18",
50-
"@typescript-eslint/eslint-plugin": "^3.5.0",
50+
"@typescript-eslint/eslint-plugin": "^4.0.0",
5151
"@typescript-eslint/parser": "^3.5.0",
52-
"adm-zip": "^0.4.16",
52+
"adm-zip": "^0.5.5",
5353
"coveralls": "^3.1.0",
5454
"eslint": "^7.3.1",
5555
"eslint-config-prettier": "^6.11.0",

packages/deprecated/serverless-plugin/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.6.6-alpha.0](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-09)
7+
8+
**Note:** Version bump only for package @sls-next/serverless-plugin
9+
610
## [2.6.5](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-03)
711

812
**Note:** Version bump only for package @sls-next/serverless-plugin

packages/deprecated/serverless-plugin/examples/app-basic/yarn.lock

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5161,9 +5161,9 @@ hmac-drbg@^1.0.1:
51615161
minimalistic-crypto-utils "^1.0.1"
51625162

51635163
hosted-git-info@^2.1.4:
5164-
version "2.8.8"
5165-
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
5166-
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
5164+
version "2.8.9"
5165+
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
5166+
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
51675167

51685168
html-entities@^1.2.0:
51695169
version "1.3.1"
@@ -6236,15 +6236,10 @@ lodash.union@^4.6.0:
62366236
resolved "https://registry.yarnpkg.com/lodash.union/-/lodash.union-4.6.0.tgz#48bb5088409f16f1821666641c44dd1aaae3cd88"
62376237
integrity sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=
62386238

6239-
[email protected], lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4:
6240-
version "4.17.15"
6241-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
6242-
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
6243-
6244-
lodash@^4.17.19:
6245-
version "4.17.19"
6246-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
6247-
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
6239+
[email protected], lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4:
6240+
version "4.17.21"
6241+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
6242+
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
62486243

62496244
log-symbols@^2.2.0:
62506245
version "2.2.0"

packages/deprecated/serverless-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publishConfig": {
44
"access": "public"
55
},
6-
"version": "2.6.5",
6+
"version": "2.6.6-alpha.0",
77
"description": "A serverless plugin for nextjs 8 serverless target",
88
"main": "index.js",
99
"keywords": [

packages/deprecated/serverless-plugin/yarn.lock

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
s3signed "^0.1.0"
1818

1919
"@sls-next/next-aws-lambda@link:../../compat-layers/apigw-lambda-compat":
20-
version "0.0.0"
21-
uid ""
20+
version "2.6.3"
2221

2322
ansi-styles@^3.2.1:
2423
version "3.2.1"
@@ -173,9 +172,9 @@ lodash.merge@^4.6.1:
173172
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
174173

175174
mime@^2.4.0:
176-
version "2.4.6"
177-
resolved "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1"
178-
integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==
175+
version "2.5.2"
176+
resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe"
177+
integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==
179178

180179
minimist@^1.1.0:
181180
version "1.2.5"

packages/libs/core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [1.0.0-alpha.3](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-09)
7+
8+
### Performance Improvements
9+
10+
- **core, lambda-at-edge:** cold start improvements ([#1044](https://github.com/serverless-nextjs/serverless-next.js/issues/1044)) ([0ee1394](https://github.com/serverless-nextjs/serverless-next.js/commit/0ee1394d83141332d594010d6e2550daac30d245))
11+
612
# 1.0.0-alpha.2 (2021-05-05)
713

814
### Bug Fixes

packages/libs/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sls-next/core",
3-
"version": "1.0.0-alpha.2",
3+
"version": "1.0.0-alpha.3",
44
"description": "Handles Next.js routing independent of provider",
55
"publishConfig": {
66
"access": "public"

packages/libs/core/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ export const handleDomainRedirects = (
4747
}
4848
};
4949

50-
export const handleLanguageRedirect = (
50+
export const handleLanguageRedirect = async (
5151
req: Request,
5252
manifest: Manifest,
5353
routesManifest: RoutesManifest
54-
): RedirectRoute | undefined => {
55-
const languageRedirectUri = getLanguageRedirectPath(
54+
): Promise<RedirectRoute | undefined> => {
55+
const languageRedirectUri = await getLanguageRedirectPath(
5656
req,
5757
manifest,
5858
routesManifest
@@ -118,11 +118,11 @@ const normalise = (uri: string, routesManifest: RoutesManifest): string => {
118118
* - redirects
119119
* - public files
120120
*/
121-
export const routeDefault = (
121+
export const routeDefault = async (
122122
req: Request,
123123
manifest: Manifest,
124124
routesManifest: RoutesManifest
125-
): Route | undefined => {
125+
): Promise<Route | undefined> => {
126126
const auth = handleAuth(req, manifest);
127127
if (auth) {
128128
return auth;
@@ -148,7 +148,7 @@ export const routeDefault = (
148148
return (
149149
publicFile ||
150150
handleCustomRedirects(req, routesManifest) ||
151-
handleLanguageRedirect(req, manifest, routesManifest)
151+
(await handleLanguageRedirect(req, manifest, routesManifest))
152152
);
153153
};
154154

packages/libs/core/src/locale.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Accept from "@hapi/accept";
21
import { Manifest, RoutesManifest } from "./types";
32

43
export function addDefaultLocaleToPath(
@@ -31,7 +30,7 @@ export function addDefaultLocaleToPath(
3130
return path;
3231
}
3332

34-
export const getAcceptLanguageLocale = (
33+
export const getAcceptLanguageLocale = async (
3534
acceptLanguage: string,
3635
manifest: Manifest,
3736
routesManifest: RoutesManifest
@@ -44,6 +43,7 @@ export const getAcceptLanguageLocale = (
4443

4544
// Accept.language(header, locales) prefers the locales order,
4645
// so we ask for all to find the order preferred by user.
46+
const Accept = await import("@hapi/accept");
4747
for (const language of Accept.languages(acceptLanguage)) {
4848
const locale = language.toLowerCase();
4949
if (locale === defaultLocale) {

packages/libs/core/src/redirect.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as http from "http";
1+
import { STATUS_CODES } from "http";
22
import { addDefaultLocaleToPath, getAcceptLanguageLocale } from "./locale";
33
import { compileDestination, matchPath } from "./match";
44
import { Manifest, Request, RedirectRoute, RoutesManifest } from "./types";
@@ -25,7 +25,7 @@ export function createRedirectResponse(
2525
}
2626

2727
const status = statusCode;
28-
const statusDescription = http.STATUS_CODES[status];
28+
const statusDescription = STATUS_CODES[status];
2929

3030
const refresh =
3131
statusCode === 308
@@ -80,19 +80,23 @@ export function getDomainRedirectPath(
8080
* @param routesManifest
8181
* @param manifest
8282
*/
83-
export function getLanguageRedirectPath(
83+
export async function getLanguageRedirectPath(
8484
req: Request,
8585
manifest: Manifest,
8686
routesManifest: RoutesManifest
87-
): string | undefined {
87+
): Promise<string | undefined> {
8888
const languageHeader = req.headers["accept-language"];
8989
const acceptLanguage = languageHeader && languageHeader[0]?.value;
9090
const basePath = routesManifest.basePath;
9191
const trailingSlash = manifest.trailingSlash;
9292
const rootUri = basePath ? `${basePath}${trailingSlash ? "/" : ""}` : "/";
9393

9494
if (req.uri === rootUri || acceptLanguage) {
95-
return getAcceptLanguageLocale(acceptLanguage, manifest, routesManifest);
95+
return await getAcceptLanguageLocale(
96+
acceptLanguage,
97+
manifest,
98+
routesManifest
99+
);
96100
}
97101
}
98102

packages/libs/core/tests/locale.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ describe("Locale Utils Tests", () => {
5454
${"fr;q=0.7, nl;q=0.9"} | ${"/nl/"}
5555
`(
5656
"returns $expectedPath for $acceptLang",
57-
({ acceptLang, expectedPath }) => {
58-
const newPath = getAcceptLanguageLocale(
57+
async ({ acceptLang, expectedPath }) => {
58+
const newPath = await getAcceptLanguageLocale(
5959
acceptLang,
6060
manifest,
6161
routesManifest
@@ -69,8 +69,8 @@ describe("Locale Utils Tests", () => {
6969
acceptLang
7070
${"en"}
7171
${"nl;q=0.7, en;q=0.9"}
72-
`("returns nothing for $acceptLang", ({ acceptLang }) => {
73-
const newPath = getAcceptLanguageLocale(
72+
`("returns nothing for $acceptLang", async ({ acceptLang }) => {
73+
const newPath = await getAcceptLanguageLocale(
7474
acceptLang,
7575
manifest,
7676
routesManifest

packages/libs/core/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"resolveJsonModule": true,
44
"esModuleInterop": true,
55
"declaration": true,
6-
"target": "ES2015",
7-
"module": "CommonJS",
6+
"lib": ["DOM", "ES2020"],
7+
"target": "ES2019",
8+
"module": "ES2020",
89
"moduleResolution": "node",
910
"noImplicitAny": true,
1011
"outDir": "dist",

packages/libs/lambda-at-edge/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.8.1-alpha.4](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-09)
7+
8+
**Note:** Version bump only for package @sls-next/lambda-at-edge
9+
10+
## [1.8.1-alpha.3](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-09)
11+
12+
### Performance Improvements
13+
14+
- **core, lambda-at-edge:** cold start improvements ([#1044](https://github.com/serverless-nextjs/serverless-next.js/issues/1044)) ([0ee1394](https://github.com/serverless-nextjs/serverless-next.js/commit/0ee1394d83141332d594010d6e2550daac30d245))
15+
616
## [1.8.1-alpha.2](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-05)
717

818
**Note:** Version bump only for package @sls-next/lambda-at-edge

packages/libs/lambda-at-edge/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publishConfig": {
44
"access": "public"
55
},
6-
"version": "1.8.1-alpha.2",
6+
"version": "1.8.1-alpha.4",
77
"description": "Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge",
88
"main": "dist/index.js",
99
"types": "dist/index.d.ts",

packages/libs/lambda-at-edge/src/build.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,15 @@ class Builder {
12311231
const isDefaultLoader = !imageLoader || imageLoader === "default";
12321232
const hasImageOptimizer = hasImagesManifest && isDefaultLoader;
12331233

1234-
if (hasImageOptimizer) {
1234+
// ...nor if the image component is not used
1235+
const exportMarker = fse.existsSync(
1236+
join(this.dotNextDir, "export-marker.json")
1237+
)
1238+
? await fse.readJSON(path.join(this.dotNextDir, "export-marker.json"))
1239+
: {};
1240+
const isNextImageImported = exportMarker.isNextImageImported !== false;
1241+
1242+
if (hasImageOptimizer && isNextImageImported) {
12351243
await this.buildImageLambda(imageBuildManifest);
12361244
}
12371245

packages/libs/lambda-at-edge/src/default-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ const handleOriginRequest = async ({
310310
}) => {
311311
const request = event.Records[0].cf.request;
312312

313-
const route = routeDefault(request, manifest, routesManifest);
313+
const route = await routeDefault(request, manifest, routesManifest);
314314
if (route) {
315315
if (route.isPublicFile) {
316316
const { file } = route as PublicFileRoute;
@@ -413,7 +413,7 @@ const handleOriginRequest = async ({
413413
const normalisedS3DomainName = normaliseS3OriginDomain(s3Origin);
414414
const hasFallback = hasFallbackForUri(uri, manifest, routesManifest);
415415
const { now, log } = perfLogger(manifest.logLambdaExecutionTimes);
416-
const isPreviewRequest = isValidPreviewRequest(
416+
const isPreviewRequest = await isValidPreviewRequest(
417417
request.headers.cookie,
418418
prerenderManifest.preview.previewModeSigningKey
419419
);

packages/libs/lambda-at-edge/src/lib/isValidPreviewRequest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import cookie from "cookie";
2-
import jsonwebtoken from "jsonwebtoken";
1+
import { parse } from "cookie";
32

43
const NEXT_PREVIEW_DATA_COOKIE = "__next_preview_data";
54
const NEXT_PRERENDER_BYPASS_COOKIE = "__prerender_bypass";
@@ -20,14 +19,15 @@ export type Cookies = {
2019
* @param cookies - Cookies header with cookies in RFC 6265 compliant format
2120
* @param previewModeSigningKey - Next build key generated in the preRenderManifest
2221
*/
23-
export const isValidPreviewRequest = (
22+
export const isValidPreviewRequest = async (
2423
cookies: Cookies,
2524
previewModeSigningKey: string
26-
): boolean => {
25+
): Promise<boolean> => {
2726
const previewCookies = getPreviewCookies(cookies);
2827

2928
if (hasPreviewCookies(previewCookies)) {
3029
try {
30+
const jsonwebtoken = await import("jsonwebtoken");
3131
jsonwebtoken.verify(
3232
previewCookies[NEXT_PREVIEW_DATA_COOKIE],
3333
previewModeSigningKey
@@ -48,7 +48,7 @@ const getPreviewCookies = (cookies: Cookies): DefaultPreviewCookies => {
4848
const targetCookie = cookies || [];
4949

5050
return targetCookie.reduce((previewCookies, cookieObj) => {
51-
const parsedCookie = cookie.parse(cookieObj.value);
51+
const parsedCookie = parse(cookieObj.value);
5252

5353
if (hasPreviewCookies(parsedCookie)) {
5454
return parsedCookie as DefaultPreviewCookies;

0 commit comments

Comments
 (0)