Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enables 'edge' as a possible runtime for API routes #4

Closed
wants to merge 2 commits into from

Conversation

feugy
Copy link
Owner

@feugy feugy commented Dec 9, 2022

📖 What's in there?

The edge runtime is going stable for API routes.
This PR brings a new allowed key inside pages/api/ folder:

const config = { runtime: 'edge' }

Regular pages can still be rendered using const runtime = 'experimental-edge', but they can not use edge(not all the cases are working yet).
This PR bring a new build error when using const runtime = 'edge'.

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • e2e tests added
  • Documentation added (from PR 43814)
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have a helpful link attached, see contributing.md

🧪 How to test?

Several tests cases added:

  • in dev mode, errors and warning: NEXT_TEST_MODE=dev pnpm testheadless --testPathPattern edge-configurable-runtime
  • in build mode, build error for pages on the edge: NEXT_TEST_MODE=start pnpm testheadless --testPathPattern edge-configurable-runtime

You can of course test it live inside the example/out folder:

// examples/out/stable-edge/pages/index.jsx
export default function Page() {
  return <p>hello world</p>
}
export const runtime = 'experimental-edge'; // try changing to `edge` to see the console error

// examples/out/stable-edge/pages/api/index.jsx
export default function handler() {
  return new Response('ok')
}
export const config = { runtime: 'edge' }; // try changing to `experimental-edge` to see the console warning

Then pnpm next build examples/out/stable-edge and pnpm next dev examples/out/stable-edge

@feugy feugy force-pushed the feat/stable-edge-runtime branch from 5b92d30 to d03539b Compare December 9, 2022 14:39
@feugy feugy changed the base branch from canary to 27925-add-remote-patterns December 9, 2022 14:53
@feugy feugy changed the base branch from 27925-add-remote-patterns to canary December 9, 2022 14:53
@feugy feugy force-pushed the feat/stable-edge-runtime branch 3 times, most recently from 7760f6d to a113884 Compare December 12, 2022 10:04
@feugy feugy force-pushed the feat/stable-edge-runtime branch 3 times, most recently from 2fca3af to 493fb3d Compare December 13, 2022 09:26
@feugy feugy changed the base branch from canary to 06-07-fix_eslint_next/server_error_when_next_is_not_in_the_root December 13, 2022 09:28
@feugy feugy changed the base branch from 06-07-fix_eslint_next/server_error_when_next_is_not_in_the_root to canary December 13, 2022 09:28
@feugy feugy marked this pull request as ready for review December 13, 2022 10:40
@feugy feugy force-pushed the feat/stable-edge-runtime branch 4 times, most recently from 33d8563 to 26aabed Compare December 14, 2022 15:21
@feugy feugy force-pushed the feat/stable-edge-runtime branch from 26aabed to 7c68f11 Compare December 15, 2022 07:58
@feugy
Copy link
Owner Author

feugy commented Jan 30, 2023

Was ported and merged.

@feugy feugy closed this Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants