-
-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lambda-at-edge, next-aws-cloudfront): support Preview Mode (#562)
* Added preview mode support. * Rebased and updated tests. * - Added rollup and bundle default handler - Fixed expected uri in origin response. - Added util to rollup externals as it was breaking. * Rebased and updated tests * Updated another test * - Add API Lambda to rollup - Fixed some erroneous logic in the router, since it's now being used in the response handler - Mocked console errors in tests * Revert some changes which were superseded by @dphang's changes. * Fixed integration test * Updated tests * Added explicit return to getPreviewCookies * Added error logging to preview token verification catch block. * Added preview path test case to redirect * Optimised getPreviewCookies function.
- Loading branch information
Showing
22 changed files
with
551 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
!tests/** | ||
dist/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
import { nodeResolve } from "@rollup/plugin-node-resolve"; | ||
import externals from "rollup-plugin-node-externals"; | ||
|
||
const LOCAL_EXTERNALS = [ | ||
"./manifest.json", | ||
"./routes-manifest.json", | ||
"./prerender-manifest.json" | ||
]; | ||
const NPM_EXTERNALS = ["aws-lambda", "aws-sdk/clients/s3"]; | ||
|
||
const generateConfig = (filename) => ({ | ||
input: `./src/${filename}.ts`, | ||
output: { | ||
file: `./dist/${filename}.js`, | ||
format: "cjs" | ||
}, | ||
plugins: [ | ||
commonjs(), | ||
externals({ | ||
exclude: "@sls-next/next-aws-cloudfront" | ||
}), | ||
nodeResolve(), | ||
typescript({ | ||
tsconfig: "tsconfig.bundle.json" | ||
}) | ||
], | ||
external: [...NPM_EXTERNALS, ...LOCAL_EXTERNALS] | ||
}); | ||
|
||
export default ["default-handler", "api-handler"].map(generateConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.