Skip to content

Commit

Permalink
chore: resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkness committed May 11, 2021
2 parents d9417b8 + 7372bf2 commit 1f757d1
Show file tree
Hide file tree
Showing 41 changed files with 367 additions and 199 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x]
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
yarn docs
- name: Deploy 🚀
uses: JamesIves/[email protected].1
uses: JamesIves/[email protected].2
with:
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ jobs:
run: |
cd packages/e2e-tests/$APP_NAME
yarn --frozen-lockfile
sleep $[($RANDOM % 15) + 1]s # Sleep 1-15 seconds to try to avoid throttling
yarn e2e:ci
- name: Mark end-to-end tests as failed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"@types/react": "^16.9.41",
"@types/react-dom": "^16.9.8",
"@types/webpack": "^4.41.18",
"@typescript-eslint/eslint-plugin": "^3.5.0",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^3.5.0",
"adm-zip": "^0.4.16",
"adm-zip": "^0.5.5",
"coveralls": "^3.1.0",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/deprecated/serverless-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [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)

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

## [2.6.5](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-03)

**Note:** Version bump only for package @sls-next/serverless-plugin
Expand Down
19 changes: 7 additions & 12 deletions packages/deprecated/serverless-plugin/examples/app-basic/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5161,9 +5161,9 @@ hmac-drbg@^1.0.1:
minimalistic-crypto-utils "^1.0.1"

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

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

[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:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==

lodash@^4.17.19:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
[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:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

log-symbols@^2.2.0:
version "2.2.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/deprecated/serverless-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.6.5",
"version": "2.6.6-alpha.0",
"description": "A serverless plugin for nextjs 8 serverless target",
"main": "index.js",
"keywords": [
Expand Down
9 changes: 4 additions & 5 deletions packages/deprecated/serverless-plugin/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
s3signed "^0.1.0"

"@sls-next/next-aws-lambda@link:../../compat-layers/apigw-lambda-compat":
version "0.0.0"
uid ""
version "2.6.3"

ansi-styles@^3.2.1:
version "3.2.1"
Expand Down Expand Up @@ -173,9 +172,9 @@ lodash.merge@^4.6.1:
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

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

minimist@^1.1.0:
version "1.2.5"
Expand Down
6 changes: 6 additions & 0 deletions packages/libs/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [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)

### Performance Improvements

- **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))

# 1.0.0-alpha.2 (2021-05-05)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sls-next/core",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Handles Next.js routing independent of provider",
"publishConfig": {
"access": "public"
Expand Down
12 changes: 6 additions & 6 deletions packages/libs/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export const handleDomainRedirects = (
}
};

export const handleLanguageRedirect = (
export const handleLanguageRedirect = async (
req: Request,
manifest: Manifest,
routesManifest: RoutesManifest
): RedirectRoute | undefined => {
const languageRedirectUri = getLanguageRedirectPath(
): Promise<RedirectRoute | undefined> => {
const languageRedirectUri = await getLanguageRedirectPath(
req,
manifest,
routesManifest
Expand Down Expand Up @@ -118,11 +118,11 @@ const normalise = (uri: string, routesManifest: RoutesManifest): string => {
* - redirects
* - public files
*/
export const routeDefault = (
export const routeDefault = async (
req: Request,
manifest: Manifest,
routesManifest: RoutesManifest
): Route | undefined => {
): Promise<Route | undefined> => {
const auth = handleAuth(req, manifest);
if (auth) {
return auth;
Expand All @@ -148,7 +148,7 @@ export const routeDefault = (
return (
publicFile ||
handleCustomRedirects(req, routesManifest) ||
handleLanguageRedirect(req, manifest, routesManifest)
(await handleLanguageRedirect(req, manifest, routesManifest))
);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/libs/core/src/locale.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Accept from "@hapi/accept";
import { Manifest, RoutesManifest } from "./types";

export function addDefaultLocaleToPath(
Expand Down Expand Up @@ -31,7 +30,7 @@ export function addDefaultLocaleToPath(
return path;
}

export const getAcceptLanguageLocale = (
export const getAcceptLanguageLocale = async (
acceptLanguage: string,
manifest: Manifest,
routesManifest: RoutesManifest
Expand All @@ -44,6 +43,7 @@ export const getAcceptLanguageLocale = (

// Accept.language(header, locales) prefers the locales order,
// so we ask for all to find the order preferred by user.
const Accept = await import("@hapi/accept");
for (const language of Accept.languages(acceptLanguage)) {
const locale = language.toLowerCase();
if (locale === defaultLocale) {
Expand Down
14 changes: 9 additions & 5 deletions packages/libs/core/src/redirect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as http from "http";
import { STATUS_CODES } from "http";
import { addDefaultLocaleToPath, getAcceptLanguageLocale } from "./locale";
import { compileDestination, matchPath } from "./match";
import { Manifest, Request, RedirectRoute, RoutesManifest } from "./types";
Expand All @@ -25,7 +25,7 @@ export function createRedirectResponse(
}

const status = statusCode;
const statusDescription = http.STATUS_CODES[status];
const statusDescription = STATUS_CODES[status];

const refresh =
statusCode === 308
Expand Down Expand Up @@ -80,19 +80,23 @@ export function getDomainRedirectPath(
* @param routesManifest
* @param manifest
*/
export function getLanguageRedirectPath(
export async function getLanguageRedirectPath(
req: Request,
manifest: Manifest,
routesManifest: RoutesManifest
): string | undefined {
): Promise<string | undefined> {
const languageHeader = req.headers["accept-language"];
const acceptLanguage = languageHeader && languageHeader[0]?.value;
const basePath = routesManifest.basePath;
const trailingSlash = manifest.trailingSlash;
const rootUri = basePath ? `${basePath}${trailingSlash ? "/" : ""}` : "/";

if (req.uri === rootUri || acceptLanguage) {
return getAcceptLanguageLocale(acceptLanguage, manifest, routesManifest);
return await getAcceptLanguageLocale(
acceptLanguage,
manifest,
routesManifest
);
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/libs/core/tests/locale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ describe("Locale Utils Tests", () => {
${"fr;q=0.7, nl;q=0.9"} | ${"/nl/"}
`(
"returns $expectedPath for $acceptLang",
({ acceptLang, expectedPath }) => {
const newPath = getAcceptLanguageLocale(
async ({ acceptLang, expectedPath }) => {
const newPath = await getAcceptLanguageLocale(
acceptLang,
manifest,
routesManifest
Expand All @@ -69,8 +69,8 @@ describe("Locale Utils Tests", () => {
acceptLang
${"en"}
${"nl;q=0.7, en;q=0.9"}
`("returns nothing for $acceptLang", ({ acceptLang }) => {
const newPath = getAcceptLanguageLocale(
`("returns nothing for $acceptLang", async ({ acceptLang }) => {
const newPath = await getAcceptLanguageLocale(
acceptLang,
manifest,
routesManifest
Expand Down
5 changes: 3 additions & 2 deletions packages/libs/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"resolveJsonModule": true,
"esModuleInterop": true,
"declaration": true,
"target": "ES2015",
"module": "CommonJS",
"lib": ["DOM", "ES2020"],
"target": "ES2019",
"module": "ES2020",
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "dist",
Expand Down
10 changes: 10 additions & 0 deletions packages/libs/lambda-at-edge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [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)

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

## [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)

### Performance Improvements

- **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))

## [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)

**Note:** Version bump only for package @sls-next/lambda-at-edge
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/lambda-at-edge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.8.1-alpha.2",
"version": "1.8.1-alpha.4",
"description": "Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
10 changes: 9 additions & 1 deletion packages/libs/lambda-at-edge/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,15 @@ class Builder {
const isDefaultLoader = !imageLoader || imageLoader === "default";
const hasImageOptimizer = hasImagesManifest && isDefaultLoader;

if (hasImageOptimizer) {
// ...nor if the image component is not used
const exportMarker = fse.existsSync(
join(this.dotNextDir, "export-marker.json")
)
? await fse.readJSON(path.join(this.dotNextDir, "export-marker.json"))
: {};
const isNextImageImported = exportMarker.isNextImageImported !== false;

if (hasImageOptimizer && isNextImageImported) {
await this.buildImageLambda(imageBuildManifest);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/libs/lambda-at-edge/src/default-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const handleOriginRequest = async ({
}) => {
const request = event.Records[0].cf.request;

const route = routeDefault(request, manifest, routesManifest);
const route = await routeDefault(request, manifest, routesManifest);
if (route) {
if (route.isPublicFile) {
const { file } = route as PublicFileRoute;
Expand Down Expand Up @@ -413,7 +413,7 @@ const handleOriginRequest = async ({
const normalisedS3DomainName = normaliseS3OriginDomain(s3Origin);
const hasFallback = hasFallbackForUri(uri, manifest, routesManifest);
const { now, log } = perfLogger(manifest.logLambdaExecutionTimes);
const isPreviewRequest = isValidPreviewRequest(
const isPreviewRequest = await isValidPreviewRequest(
request.headers.cookie,
prerenderManifest.preview.previewModeSigningKey
);
Expand Down
10 changes: 5 additions & 5 deletions packages/libs/lambda-at-edge/src/lib/isValidPreviewRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cookie from "cookie";
import jsonwebtoken from "jsonwebtoken";
import { parse } from "cookie";

const NEXT_PREVIEW_DATA_COOKIE = "__next_preview_data";
const NEXT_PRERENDER_BYPASS_COOKIE = "__prerender_bypass";
Expand All @@ -20,14 +19,15 @@ export type Cookies = {
* @param cookies - Cookies header with cookies in RFC 6265 compliant format
* @param previewModeSigningKey - Next build key generated in the preRenderManifest
*/
export const isValidPreviewRequest = (
export const isValidPreviewRequest = async (
cookies: Cookies,
previewModeSigningKey: string
): boolean => {
): Promise<boolean> => {
const previewCookies = getPreviewCookies(cookies);

if (hasPreviewCookies(previewCookies)) {
try {
const jsonwebtoken = await import("jsonwebtoken");
jsonwebtoken.verify(
previewCookies[NEXT_PREVIEW_DATA_COOKIE],
previewModeSigningKey
Expand All @@ -48,7 +48,7 @@ const getPreviewCookies = (cookies: Cookies): DefaultPreviewCookies => {
const targetCookie = cookies || [];

return targetCookie.reduce((previewCookies, cookieObj) => {
const parsedCookie = cookie.parse(cookieObj.value);
const parsedCookie = parse(cookieObj.value);

if (hasPreviewCookies(parsedCookie)) {
return parsedCookie as DefaultPreviewCookies;
Expand Down
Loading

0 comments on commit 1f757d1

Please sign in to comment.