From 88aa3165ee436b19f668461f07cf4b0a8440db99 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Wed, 31 Aug 2022 16:45:01 -0400 Subject: [PATCH 1/5] feat: create demo for using an edge function on a next site --- demos/next-with-edge-functions/.gitignore | 30 +++ demos/next-with-edge-functions/netlify.toml | 17 ++ .../netlify/edge-functions/helloOnTheEdge.ts | 1 + demos/next-with-edge-functions/next.config.js | 7 + demos/next-with-edge-functions/package.json | 13 ++ demos/next-with-edge-functions/pages/index.js | 209 ++++++++++++++++++ .../public/favicon.ico | Bin 0 -> 15086 bytes .../public/vercel.svg | 4 + package-lock.json | 90 +++++++- package.json | 3 +- 10 files changed, 370 insertions(+), 4 deletions(-) create mode 100644 demos/next-with-edge-functions/.gitignore create mode 100644 demos/next-with-edge-functions/netlify.toml create mode 100644 demos/next-with-edge-functions/netlify/edge-functions/helloOnTheEdge.ts create mode 100644 demos/next-with-edge-functions/next.config.js create mode 100644 demos/next-with-edge-functions/package.json create mode 100644 demos/next-with-edge-functions/pages/index.js create mode 100644 demos/next-with-edge-functions/public/favicon.ico create mode 100644 demos/next-with-edge-functions/public/vercel.svg diff --git a/demos/next-with-edge-functions/.gitignore b/demos/next-with-edge-functions/.gitignore new file mode 100644 index 0000000000..20fccdd4b8 --- /dev/null +++ b/demos/next-with-edge-functions/.gitignore @@ -0,0 +1,30 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local diff --git a/demos/next-with-edge-functions/netlify.toml b/demos/next-with-edge-functions/netlify.toml new file mode 100644 index 0000000000..e78b460590 --- /dev/null +++ b/demos/next-with-edge-functions/netlify.toml @@ -0,0 +1,17 @@ +[build] +command = "next build" +publish = ".next" + +[dev] +framework = "#static" + +[[plugins]] +package = "../plugin-wrapper/" + +# This is a fake plugin, that makes it run npm install +[[plugins]] +package = "@netlify/plugin-local-install-core" + +[[edge_functions]] +path = "/" +function = "helloOnTheEdge" diff --git a/demos/next-with-edge-functions/netlify/edge-functions/helloOnTheEdge.ts b/demos/next-with-edge-functions/netlify/edge-functions/helloOnTheEdge.ts new file mode 100644 index 0000000000..37dac66749 --- /dev/null +++ b/demos/next-with-edge-functions/netlify/edge-functions/helloOnTheEdge.ts @@ -0,0 +1 @@ +export default (req, context) => context.json({firstName: "Louise", lastName: "Belcher"}); diff --git a/demos/next-with-edge-functions/next.config.js b/demos/next-with-edge-functions/next.config.js new file mode 100644 index 0000000000..ac4d4ecf97 --- /dev/null +++ b/demos/next-with-edge-functions/next.config.js @@ -0,0 +1,7 @@ +module.exports = { + eslint: { + // Warning: This allows production builds to successfully complete even if + // your project has ESLint errors. + ignoreDuringBuilds: true, + }, +} diff --git a/demos/next-with-edge-functions/package.json b/demos/next-with-edge-functions/package.json new file mode 100644 index 0000000000..9e4441a010 --- /dev/null +++ b/demos/next-with-edge-functions/package.json @@ -0,0 +1,13 @@ +{ + "private": true, + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start" + }, + "dependencies": { + "next": "latest", + "react": "17.0.2", + "react-dom": "17.0.2" + } +} diff --git a/demos/next-with-edge-functions/pages/index.js b/demos/next-with-edge-functions/pages/index.js new file mode 100644 index 0000000000..04434312ae --- /dev/null +++ b/demos/next-with-edge-functions/pages/index.js @@ -0,0 +1,209 @@ +import Head from 'next/head' + +export default function Home() { + return ( +
+ + Create Next App + + + +
+

+ Welcome to Next.js! +

+ +

+ Get started by editing pages/index.js +

+ +
+ +

Documentation →

+

Find in-depth information about Next.js features and API.

+
+ + +

Learn →

+

Learn about Next.js in an interactive course with quizzes!

+
+ + +

Examples →

+

Discover and deploy boilerplate example Next.js projects.

+
+ + +

Deploy →

+

+ Instantly deploy your Next.js site to a public URL with Vercel. +

+
+
+
+ + + + + + +
+ ) +} diff --git a/demos/next-with-edge-functions/public/favicon.ico b/demos/next-with-edge-functions/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..4965832f2c9b0605eaa189b7c7fb11124d24e48a GIT binary patch literal 15086 zcmeHOOH5Q(7(R0cc?bh2AT>N@1PWL!LLfZKyG5c!MTHoP7_p!sBz0k$?pjS;^lmgJ zU6^i~bWuZYHL)9$wuvEKm~qo~(5=Lvx5&Hv;?X#m}i|`yaGY4gX+&b>tew;gcnRQA1kp zBbm04SRuuE{Hn+&1wk%&g;?wja_Is#1gKoFlI7f`Gt}X*-nsMO30b_J@)EFNhzd1QM zdH&qFb9PVqQOx@clvc#KAu}^GrN`q5oP(8>m4UOcp`k&xwzkTio*p?kI4BPtIwX%B zJN69cGsm=x90<;Wmh-bs>43F}ro$}Of@8)4KHndLiR$nW?*{Rl72JPUqRr3ta6e#A z%DTEbi9N}+xPtd1juj8;(CJt3r9NOgb>KTuK|z7!JB_KsFW3(pBN4oh&M&}Nb$Ee2 z$-arA6a)CdsPj`M#1DS>fqj#KF%0q?w50GN4YbmMZIoF{e1yTR=4ablqXHBB2!`wM z1M1ke9+<);|AI;f=2^F1;G6Wfpql?1d5D4rMr?#f(=hkoH)U`6Gb)#xDLjoKjp)1;Js@2Iy5yk zMXUqj+gyk1i0yLjWS|3sM2-1ECc;MAz<4t0P53%7se$$+5Ex`L5TQO_MMXXi04UDIU+3*7Ez&X|mj9cFYBXqM{M;mw_ zpw>azP*qjMyNSD4hh)XZt$gqf8f?eRSFX8VQ4Y+H3jAtvyTrXr`qHAD6`m;aYmH2zOhJC~_*AuT} zvUxC38|JYN94i(05R)dVKgUQF$}#cxV7xZ4FULqFCNX*Forhgp*yr6;DsIk=ub0Hv zpk2L{9Q&|uI^b<6@i(Y+iSxeO_n**4nRLc`P!3ld5jL=nZRw6;DEJ*1z6Pvg+eW|$lnnjO zjd|8>6l{i~UxI244CGn2kK@cJ|#ecwgSyt&HKA2)z zrOO{op^o*- + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 92438ac7f7..3080608af0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,8 @@ "demos/plugin-wrapper", "demos/server-components", "demos/middleware", - "demos/custom-routes" + "demos/custom-routes", + "demos/next-with-edge-functions" ], "dependencies": { "next": "^12.2.0" @@ -259,6 +260,47 @@ "typescript": "^4.6.3" } }, + "demos/next-with-edge-functions": { + "dependencies": { + "next": "latest", + "react": "17.0.2", + "react-dom": "17.0.2" + } + }, + "demos/next-with-edge-functions/node_modules/react": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", + "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "demos/next-with-edge-functions/node_modules/react-dom": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", + "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "scheduler": "^0.20.2" + }, + "peerDependencies": { + "react": "17.0.2" + } + }, + "demos/next-with-edge-functions/node_modules/scheduler": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", + "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, "demos/plugin-wrapper": { "name": "local-plugin", "version": "1.0.0", @@ -16935,6 +16977,10 @@ "resolved": "demos/next-export", "link": true }, + "node_modules/next-with-edge-functions": { + "resolved": "demos/next-with-edge-functions", + "link": true + }, "node_modules/nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -22927,7 +22973,7 @@ }, "packages/next": { "name": "@netlify/next", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "devDependencies": { "@types/node": "^17.0.25", @@ -22944,7 +22990,7 @@ }, "packages/runtime": { "name": "@netlify/plugin-nextjs", - "version": "4.21.0", + "version": "4.21.1", "license": "MIT", "dependencies": { "@netlify/esbuild": "0.14.25", @@ -35702,6 +35748,44 @@ "typescript": "^4.6.3" } }, + "next-with-edge-functions": { + "version": "file:demos/next-with-edge-functions", + "requires": { + "next": "latest", + "react": "17.0.2", + "react-dom": "17.0.2" + }, + "dependencies": { + "react": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", + "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, + "react-dom": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", + "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "scheduler": "^0.20.2" + } + }, + "scheduler": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", + "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + } + } + }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", diff --git a/package.json b/package.json index 00c4f8ddc1..902a391420 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,7 @@ "demos/plugin-wrapper", "demos/server-components", "demos/middleware", - "demos/custom-routes" + "demos/custom-routes", + "demos/next-with-edge-functions" ] } From f7da7819bf4f4a27bc1682899f21515f3f465793 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Wed, 31 Aug 2022 16:45:30 -0400 Subject: [PATCH 2/5] style: lint --- packages/next/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/CHANGELOG.md b/packages/next/CHANGELOG.md index 21a08c2669..15b68627c1 100644 --- a/packages/next/CHANGELOG.md +++ b/packages/next/CHANGELOG.md @@ -2,10 +2,10 @@ ## [1.1.1](https://github.com/netlify/next-runtime/compare/next-v1.1.0...next-v1.1.1) (2022-08-31) - ### Bug Fixes -* remove Next.js as a peer dependency ([#1584](https://github.com/netlify/next-runtime/issues/1584)) ([6be4dc0](https://github.com/netlify/next-runtime/commit/6be4dc08e5339efb84e180e9ea02ce0bc6efe5b5)) +- remove Next.js as a peer dependency ([#1584](https://github.com/netlify/next-runtime/issues/1584)) + ([6be4dc0](https://github.com/netlify/next-runtime/commit/6be4dc08e5339efb84e180e9ea02ce0bc6efe5b5)) ## [1.1.0](https://github.com/netlify/next-runtime/compare/next-v1.0.0...next-v1.1.0) (2022-08-22) From fb6d8b75461f7adb5ba1a50798ece0cb2e5722d9 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Tue, 6 Sep 2022 09:40:06 -0400 Subject: [PATCH 3/5] chore: general cleanup --- demos/next-with-edge-functions/pages/index.js | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/demos/next-with-edge-functions/pages/index.js b/demos/next-with-edge-functions/pages/index.js index 04434312ae..58ba0f7f61 100644 --- a/demos/next-with-edge-functions/pages/index.js +++ b/demos/next-with-edge-functions/pages/index.js @@ -35,30 +35,8 @@ export default function Home() {

Examples →

Discover and deploy boilerplate example Next.js projects.

- - -

Deploy →

-

- Instantly deploy your Next.js site to a public URL with Vercel. -

-
- - -