rsnext/test/e2e
Hannes Bornö a9b9e00703
fix(switchable-runtime): Make it possible to switch between edge and server runtime in dev (#39327)
Makes it possible to switch between edge/server runtime in dev without
breaking the server.

Fixes slack:
[1](https://vercel.slack.com/archives/CGU8HUTUH/p1659082535540549)
[2](https://vercel.slack.com/archives/C02CDC2ALJH/p1658978287244359)
[3](https://vercel.slack.com/archives/C03KAR5DCKC/p1656869427468779)

#### middleware-plugin.ts
`middlewareManifest` moved from module scope to local scope. Stale state
from earlier builds ended up in `middleware-manifest.json`. Functions
that changed from edge to server runtime stayed in the manifest as edge
functions.

#### on-demand-entry-handler.ts
When a server or edge entry is added we check if it has switched
runtime. If that's the case the old entry is removed.

#### Reproduce
Create edge API route and visit `/api/hello`
```js
// pages/api/hello.js
export const config = {
  runtime: 'experimental-edge',
}

export default () => new Response('Hello')
```

Change it to a server api route and visit `/api/hello`, it will explode.
```js
// pages/api/hello.js
export default function (req, res) {
  res.send('Hello')
}
```

#### Bug not fixed
One EDGE case is not fixed. It occurs if you switch between edge and
server runtime several times without changing the content of the file:

Edge runtime
```js
export const config = {
  runtime: 'experimental-edge',
}

export default () => new Response('Hello')
```

Change it to a server runtime
```js
export default function (req, res) {
  res.send('Hello')
}
```

Change back to edge runtime, the content of the file is the same as the
first time we compiled the edge runtime version.
```js
export const config = {
  runtime: 'experimental-edge',
}

export default () => new Response('Hello')
```

The reason is that both the edge and server compiler emits to the same
file (/.next/server/pages/api/hello.js) which makes this check fail in
webpack:
https://github.com/webpack/webpack/blob/main/lib/Compiler.js#L849-L861
Possible solution is to use different output folders for edge and server
https://vercel.slack.com/archives/CGU8HUTUH/p1661163106667559

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-07 13:42:32 -07:00
..
app-dir Add prefetch to new router (#39866) 2022-09-06 17:29:09 +00:00
basepath Add handling for testing against deployments (#36285) 2022-04-20 12:23:09 +00:00
browserslist Add support for browserslist and legacyBrowsers experimental option (#36584) 2022-05-17 15:09:34 +00:00
browserslist-extends Ensure browserslist extends works properly (#33890) 2022-02-02 13:23:51 -06:00
config-promise-export Add support for async fn / promise in next.config.js/.mjs (#33662) 2022-02-07 08:48:35 +00:00
dynamic-route-interpolation Match data fetch and busting cache key when path URI encodes (#39568) 2022-09-01 21:22:17 -07:00
edge-api-endpoints-can-receive-body Fix usage of experimental-edge in pages/api/index (#38024) 2022-07-19 19:33:00 -05:00
edge-can-use-wasm-files Enable @typescript-eslint/no-use-before-define for functions (#39602) 2022-08-15 10:29:51 -04:00
edge-compiler-can-import-blob-assets allow Edge Functions to stream a compressed fetch response (#39608) 2022-08-21 10:43:02 +00:00
edge-compiler-module-exports-preference Update some flaking tests for edge compiler and rsc (#38344) 2022-07-05 14:37:42 -05:00
edge-render-getserversideprops Update to detect GSSP with edge runtime during build (#40076) 2022-08-30 18:18:02 +00:00
getserversideprops Fix failing e2e getServerSideProps test (#39885) 2022-08-23 22:41:38 -05:00
handle-non-hoisted-swc-helpers Ensure @swc/helpers do not rely on hoisting (#38174) 2022-06-29 22:47:44 +00:00
i18n-api-support Enable E2E deploy tests on publish (#37019) 2022-05-21 04:46:16 -05:00
i18n-data-fetching-redirect Update deploy E2E test setup (#37126) 2022-05-23 17:37:21 -05:00
i18n-ignore-redirect-source-locale i18n regression tests and docs for ignore locale in rewrite (#37581) 2022-06-10 14:04:31 -05:00
i18n-ignore-rewrite-source-locale i18n regression tests and docs for ignore locale in rewrite (#37581) 2022-06-10 14:04:31 -05:00
ignore-invalid-popstateevent Ignore popstate with invalid state (#37110) 2022-05-28 20:07:44 -05:00
link-with-api-rewrite Handle Client Rewrites Correctly (#38340) 2022-07-05 22:44:38 +00:00
manual-client-base-path Fix invalid warning for existing experimental flag (#38027) 2022-06-25 23:05:02 -05:00
middleware-base-path Update to process redirects/rewrites for _next/data with middleware (#37574) 2022-06-10 12:35:12 -05:00
middleware-custom-matchers feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
middleware-custom-matchers-basepath feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
middleware-custom-matchers-i18n feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
middleware-fetches-with-any-http-method [middleware] Support any method when fetching a Request instance (#37540) 2022-06-08 11:00:49 +00:00
middleware-general feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
middleware-matcher feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
middleware-redirects Enable @typescript-eslint/no-use-before-define for functions (#39602) 2022-08-15 10:29:51 -04:00
middleware-responses Enable @typescript-eslint/no-use-before-define for functions (#39602) 2022-08-15 10:29:51 -04:00
middleware-rewrites Ensure prefetch heuristic matches with and without middleware (#39920) 2022-08-26 16:24:10 -05:00
middleware-trailing-slash feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
new-link-behavior Add support for passing ref to next/link with new behavior enabled (#36537) 2022-04-28 11:32:32 +02:00
next-head Fix document head with react 18 (#37443) 2022-06-04 10:30:42 +00:00
next-script [Script] Allow next/script to be placed in _document body (#37894) 2022-06-27 17:56:53 +00:00
no-eslint-warn-with-no-eslint-config fix: detect ESLint config in package.json (#40158) 2022-09-01 16:23:03 +00:00
nonce-head-manager correctly assess node equality when nonce attribute is present (#27573) 2021-11-10 19:31:32 -06:00
postcss-config-cjs Fix postcss deploy e2e test (#38782) 2022-07-18 20:21:35 -05:00
prerender Ensure On-Demand revalidate does not consider preview cookie (#39313) 2022-08-04 08:23:54 -05:00
prerender-native-module Migrate prerender tests to new set-up (#29245) 2021-09-21 16:21:05 +02:00
proxy-request-with-middleware Enable @typescript-eslint/no-use-before-define for functions (#39602) 2022-08-15 10:29:51 -04:00
reload-scroll-backforward-restoration Update deploy E2E test setup (#37126) 2022-05-23 17:37:21 -05:00
ssr-react-context fix: react dev bundle is picked in prod mode (#39221) 2022-08-01 14:21:42 +00:00
streaming-ssr test: merge edge ssr tests (#39924) 2022-08-24 23:56:59 +01:00
styled-jsx Setup require hook in next-server for styled-jsx resolving (#39305) 2022-08-08 20:27:42 -05:00
swc-warnings Add experimental flag to force SWC transforms (#36789) 2022-05-10 10:33:31 +00:00
switchable-runtime fix(switchable-runtime): Make it possible to switch between edge and server runtime in dev (#39327) 2022-09-07 13:42:32 -07:00
type-module-interop fix(#36435): apply correct fix (#36464) 2022-04-26 11:15:49 -05:00
yarn-pnp/test Update version for yarn pnp tests (#38688) 2022-07-15 11:41:53 -05:00
basepath-trailing-slash.test.ts Ensure trailingSlash is correct for index with query (#29217) 2021-09-21 16:18:42 +02:00
basepath.test.ts Ensure mixed query/hash values are handled correctly (#38852) 2022-07-21 19:16:38 +00:00
example.txt Add util for generating new tests/error documents (#33001) 2022-01-06 09:45:04 -06:00
prerender-crawler.test.ts Add crawler blocking for fallback: true (#29121) 2021-09-16 11:01:28 -05:00
prerender-native-module.test.ts Update resolving for node_modules trace pass (#30985) 2021-11-04 20:09:37 -05:00
prerender.test.ts Ensure On-Demand revalidate does not consider preview cookie (#39313) 2022-08-04 08:23:54 -05:00