Commit graph

2724 commits

Author SHA1 Message Date
Gal Schlezinger
e05c31df17
Throw an error when target: 'serverless' is used with Middleware (#37819)
Serverless target is deprecated, so we don't support it in Middleware as it's a new feature,
but we need to have a good error message for that. This commit solves that.

## Related

* Fixes #37433



## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-19 13:17:18 +00:00
JJ Kasper
8577c4f07b
Detect pnpm correctly when installing missing dependencies (#37813)
This ensures we properly detect `pnpm` when installing missing dependencies. This also adds test coverage to ensure we properly detect the correct package manager. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1655568091661719)
2022-06-19 12:33:23 +00:00
Hannes Bornö
2313ee093a
Display full refresh warning even when error has occurred (#37425)
If you end up in a state where an error happened and you also should be warned about a full refresh  - you get stuck. The full refresh is blocked by the warning but the error is shown instead.

Tests didn't catch this because the refresh warning never showed in `__NEXT_TEST_MODE`.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-19 00:00:14 +00:00
Sukka
5c88484f04
fix(config): only warn experimental feature when used (#37755)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

```js
// next.config.js
module.exports = {
  experimental: {
    legacyBrowsers: false,
    sharedPool: true,
    newNextLinkBehavior: false
  }
}
```

With the current implementation, using the config above will warn the usage of experimental features. However, those are the preset values that are defined in `defaultConfig` which means actually no experimental feature has been enabled at all.

The PR changes to only check if experimental features are actually enabled (have different values than the ones defined in `defaultConfig`).
2022-06-18 07:44:37 -04:00
Alex Castle
af9d92207e
Use SVG blur technique for raw layout images (#37022)
This PR switches to using an SVG filter for blurring placeholder images, rather than a CSS filter. It's based on the technique described in @cramforce's [blog post](https://www.industrialempathy.com/posts/image-optimizations/#blurry-placeholder).

One change I made to @cramforce's version was to increase the stdDeviation property of the SVG (which controls the gaussian blur strength) from .5 to 50. Smaller values than this tended to look bad, as our technique for generating the blurry placeholder image tends to produce images with sharp contrast between the pixels, which looks bad when blown up unless it's blurred by a substantial amount.

This PR currently only affects the experimental `layout="raw"` but I expect to eventually apply it to all images. CC: @styfle @kara
2022-06-17 21:16:20 +00:00
JJ Kasper
85e643be83
Ensure query params are populated correctly with middleware (#37784)
* Ensure query params are populated correctly with middleware

* update test

* dont match edge ssr

* fix query hydrate check

* fix lint

* update test
2022-06-17 10:28:25 -05:00
Javi Velasco
2d5d43fb75
Refactor server routing (#37725)
This PR fixes an issue where we have a middleware that rewrites every single request to the same origin while having `i18n` configured. It would be something like: 

```typescript
import { NextResponse } from 'next/server'

export function middleware(req) {
  return NextResponse.rewrite(req.nextUrl)
}
```

In this case we are going to be adding always the `locale` at the beginning of the destination since it is a rewrite. This causes static assets to not match and the whole application to break. I believe this is a potential footgun so in this PR we are addressing the issue by removing the locale from pathname for those cases where we check against the filesystem (e.g. public folder).

To achieve this change, this PR introduces some preparation changes and then a refactor of the logic in the server router. After this refactor we are going to be relying on properties that can be defined in the `Route` to decide wether or not we should remove the `basePath`, `locale`, etc instead of checking which _type_ of route it is that we are matching.

Overall this simplifies quite a lot the server router. The way we are testing the mentioned issue is by adding a default rewrite in the rewrite tests middleware.
2022-06-16 21:43:01 +00:00
JJ Kasper
5730ed0f61
Ensure eslint-config warning/errors are correct (#37760)
* Ensure eslint-config warning/errors are correct

* fix tests
2022-06-16 16:04:44 -05:00
Steven
b7d057453d
Add images.unoptimized: true for easy next export (#37698)
In a previous PR (#19032), we added a hard error during `next export` if the default Image Optimization API is being used because it requires a server to optimized on demand. The error message offers several different solutions but it didn't consider that by the time someone runs `next export`, they are probably done writing their app.

So if `next export` is a hard requirement, the quickest path forward is to disable Image Optimization API. So this PR adds a new configuration option to `next.config.js`:

```js
module.exports = {
  images: {
    unoptimized: true
  }
}
```

### Update
Upon further discussion, we might want to avoid doing this just for images and instead introduce a top-level config to indicate export is coming and then handle errors or warn for [unsupported features](https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features).

```
module.exports = {
  nextExport: true
}
```

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-16 20:20:17 +00:00
Steven
448ba2b384
Enhance experimental feature warning (#37752)
This improves the warning thats printed when you have experimental features enable so its clear which ones are enabled (in parenthesis) and where they are enabled (in next.config.js or next.config.mjs)

## Before

```
warn  - You have enabled experimental feature(s).
```

## After

```
warn  - You have enabled experimental features (reactRoot, serverComponents, scrollRestoration) in next.config.js.
```
2022-06-16 19:59:47 +00:00
JJ Kasper
37de4f989a
Remove previous query param deleting warning (#37740) 2022-06-16 13:41:44 -05:00
Balázs Orbán
b8e533b589
chore: use pnpm install in tests (#37712)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] 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`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-16 18:08:07 +00:00
JJ Kasper
a4abc1e77d
Expose test timings token for e2e tests (#37756)
* Expose test timings token for e2e tests

* update flake
2022-06-16 11:56:43 -05:00
JJ Kasper
9bd1751ce5
Update to skip middleware for unstable_revalidate (#37734)
* Update to skip middleware for unstable_revalidate

* lint fix
2022-06-16 11:22:35 -05:00
Seiya Nuta
0bf9233e14
[middleware] Warn dynamic WASM compilation (#37681)
In Middlewares, dynamic code execution is not allowed. Currently, we warn if eval / new Function are invoked in dev but don't warn another dynamic code execution in WebAssembly.

This PR adds warnings for `WebAssembly.compile` and `WebAssembly.instantiate` with a buffer parameter (note that `WebAssembly.instantiate` with a **module** parameter is legit) invocations. Note that other methods that compile WASM dynamically such as `WebAssembly.compileStreaming` are not exposed to users so we don't need to cover them.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] 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`
- [x] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-16 14:59:30 +00:00
Andrei Stefan
6b829d8bd6
fix(eslint): allow <img> in conjunction with <picture> (#37504) (#37570)
* fix(eslint): allow <img> in conjunction with <picture> (#37504)

* Apply suggestions from code review

* add space

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-15 21:13:52 -05:00
JJ Kasper
808e558ade
Ensure rewrite query params with middleware are available in router (#37724)
* Ensure rewrite query params with middleware are available in router

* Ensure header matches deploy and add test case

* update check
2022-06-15 14:32:44 -05:00
Jiachi Liu
40b0dae558
chore: bump react dev dep to 18.2 (#37697)
* chore: bump react dev dep to 18.2

* fix test and exclude inc cache path for edge

* update compiled

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-15 10:14:43 -05:00
Gal Schlezinger
7193effcc0
Fix shallow routing with rewrites/middleware (#37716)
Shallow route changes did not work for rewritten pages when Middleware
was used, and made hard refreshes, although it was possible with static rewrites.

This happened because the router has a manifest of the static rewrites,
allowing static rewrites to map the route before comparing with the
local cache.

Middleware rewrites are dynamic and happening on the server, so we
can't send a manifest easily. This means that we need to propagate
the rewrites from the data requests into the components cache in
the router to make sure we have cache hits and don't miss.

This commit does exactly that and adds a test to verify that it works.

This fixes #37072 and fixes #31680

_Note:_ there's one thing that is somewhat an issue though: if the first
page the user lands on is a rewritten page, and will try to make a
shallow navigation to the same page--we will make a `fetch` request.
This is because we don't have any client cache of the `rewrite` we just
had.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-15 15:09:13 +00:00
JJ Kasper
bf7bf8217f
Ensure navigating with middleware parses route params correctly (#37704) 2022-06-15 09:09:51 -05:00
Javi Velasco
de7b316446
Improve Middleware errors (#37695)
* Improve stack traces in dev mode

* Refactor `react-dev-overlay` to support the Edge Compiler

* Serialize errors including the compiler `source`

* Adopt the new `react-dev-overlay` displaying it for middleware errors

* Improve tests

* fix rsc cases

* update test

* use check for dev test

* handle different error from node version

Co-authored-by: feugy <damien@vercel.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-14 19:58:13 -05:00
Javi Velasco
c501842311
Add test combining middleware & config rewrites (#37667)
* Add test combining middleware & config rewrites

* Add `afterFiles` test

* update some tests

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-14 17:31:33 -05:00
JJ Kasper
f17f1d4e56
Update middleware matcher e2e test (#37694) 2022-06-14 15:11:36 -05:00
JJ Kasper
a01aa4de6a
Revert "Revert "Revert "Avoid unnecessary router state changes""" (#37692)
Revert "Revert "Revert "Avoid unnecessary router state changes"" (#37593)"

This reverts commit 78cbfa06fb.
2022-06-14 12:00:11 -05:00
JJ Kasper
e7f08ef040
Ensure custom middleware matcher is used correctly in client manifest (#37672)
* Ensure custom middleware matcher is used correctly in client manifest

* lint-fix

* patch e2e case

* fix rsc case

* update test

* add missing normalize
2022-06-13 22:07:40 -05:00
Michael Novotny
5211ac5cae
Adds consistency to ESLint rules. (#34335)
* Adds consistency to ESLint rules.

* Fixes lint errors.

* Fixes manifest.

* Adds missing title.

* Fixes copy / paste error.

Co-authored-by: Lee Robinson <me@leerob.io>

* Update errors/no-script-in-document.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Update errors/no-sync-scripts.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Updates a couple of rule descriptions.

* Adds redirects.

* Fixes unit tests.

* Removes duplicated section.

* Updates `no-before-interactive-script-outside-document` description.

* Fixes lint.

* Fixes integration tests.

* Adds description to `no-before-interactive-script-outside-document` documentation.

* Removes `link-passhref` from rules list.

* Updates remaining `pages/_middleware.js` references.

* Adds consistancy to messaging in new `no-styled-jsx-in-document` rule.

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-13 21:17:42 -05:00
Steven
ec4df71352
Fix Image Optimization cache-control regression with external images (#37625)
In a previous PR (#34075), the ISR behavior was introduced to the Image Optimization API, however it changed the cache-control header to always set maxage=0. While this is probably the right behavior (the client shouldn't cache the image), it introduced a regression for users who have CDNs in front of a single Next.js instance (as opposed to [multiple Next.js instances](https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#self-hosting-isr)).

Furthermore, the pros of client-side caching outweight the cons because its easy to change the image url (add querystring param for example) to invalidate the cache.

This PR reverts the cache-control behavior until we can come up with a better long-term solution.

- Fixes #35987
- Related to #19914 
- Related to #22319 
- Closes #35596
2022-06-13 22:13:55 +00:00
JJ Kasper
668466bc07
Fix rewrite/dynamic interpolation E2E cases (#37669) 2022-06-13 15:46:19 -05:00
JJ Kasper
3b9f180d25
Allow passing FileRef directly to createNext (#37664)
* Allow passing FileRef directly to createNext

* update type
2022-06-13 15:28:34 -05:00
Gal Schlezinger
b62bb97b6f
Re-introduce Edge API Endpoints (#37481)
* Re-introduce Edge API Endpoints

This reverts commit 210fa39961, and
re-introduces Edge API endpoints as a possible runtime selection in API
endpoints.

This is done by exporting a `config` object:

```ts
export config = { runtime: 'edge' }
```

Note: `'edge'` will probably change into `'experimental-edge'` to show
that this is experimental and the API might change in the future.

* Support `experimental-edge`, but allow `edge` too

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-06-13 11:17:44 -07:00
JJ Kasper
b33bc2dfb0
Update flakey next-script tests (#37663) 2022-06-13 09:54:59 -05:00
JJ Kasper
6f698405dd
Update matched path params priority (#37646)
This ensures we use the correct dynamic route params favoring params from the URL/matched-path over route-matches. This also ensures we properly cache `_next/data` requests client side when the page is not a `getServerSideProps` page. 

x-ref: https://github.com/vercel/next.js/pull/37574

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] 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`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-13 13:34:08 +00:00
Joe Previte
6108f10799
feat(next export): add warning if using getInitialProps (#37642)
This PR builds on the work from @hattakdev (PR went stale: https://github.com/vercel/next.js/pull/14499) and adds a new `integration` test for the new warning.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

![image](https://user-images.githubusercontent.com/3806031/173214117-f5159f3a-778c-4177-894d-78e7bb0c80e7.png)

## To run locally
1. `pnpm build` 
2. `pnpm testonly test/integration/export-getInitialProps-warn/test/index.test.js`

Fixes #13946

## Notes

<details>
<summary>Click to toggle see</summary>

I know the `contributing.md` doc said to avoid adding new tests to `integration`. It also said new tests should be written in TypeScript.

I wasn't sure where to put the tests for this so I went with `integration`. I also didn't see many other tests written in TS in this part of the codebase so I stuck with `.js`. 

</details>

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-13 02:34:23 +00:00
Damien Simonin Feugas
ae44779bcb
chore: narrows regexp to enable middleware source maps (#37582)
* chore: narrows regexp to enable middleware source maps

* update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-10 20:22:03 -05:00
JJ Kasper
934e5a4835
Update usage of example.com -> example.vercel.sh (#37630)
* Update usage of example.com -> example.vercel.sh

* another one

* another flakey test
2022-06-10 18:19:37 -05:00
Jiachi Liu
12b726fd15
Strip next internal queries for flight response (#37617)
Strip next internal queries in inline flight response

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-10 20:08:24 +00:00
Hannes Bornö
7cc8f92241
i18n regression tests and docs for ignore locale in rewrite (#37581)
* Add regression tests for locale prefixed public files

* Add tests for ignoring source locale in rewrite

* Fix lint

* Add doc example

* Redirect tests

* fix test names

* update tests

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-10 14:04:31 -05:00
JJ Kasper
607ff2b322
Update to process redirects/rewrites for _next/data with middleware (#37574)
* Update to process redirects/rewrites for _next/data

* correct matched-path resolving with middleware

* Add next-data header

* migrate middleware tests

* lint-fix

* update error case

* update test case

* Handle additional resolving cases and add more tests

* update test from merge

* fix test

* rm .only

* apply changes from review

* ensure _next/data resolving does not apply without middleware
2022-06-10 12:35:12 -05:00
Shu Ding
78cbfa06fb
Revert "Revert "Avoid unnecessary router state changes"" (#37593)
Reverts vercel/next.js#37572, with a new test case added about `routeChangeComplete`.
2022-06-09 15:48:50 +00:00
Jiachi Liu
0bfdf0e0d1
Fix react root env missing in NextServer (#37562)
* Fix react root env missing in NextServer

* switch to useId instead of using process.env var

* add production test

* extend timeout

* fix test

* fix lint

* use version to detect if enable react root
2022-06-09 15:43:38 +02:00
Gal Schlezinger
9155201807
[middleware] support destructuring for env vars in static analysis (#37556)
This commit enables the following patterns in Middleware:

```ts
// with a dot notation
const { ENV_VAR, "ENV-VAR": myEnvVar } = process.env;

// or with an object access
const { ENV_VAR2, "ENV-VAR2": myEnvVar2 } = process["env"];
```

### Related

- @cramforce asked this fixed here: https://github.com/vercel/next.js/pull/37514#discussion_r892437257



## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-09 11:49:58 +00:00
Kiko Beats
76083210ed
Middleware: remove req.ua (#37512)
This PR moves the internal logic associated with `req.ua` into an explicit method the user should to call to have the same behavior.

**before**

```typescript
// middleware.ts
import { NextRequest, NextResponse } from 'next/server'
export function middleware(request: NextRequest) {
  const url = request.nextUrl
  const viewport = request.ua.device.type === 'mobile' ? 'mobile' : 'desktop'
  url.searchParams.set('viewport', viewport)
  return NextResponse.rewrites(url)
}
```

**after**

```typescript
// middleware.ts
import { NextRequest, NextResponse, userAgent } from 'next/server'
export function middleware(request: NextRequest) {
  const url = request.nextUrl
  const { device } = userAgent(request)
  const viewport = device.type === 'mobile' ? 'mobile' : 'desktop'
  url.searchParams.set('viewport', viewport)
  return NextResponse.rewrites(url)
}
```

This potentially will save the extra 17 kB related to the size of `ua-parser-js`
2022-06-09 11:10:21 +00:00
Shu Ding
23295ef34b
Revert "Avoid unnecessary router state changes" (#37572)
Reverts vercel/next.js#37431
2022-06-08 21:51:40 +00:00
Damien Simonin Feugas
08ed362b82
chore: reworks nested middleware error message (#37513)
* chore: reworks nested middleware error message

* chore: fix invalid path in nested middleware error message

* Update to show nested middleware error together

* update

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-08 11:51:26 -05:00
Damien Simonin Feugas
09f48a7590
fix(eslint): false positive for legit next/server imports (#37515)
* fix(eslint): next/server error when next is not in the root

* chore: fix lint issue and posix compatibility

* chore: make it portable
2022-06-08 11:08:59 -05:00
Javi Velasco
7584b02b34
Remove Middleware Preflight (#37490)
* Refactor data fetching to support getting headers

* Relax `getNextPathnameInfo` type

* Add test for middleware internal redirects

* Export `ParsedRelativeUrl` type

* Refactor `getMiddlewareEffects`

* Move rewrite i18n test to middleware rewrite tests

* Fix bug parsing pathname info

* Normalize data requests to page requests for middleware

* Ensure there is a header `x-nextjs-matched-path` for middleware rewrites on data requests

* Extract `getDataHref` to a function

* Stop using `getDataHref` for flight

* Always set the query in `dataHref` independently of if it is SSG

* Add test for recursive rewrites

* Refactor dynamicPath validation to `matchHrefAndAsPath`

* Add `dataHref` to `FetchDataOutput`

* Extract `matchesMiddleware` function

* Add `hasMiddleware` option to `fetchNextData`

* Move preflight test

* Remove preflight test

* Add middleware prefetch tests

* Remove preflight

* Attempt to reduce bundle size

Include `withMiddlewareEffects` and `matchHrefAndAsPath` into `router`

Bring `getDataHref` back to `page-loader`

Bring `resolveDynamicRoute` back to `router`

* Reduce arg duplication for `withMiddlewareEffects`

* Remove some async/await and spreads to reduce bundle size

* Upgrade `edge-runtime` & clone `Request` on redirects to mutate headers

* Add some rewrite tests

Co-authored-by: Kiko Beats <josefrancisco.verdu@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-08 10:41:28 -05:00
Damien Simonin Feugas
977ff52472
fix(#37106): middleware can not be loaded from src folder (#37428)
## Bug
fixes #37106

Please note that, as for `pages/` the `src/middleware` file is ignored when `/middleware` is present.

## How to test

1. Rebuild next.js `pnpm build`
2. Run dedicated tests: `pnpm testheadless --testPathPattern middleware-src/`
2022-06-08 14:10:05 +00:00
Jiachi Liu
16fd15b526
Migrate head side effects to hooks (#37526)
* rewrite head side effects component in hooks
* remove mapping from element to children in head manager since they're already the children of `<Head>`

When move `SideEffect` to hooks, the effects scheduling is earlier than life cycle. We're leverage layout effects and effects at the same time, always cache the latest head updating function in head manager in layout effects, and flush them in the effects. This could help get rid of the promises delaying approach in head manager.

Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2022-06-08 11:26:57 +00:00
Gal Schlezinger
88d0440ad4
[middleware] Support any method when fetching a Request instance (#37540)
There was a bug that ignored `Request` options when one was given to the `fetch` function:

```ts
const request = new Request("https://example.vercel.sh", { method: "POST" });
await fetch(request);
```

The code above was expected to make a `POST` request, but instead it
made a `GET` request.

This commit fixes it and adds some tests to verify that fetching with a
`Request` object works as expected, and therefore resolves #37123.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-08 11:00:49 +00:00
Keen Yee Liau
dc36199b22
add method to measure Interaction to Next Paint (INP) (#36490)
This commit lets users measure their Interaction to Next Paint [INP](https://web.dev/inp/) web vital.
Note that the `web-vitals` package is beta to denote that INP is an experimental metric, the code is stable and v3 is backwards compatible.

    `web-vitals` CHANGELOG for v3:
    
    - [BREAKING] Report TTFB after a bfcache restore
    - [BREAKING] Only include last LCP entry in metric entries
    - Add support for the new INP metric
    - Rename getXXX() functions to onXXX()
    - Add a navigationType property to the Metric object
    
    See https://github.com/GoogleChrome/web-vitals/blob/next/CHANGELOG.md

Upgraded `playwright-chromium` from `1.14.1` to `1.17.2` because the Events Timing API used to measure INP is only available in Chromium >= v98.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] 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`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-06-07 18:28:58 +00:00