Commit graph

3869 commits

Author SHA1 Message Date
Jan Kaifer
80ebfad19d
Handle async require when importing ESM in instrumentation.ts (#47658)
Fixed issue where `require` will return a Promise if (and only if) there
is an ESM module imported in `instrumentation.ts`:
61cd219f15/packages/next/src/server/next-server.ts (L212)

Had to move stuff to async function from constructor, but luckily we
already have `prepare`.
2023-03-30 16:05:26 +00:00
Jiachi Liu
16badb40c1
test: disable the flaky test for parallel-routes-and-interception (#47694)
x-ref: https://github.com/vercel/next.js/actions/runs/4548265038/jobs/8019160929?pr=47630
2023-03-30 15:25:51 +00:00
Jiachi Liu
99cdb36663
Vendor @vercel/og and expose ImageResponse (#47657
### What?

This PR vendors @vercel/og and export `ImageResponse` from
`next/server`. When you render a opengraph image the below code snippets
will be legit:

```tsx
import { ImageResponse } from 'next/server'

export default function og() {
  return new ImageResponse(<div style={{ width: '100%', height: '100%' }}>hello</div>)
}
```

### Why?

To make development more easier, user can directly use `@vercel/og`
Image Response with nextjs instead of install it and use it. This makes
building metadata icons, og or twitter images more convenient.

### How?

Closes NEXT-899
2023-03-30 13:06:30 +02:00
Steven
d19617e9c7
fix: image loaderFile with edge runtime (#47659)
- Fixes #47168 
- fix NEXT-909 ([link](https://linear.app/vercel/issue/NEXT-909))
2023-03-29 15:08:36 -07:00
Steven
b55633fe1c
fix: handle output: export with use client (#47635)
This PR removes usage of `appPaths` in favor of `hasAppDir` to avoid the
issue where export does not read app manifest.

Fixes the error:

```
TypeError: Cannot read properties of undefined (reading 'cssModules')
```

fix NEXT-885 ([link](https://linear.app/vercel/issue/NEXT-885))
2023-03-29 13:55:32 -07:00
Wyatt Johnson
aca83d2a09
Move App Route handler logic into bundle (#47633)
Previously the app route handler was included in the server bundle, and called into user code to execute the underlying handler logic. This PR serves to move the handler code into the bundle so that the Node.js environment more closely matches the Edge environment.

This also updates the Rust code for the new loader.
fix NEXT-712 ([link](https://linear.app/vercel/issue/NEXT-712))
2023-03-29 19:31:30 +00:00
Jiachi Liu
facea99f0e
Expose metadata types (#47630)
### What?

- Besides existing `Metadata` type, expose `ResolvingMetadata` and `ResolvedMetadata` to `'next'`.
- Group `Robots` / `Sitemap` / `Manifest` these dynamic data routes types as `MetadataRoute` type and expose to `'next'`

### Why?

Allow users to type the more API easily, and grouping them to avoid type conflicts (e.g. we have `Robots` in metadata interface field, `MetadataRoute.Robots` can avoid conflicts)

### How?

Closes NEXT-908
2023-03-29 11:16:47 +00:00
Shu Ding
54fce53dd9
Make sure the global not found route doesn't conflict with existing /not-found route (#47619)
In #47328 we made the root level `/not-found.js` a special entry, to
override the page 404 during builds. However, it's possible that the
user has a valid `/not-found/page.js` route that might conflict with
this special entry. This PR changes the entry to be `/_not-found` so it
will never conflict with existing valid entries.
2023-03-28 21:54:58 +02:00
JJ Kasper
28d56ec95f
Update test create-next-app running (#47611)
This re-enables running the CNA tests for all non-docs changes as it's now ensuring we don't regress on turbopack or our default templates. 

Also fixes the main repo's package.json files from being modified during tests.
2023-03-28 17:39:00 +00:00
JJ Kasper
4d0f5a0503
Revert "Move App Route handler logic into bundle" (#47614)
Reverts vercel/next.js#47582

This breaks turbopack support so we should address that before landing.
Potentially we can re-use the same loader for both which would eliminate
this issue.

x-ref:
https://github.com/vercel/next.js/actions/runs/4544370605/jobs/8010399819
x-ref:
https://github.com/vercel/next.js/actions/runs/4545240650/jobs/8012475072?pr=47611
fix NEXT-712 ([link](https://linear.app/vercel/issue/NEXT-712))
2023-03-28 10:12:03 -07:00
Wyatt Johnson
5dc31354b9
Move App Route handler logic into bundle (#47582)
Previously the app route handler was included in the server bundle, and
called into user code to execute the underlying handler logic. This PR
serves to move the handler code into the bundle so that the Node.js
environment more closely matches the Edge environment.
fix NEXT-712 ([link](https://linear.app/vercel/issue/NEXT-712))
2023-03-28 16:38:17 +02:00
Wyatt Johnson
bf52c25497
Underscore Handling Fixes (#47581)
Previously to this PR, if an absolute path contained an `_` it would
ignore all app files. If for example the Next.js app was in a folder
named `/some/_directory` then today:

```
/some/_directory/app/page.js <- should 200, currently 404
/some/_directory/app/route.js <- should 200, currently 404
/some/_directory/app/_internal/route.js <- should 404, currently 200 in development
```

This also enables the same `_` functionality for app routes in
development. After this PR, we get:


```
/some/_directory/app/page.js <- 200
/some/_directory/app/route.js <- 200
/some/_directory/app/_internal/route.js <- 404
```
2023-03-28 12:19:01 +02:00
Jan Kaifer
54a08ebe77
Fix instrumentation not being called on edge in some cases (#47495)
- Modified tests to catch issue with instrumentation not being invoked
for edge api calls
- Add tests for middleware
- Add instrumentation into middleware bundle

<!-- Thanks for opening a PR! Your contribution is much appreciated.
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(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-03-27 20:54:43 +00:00
JJ Kasper
4a2df3c375
Fix fetch cache config and fetch revalidates (#47573)
This ensures we properly honor config and fetch based revalidate on the
same page in fetch cache.

Fixes:
https://github.com/vercel/next.js/actions/runs/4529647521/jobs/7978177827
2023-03-27 13:08:23 -07:00
Shu Ding
b28cd21ee5
Improve client boundary source type detection (#47532)Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Currently in a client boundary file, we only explicitly export
individual fields in ESM (`export foo`) when the source type is
`module`. However in most of the time SWC gives the `auto` source type.
This PR improves the type detection a bit so if it's `auto` and we do
see ESM exports collected, we assume it's ESM and re-export these
fields.

Fixes #41940, fix NEXT-796
([link](https://linear.app/vercel/issue/NEXT-796)).

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-27 19:16:23 +02:00
Jan Kaifer
1cea1c22bc
Remove unneeded waiting in otel tests (#47431)
- wip
- remove waiting for otel before tests
- remove useless timeout in test



fix NEXT-815 ([link](https://linear.app/vercel/issue/NEXT-815))
2023-03-27 10:50:06 +00:00
JJ Kasper
ac84542fda
Update some flakey test cases (#47556)
x-ref:
https://github.com/vercel/next.js/actions/runs/4529093785/jobs/7976512430
x-ref:
https://github.com/vercel/next.js/actions/runs/4529093785/jobs/7976517246
x-ref:
https://github.com/vercel/next.js/actions/runs/4528686011/jobs/7976058968
2023-03-26 23:41:15 -07:00
JJ Kasper
d34ba2b0ff
Update failing i18n e2e deploy test (#47555)
Temporarily skips a failing test case on e2e deploy mode for i18n-hybrid
test suite.

x-ref:
https://github.com/vercel/next.js/actions/runs/4520873270/jobs/7962318031
2023-03-26 22:40:32 -07:00
OJ Kwon
73491e16c3
test(test-utils): correct --turbo error overlay lookup (#46901)
### Fixing a bug

Minor fix for https://github.com/vercel/next.js/pull/46589, forgot to
wrap in evaluate in result fail to ask to browser to lookup overlay in
--turbo tests.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-26 21:30:16 -07:00
Janicklas Ralph
83c2a3f09c
Integrating capsize latest (#47428)
Integrating capsize latest

<!-- Thanks for opening a PR! Your contribution is much appreciated.
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(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-26 20:29:28 -07:00
Ngô Đức Anh
c748b16555
Feat(next-types-plugin): added support for Route Handlers (#47185)
Thanks for opening a PR! Your contribution is much appreciated.
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(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to understand the PR)
- When linking to a Slack thread, you might want to share details of the conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic behind a change

### What?

This PR adds next-types-plugin's support for Route Handlers.

### Why?

Since `route.js` is somewhat like `page.js` and `layout.js`, I find it to be necessary that we also enable TS checks for these files as well.

### How?

Just changing the `createTypeGuardFile` function a bit and adding a few new tests, yeah.
2023-03-26 23:34:54 +00:00
Tim Neutkens
baae7b1f44
Clean up leftover loaders (#46801)
More cleanup flowing out of the removal of the `target` option.

<!--
Thanks for opening a PR! Your contribution is much appreciated.
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(s) that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/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`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

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

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-03-25 10:21:27 +01:00
Tim Neutkens
a058b8569e
Remove head.js (#47507)
### What?

Removes `head.js` file convention in favor of built-in SEO support through `metadata`: https://beta.nextjs.org/docs/guides/seo

### Why?

The `head.js` convention was superseded by the built-in SEO support which is designed specifically for Server Components.

### How?

Removed the `head.js` handling in app-loader and the tests for it.

fix NEXT-812 ([link](https://linear.app/vercel/issue/NEXT-812))
2023-03-25 01:40:30 +00:00
JJ Kasper
4b4dd8b33a
Fix other case for useSelectedLayoutSegments (#47511)
Follow-up to https://github.com/vercel/next.js/pull/47492 this ensures
we properly check for `__PAGE_` elsewhere and re-enables some other
tests now that it's passing.
2023-03-24 16:06:17 -07:00
JJ Kasper
318642a1d9
Update flakey app dev tests (#47504)
x-ref:
https://github.com/vercel/next.js/actions/runs/4513582756/jobs/7948722605
x-ref:
https://github.com/vercel/next.js/actions/runs/4513582756/jobs/7948722818
x-ref:
https://github.com/vercel/next.js/actions/runs/4513366262/jobs/7949059763
2023-03-24 15:44:44 -07:00
Jan Kaifer
adf8c7f6e7
Add http.route into root otel span (#47392)
Co-authored-by: Steven <steven@ceriously.com>
2023-03-24 17:52:28 +00:00
Jimmy Lai
de8e4e999e
parallel routes: implement default route + fix bugs on navigation (#47436)
### What?

This PR is another part of making parallel routes viable!

- enables some of the tests, partially only in dev (build fails because
the intersection routes are not implemented)
- introduces a new type of special file: a `default` file that can be
added to any segment, next to `page` etc, that will act as the
default/placeholder when a layout does not match
- this also fixes bugs when navigating within parallel routes

### Why?

### How?

<!-- Thanks for opening a PR! Your contribution is much appreciated.
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(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

fix NEXT-748 ([link](https://linear.app/vercel/issue/NEXT-748))

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-24 18:01:41 +01:00
JJ Kasper
ba9b94d5fb
Fix failing og api e2e test (#47500)
x-ref: https://github.com/vercel/next.js/actions/runs/4508438652/jobs/7937409460
2023-03-24 15:59:45 +00:00
Tim Neutkens
68abad58ed
Fix useSelectedLayoutSegments including __PAGE__ (#47492)
### What?

Excludes `__PAGE__` elements from `useSelectedLayoutSegment` as it's not
a public api.
This ensures the exclude still applies when there are searchParams part
of the key.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
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(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-03-24 16:13:22 +01:00
Wyatt Johnson
b8d785d286
Locale fixes for App Directory (#47429)
Fixes issue with app directory that caused problems with `i18n` was
enabled. Previously, when you accessed a URL like `/blog/first-issue`,
you would expect it to hit the app route at `/app/blog/[slug]/page.tsx`,
but instead it internally attempted to access
`/app/{defaultLocale}/blog/[slug]/page.tsx` (where `{defaultLocale}` is
set in `next.config.js` via `i18n.defaultLocale`). This is because while
the path did not assume the locale, the domain/default was enough to
suggest it, causing the mismatch.

This adds a new internal parameter for tracking this _default_
assignment so it can be handled by the matcher correctly.

Fixes #46814
Fixes #46841
fix NEXT-777 ([link](https://linear.app/vercel/issue/NEXT-777))
fix NEXT-834 ([link](https://linear.app/vercel/issue/NEXT-834))

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-24 13:06:27 +01:00
Shu Ding
9fff7e321c
Finalize HOC support with server entries and add encodeReply & decodeReply (#47438)
Revert some code in #47379 and finalize HOC support. We should require
the HOC to return a "use server" function, so there's no need to compile
the function call specially now.

To make that wrapping logic work, we need to allow passing a server
reference to another server reference. This usually happens in the
function closure in the HOC case, but ideally it's also allowed to
directly pass it as an argument. This requires adding React server DOM's
`encodeReply` and `decodeReply` and other corresponding changes,
including adding `busboy` (can probably be vendored?) as we need to
parse the multipart body now.

fix NEXT-808 ([link](https://linear.app/vercel/issue/NEXT-808))
([link](https://linear.app/vercel/issue/NEXT-808))
2023-03-24 13:01:10 +01:00
Tim Neutkens
b9be75df03
Ignore folders prefixed by underscore (_) in App Router (#47439)
### What?

In `app` all directories starting with `_` are now considered private
and won't be routed.

E.g. `app/_components/page.js` -> does not route

If you want to have a route starting with an underscore like
`/_settings` you can use `%5F` which is the url encode version of `_`:
`app/%5Fsettings/page.js`-> does route

### Why?

Ensures that you can create directories that will never conflict with
Next.js internal naming. E.g. when additional conventions are added for
file names.

### How?

It's a bit more involved than you might expected:
- build
- While resolving entries by traversing `app` parts with `_` are ignored
	- While normalizing entires `%5F` is replaced with `_`
- I've changed one case that was relying on the entry name for resolving
to use the full path to the file instead.
- dev
- Ignored paths with underscore from being generated as part of the
initial scan of the filesystem
- Updated development and production the route matcher to replace `%5F`
with `_` so that it matches the right path.

fix NEXT-798 ([link](https://linear.app/vercel/issue/NEXT-798))
([link](https://linear.app/vercel/issue/NEXT-798))

<!-- 
## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-24 12:53:11 +01:00
Islam Shehata
b39a03f4e3
add useReportWebVitals that makes use of web-vitals package (#47319)
### What?
introduce a new hook `useReportWebVitals` that would register a function to handle web-vitals metrics. 

### Why?
next.js users who use [Axiom](https://axiom.co) has been [asking](https://github.com/axiomhq/next-axiom/issues/109) for this feature for nextjs 13, as it was working for nextjs 12.
2023-03-24 10:13:50 +00:00
JJ Kasper
af89adbd61
Update fetch cache memory handling (#47465)
This ensures we only honor cache entries from the in memory cache for up
to 2 seconds so that revalidates can correctly propagate and also
increases max fetch cache entry size to 2 MB. The `fetchCache` export is
also being detected in this PR but not yet honored which will be done in
a follow-up.
2023-03-23 22:30:08 -07:00
Steven
26f8793e85
chore: add telemetry for output: export (#47464)
fix NEXT-870 ([link](https://linear.app/vercel/issue/NEXT-870))
2023-03-23 17:52:17 -07:00
JJ Kasper
9f7318a8f9
Update failing i18n e2e deploy test (#47462)
This tests is currently not expected to work in the deploy mode so this
temporarily skips it for now

x-ref:
https://github.com/vercel/next.js/actions/runs/4504603973/jobs/7929514077
2023-03-23 15:53:14 -07:00
Steven
4769407006
chore: run all tests for next/image against app dir (#47267)
These tests are copy/pasta from existing tests

- from `test/integration/next-image-new/default`
- to `test/integration/next-image-new/app-dir` 

There were a handful of changes need to migrate the fixture from `pages` to `app` but the test assertions are the same.

There is one test assertion for preload that wasn't working so its marked as "skip" until it can be fixed in a future PR.

fix NEXT-849 ([link](https://linear.app/vercel/issue/NEXT-849))
2023-03-23 22:02:40 +00:00
JJ Kasper
a01ea2335d
Update failing e2e deploy test (#47453)
Temporarily skips failing test in deploy mode

x-ref:
https://github.com/vercel/next.js/actions/runs/4474556375/jobs/7863295708
x-ref:
https://github.com/vercel/next.js/actions/runs/4495220910/jobs/7909314612
2023-03-23 12:29:51 -07:00
Jiachi Liu
d187c36503
Add content hash for dynamic og image routes (#47440)
* Add `contenthash` as query (`?<hash>`) for dynamic image and icon
routes as well.
* Merge the metadata image info extration into 1 single loader, dynamic
and static image route will all pass through
`next-metadata-image-loader` to extract the image info such as size,
content type, etc.
* Applying same cache header from `@vercel/og`, for development we use
"no cache" header, for production, we use "long cache" header

Closes NEXT-882
2023-03-23 17:38:42 +01:00
Shu Ding
ae71ff6eb7
Error during dev if returning Response in pages API routes in Node.js runtime (#47442)
This avoids the case that one can accidentally return a `Response` object in the Node.js runtime in `pages/api/`, that causes the request to hang forever.
2023-03-23 15:54:23 +00:00
Shu Ding
38cddd902b
Add test for force-dynamic and catch-all routes (#47418
fix NEXT-640 ([link](https://linear.app/vercel/issue/NEXT-640))
([link](https://linear.app/vercel/issue/NEXT-640)). Fix #45603.

https://github.com/vercel/next.js/issues/45603#issuecomment-1480195089
2023-03-23 15:53:51 +01:00
Steven
9791d1e608
feat: change next build to emit output with output: export (#47376)
This PR ensures the correct output is emitted during `next build` and
deprecates `next export`.

The `output: export` configuration tells it to emit exported html and
the `distDir: out` configures the output directory.

```js
module.exports = {
  output: 'export',
  distDir: 'out',
}
```

fix NEXT-868 ([link](https://linear.app/vercel/issue/NEXT-868))

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-23 15:40:18 +01:00
Jiachi Liu
b2ca7a3bf8
Fix twitter metadata info merging (#47433)
* Fix rest of twitter metadata when merging with static metadata images,
should include title/description/etc. properties
* rename `opengraph` to `openGraph` property

Related to NEXT-266
Follow up for #47425 

Fixing the twitter metadata are missing found while testing
<img width="583" alt="image"
src="https://user-images.githubusercontent.com/4800338/227190635-60867873-d3b5-4bdc-ab5a-24abdded8faa.png">
2023-03-23 13:04:26 +01:00
Jimmy Lai
0416bd559d v13.2.5-canary.14 2023-03-23 10:15:46 +01:00
Jiachi Liu
9150620993
Support dynamic routes for social images and icons (#47425)
Redo #47372 , basically revert #47416 and upgrade og (https://github.com/vercel/og/pull/60)

Closes NEXT-264
Closes NEXT-266
2023-03-23 00:12:22 +00:00
Shu Ding
b1d2200770
Add optional match support of rewrites and redirects in typedRoutes (#47398)
This PR refactors the types plugin a bit and adds support for optional match groups in rewrites and redirects:

```js
source: '/redirect(/v1)?/guides/:param/page'
```

Which will be created as two rules:

```ts
| `/redirect/guides/${SafeSlug<T>}/page`
| `/redirect/v1/guides/${SafeSlug<T>}/page`
```

fix NEXT-875 ([link](https://linear.app/vercel/issue/NEXT-875))
2023-03-22 23:27:59 +00:00
JJ Kasper
76f8e41113
Update failing e2e checks (#47423)
x-ref:
https://github.com/vercel/next.js/actions/runs/4484749964/jobs/7885622738
x-ref:
https://github.com/vercel/next.js/actions/runs/4484749964/jobs/7885622985
x-ref:
https://github.com/vercel/next.js/actions/runs/4484749964/jobs/7885704581
2023-03-22 15:32:06 -07:00
Shu Ding
783d7d589c
Extend not-found.js to catch all unmatched routes (#47328)
This PR continues the work of #45867, that treats the root-level `not-found.js` file inside app dir as the global 404 page, if it exists. Previously, it fallbacks to the /404 route inside pages (and the default one if `404.js` isn't specified).

In the implementation, we include `/not-found` in `appPaths` during the build, and treat it as the special `/404` path during pre-rendering. In the renderer, if the `/404` pathname is being handled, we always render the not found boundary.

And finally inside the server, we check if `/not-found` exists before picking up the `/404` component.

A deployed example: https://not-found-shuding1.vercel.app/balasdkjfaklsdf

fix NEXT-463 ([link](https://linear.app/vercel/issue/NEXT-463))
2023-03-22 22:16:50 +00:00
Jiachi Liu
de92781145
Add default meta tags to error page (#47404)
Default tags of `charset` and `viewport` should also be rendered in app
router error pages like not found pages.

Closes NEXT-869

This PR:
* Extract not found boundary to single component
* Add the default tags to `NotFoundErrorBoundary` rendering
* Fix duplicated `noindex` tag for streaming error rendering
2023-03-22 22:44:45 +01:00
JJ Kasper
84a416b5e1
Fix build spinner in TTY env (#47383)
This ensures the build spinner is correctly stopped in a TTY environment
and also adds regression tests for `app` and `pages` to ensure this
behaves as expected.

This updates our docker image to use the `jammy` tag instead of `focal`
to match the Ubuntu version to our CI.
2023-03-22 12:56:39 -07:00