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..349ae31f5d --- /dev/null +++ b/demos/next-with-edge-functions/pages/index.js @@ -0,0 +1,53 @@ +import Head from 'next/head' + +export default function Home() { + return ( +
+ + Next.js with Edge functions + + +
+

+ If you're seeing this page, that means that edge functions aren't running. + Run `netlify dev` to see an edge function in action! +

+ +
+ + + +
+ ) +} diff --git a/package-lock.json b/package-lock.json index 90f6ed2616..3f65762ab3 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", @@ -16944,6 +16986,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", @@ -35724,6 +35770,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 9edd6ac8b0..7f7d7c00b9 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" ] } 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)