Commit graph

3581 commits

Author SHA1 Message Date
JJ Kasper
81a4063db7
Update CNA tests (#45768
These had incorrect import alias flags since the `"` characters were
being included incorrectly.

x-ref:
https://github.com/vercel/next.js/actions/runs/4137310428/jobs/7152385081
2023-02-09 14:59:28 -08:00
Shu Ding
d841f8ea83
Move CSS tests out of the main test suite (#45765)
No changes in this PR, just move out all CSS related tests out of
app-dir/app/index.tests.ts into a separate suite.

## 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: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-09 23:22:53 +01:00
Jiachi Liu
e8e85effd6
Support favicon.ico for metadata (#45759
## Feature

* Picking up root favicon (`/app/favicon.ico`) into icons, and add
missing `type` prop for `<link>`
* Fixes the `/favicon.ico` 500 in dev server (`fileExists` checking
part)

Closes NEXT-475

- [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`
- [ ]
[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)
2023-02-09 13:14:09 -08:00
Shu Ding
bb9bb64864
Fix global CSS loader behavior when appDir is enabled (#45739)
The current behavior is, when `appDir` is enabled, global CSS should be
allowed to be imported from anywhere (because components can be re-used
by both pages and app). Changes in #45619 made it not behaving correctly
and this PR fixes it.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] 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)
2023-02-09 14:33:45 +01:00
JJ Kasper
77bab39097
Ensure bundle 404 can be rewritten in dev (#45728)
This fixes a mismatch in behavior between dev/start where bundle 404s
could be rewritten in production but not dev. Also ensures we have a
regression test for this behavior.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1675869554570429)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

---------

Co-authored-by: Shu Uesugi <shu.chibicode@gmail.com>
2023-02-08 22:02:39 -08:00
Jiachi Liu
628bc4c07b
Allow setting metadataBase for metadata (#45719)
## Feature

For property that needs to be resolved as URL, compose with
`metadataBase` if it's provided

Closes NEXT-398

### Detail updates

* fix issue that path having extra `/` in the middle for pages path
under app dir
* don't render Meta if value is empty string, e.g. `og:title` can be
`''` from value of `title.absolute`
* did some refactor to separate resolvers into different files
* add some unit tests for resolve urls

- [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]
[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)

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-02-09 01:35:19 +01:00
Vu Van Dung
7654d7bc2d
Allow generateMetadata to be synchronous (#45696)
The very-newly-released `generateMetadata` function currently does not
allow itself to be synchronous. It leads to situations like this

```ts
export async function generateMetadata() {
  return { title: "Hello, world!" };
}
```

where there's evidently no reason to use `async`, but it's forced by
Next.js.

This PR aims to remove this restriction: `generateMetadata` can be
synchronous now.

## Bug

- [x] Related issues linked using `fixes #45685`
- [ ] 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`
- [x]
[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)

Signed-off-by: Vu Van Dung <me@joulev.dev>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-02-08 21:02:03 +01:00
Shu Ding
a25c32a9a0
Fix CSS loaders in pages when app dir is enabled (#45619)
This PR changes the loader logic from something like `ctx.hasAppDir ?
useAppLoaderForCSS : usePagesLoaderForCSS`, to a mental modal of
`[ctx.hasAppDir ? useAppLoaderForCSSInAppLayer : null,
usePagesLoaderForCSSInPagesLayer]`. This change makes sure that both
pages and app can exist and work well together, instead of a binary
switch.

Also renamed the loader with `-dev` removed, because it is used for
production build too.

NEXT-461

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] 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: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-08 20:55:01 +01:00
JJ Kasper
434a8cb7d0
Fix missing hasHeader mock during revalidate (#45681)
Replaces usage of `hasHeader` of `getHeader` and also ensures we include
`hasHeader` in our `mockRes` we create during revalidate for good
measure.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

Closes: https://github.com/vercel/next.js/issues/34929
Closes: https://github.com/vercel/next.js/issues/37338
Closes: https://github.com/vercel/next.js/issues/45481
2023-02-07 17:51:26 -08:00
Jiachi Liu
e36fb42e30
Add warning for head.js with metadata docs link (#45680)
Warn users when there's `head.js` being used in `app/`, and recommend to
use metadata. Will show a warning in console while rendering

Closes NEXT-268

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Lee Robinson <me@leerob.io>
2023-02-07 17:02:40 -08:00
JJ Kasper
01649d93ab
Skip prefetching for bots in app-router too (#45678)
Same as https://github.com/vercel/next.js/pull/40435 this ensures we
don't prefetch for bots in `app-router` as well.

Fixes: https://github.com/vercel/next.js/issues/45677

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-02-07 14:15:10 -08:00
Wojtek Olek
6444006f23
[ESLint] Add app dir to default linting directories (#44426)
Fixes #44424 by adding the `app` folder to an `ESLINT_DEFAULT_DIRS`
constant which defines all folders where the linter should go through.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-02-07 13:53:46 -08:00
Jiachi Liu
c26fc2456b
Picking apple-icon instead of apple-touch-icon (#45673)
Fix up a icon convention in #45612, we should pick up the
`apple-icon.<ext>` as this is a shorter path for users to remember.

Also addessing some feedbacks from @shuding in #45612

---------
2023-02-07 13:25:39 -08:00
Hannes Bornö
7f28195dc4
Improve client-only imported in external package error (#45484)
Currently if an external package imports `'client-only'` it's difficult to figure out why the error occured. This change adds an explanation of which import caused the error.

The errors in the images are from using `<style jsx>` in a Server Component.

Before, runtime error on the server
![image](https://user-images.githubusercontent.com/25056922/216080617-9eebf99e-2899-4d7e-80b6-ef7ded0831ce.png)

After, webpack error with added stack trace
![image](https://user-images.githubusercontent.com/25056922/216303311-05c2f3ca-2857-4fe7-b55c-caaccf5f46bb.png)


Fixes NEXT-409

## 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)
2023-02-07 19:56:03 +00:00
Jiachi Liu
25dfdbb131
Support filebased metadata icon and apple touch icons (#45612)
This PR add supports for a shortcut for adding `icons.icon` or
`icons.apple` metadata for page or layout with static files.

Closes NEXT-263
Closes NEXT-260

If you specific icon.png or apple-touch-icon.png, they will be
automatically picked by and added into metadata as `icon` and
`apple-touch-icon` fields, and replace the `icons` field specified in
page/layout level metadata exports.

File matching rule:
```
icon -> /^icon\d?\.(ico|jpg|png|svg)$/
apple-touch-icon -> /^apple-touch-icon\d?\.(ico|jpg|png|svg)$/
```

## Feature

- [x] 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]
[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)

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-07 18:30:59 +01:00
Jan Kaifer
3827d8fbfb
Fix issue where layout-router wouldn't auto-scroll if we imported styles or fonts (#45487)
fixes https://github.com/vercel/next.js/issues/42492
2023-02-07 12:03:18 +00:00
Tim Neutkens
30a6c51296
Refactor server-patch-reducer and refresh-reducer to use applyFlightData and handleMutable (#45608)Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Jan Kaifer <jan@kaifer.cz>
Follow-up to #45555. This uses the same handling of mutable for
serverPatchReducer and refreshReducer.

Fixes NEXT-213

Ensures scroll position is still applied when calling `router.push()`
and `router.refresh()` in a single transition:
```tsx
startTransition(() => {
    router.push('/dashboard')
    router.refresh()
})
```
<!--
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: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Jan Kaifer <jan@kaifer.cz>
2023-02-06 14:53:34 +01:00
JJ Kasper
f01543a753
Fix unsafe caching for isolated tests (#45602)
Noticed while testing across CI environments that the `test-pack` handling is not-concurrent or cache safe so this removes it from being used by default and moves it behind a flag to allow further investigating later. 

In CI if `test-pack` is called at the same time due to multiple concurrency it can cause the resulted archive to be corrupted so may require a form of lock to resolve in CI although locally re-using the same archive name/path isn't safe with pnpm as it won't bust the store cache and continue to leverage previous cache.
2023-02-06 09:01:44 +00:00
Jiachi Liu
a2dc530f44
Separate next/dynamic implementation for app and pages (#45565)
## Issue

To address the problem that we introduced in 13.0.7 (#42589) where we thought we could use same implementation `next/dynamic` for both `pages/` and `app/` directory. But it turns out it leads to many problems, such as:

* SSR preloading could miss the content, especially with nested dynamic calls
  * Closes #45213
* Introducing suspense boundary into `next/dynamic` with extra wrapped `<Suspense>` outside will lead to content is not resolevd during SSR
  * Related #45151
  * Closes #45099
* Unexpected hydration errors for suspense boundaries. Though react removed this error but the 18.3 is not out yet.
  * Closes #44083
  * Closes #45246
 
## Solution

Separate the dynamic implementation for `app/` dir and `pages/`. 

For `app/` dir we can encourage users to: 
  * Directly use `React.lazy` + `Suspense` for SSR'd content, and `next/dynamic` 
  * For non SSR components since it requires some internal integeration with next.js.

For `pages/` dir we still keep the original implementation

If you want to use `<Suspense>` with dynamic `fallback` value, use `React.lazy` + `Suspense` directly instead of picking up `next/dynamic` 
  * Closes #45116

This will solve various issue before react 18.3 is out and let users still progressively upgrade to new versions of next.js.

## Bug Fix

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-02-04 01:45:35 +00:00
Hannes Bornö
e3ed2f27e1
Add editor links to module import traces (#45257)
Makes it possible to open the files in module import traces in your editor by clicking them.

Module not found:
![image](https://user-images.githubusercontent.com/25056922/214539916-a776fa6f-7645-49c8-9106-a2abd62a8447.png)

Parse error:
![image](https://user-images.githubusercontent.com/25056922/214539987-0e3fd312-7ade-44fc-a334-b95d73320775.png)

Fixes NEXT-422

## 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)
2023-02-04 00:41:01 +00:00
Hannes Bornö
06b6aa2fa4
Error when exporting AMP config in app dir (#45228)
Errors in app-render if an exported amp config is found.

Fixes NEXT-223

## 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)
2023-02-02 23:37:05 +00:00
Steven
bf7fea5b80
Fix image blur cover when fill and blurDataURL (#44317)
- Fixes #42765 
- Fixes #40644
2023-02-02 22:04:03 +00:00
Jan Kaifer
fdb3c1a4b9
Refactor next export tests (#45227) 2023-02-02 16:22:54 +00:00
Jan Kaifer
d022ccb432
Clean up CI logs (#45171) 2023-02-02 15:46:17 +00:00
Hannes Bornö
8aa42519f3
Reload on server component change (#45268)
If there's an error when hard navigating to a page, the overlay in `packages/react-dev-overlay` is rendered instead of the one in `next`. This can cause you to get stuck if it's a server component because currently `packages/react-dev-overlay` ignores server component change events. This adds a reload for this case. The next step is probably to make sure the `app` overlay is rendered for errors during hard navigations as well.

## 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)
2023-02-02 14:58:39 +00:00
Sam Ko
a85c636bfe
Fix middleware matcher for i18n with negative look ahead (#45504)closes https://github.com/vercel/next.js/issues/40305
<!--
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:
-->

Found a bug with excluding `/_next/static` from Edge Middleware due to
`/_next` being special-cased when deployed and i18n is configured.

```
export const config = {
  matcher: [
    '/',
    '/((?!api|_next/static|favicon|.well-known|auth|sitemap|robots.txt|files).*)',
  ],
};
```

closes: https://github.com/vercel/next.js/issues/40305

## Bug

- [X] Related issues linked using `fixes #number`
- [X] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-02-01 17:30:48 -08:00
Shu Ding
074b7e4dcc
Split router utils into smaller modules (#45451)Co-authored-by: Jan Kaifer <jan@kaifer.cz>
This makes sure that the entire module `shared/lib/router/router` isn't
included in the final bundle, by splitting it into smaller utils.

## 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: Jan Kaifer <jan@kaifer.cz>
2023-02-01 19:03:05 +01:00
LongYinan
221692b32e
build(cargo): update turbopack to turbopack-230201.1 (#45454)
### Features
- https://github.com/vercel/turbo/pull/3514
- https://github.com/vercel/turbo/pull/3530
- https://github.com/vercel/turbo/pull/3510
- https://github.com/vercel/turbo/pull/3497

### Bug fixes
- https://github.com/vercel/turbo/pull/3545
- https://github.com/vercel/turbo/pull/3522
- https://github.com/vercel/turbo/pull/3525
- https://github.com/vercel/turbo/pull/3518
- https://github.com/vercel/turbo/pull/3501
2023-02-01 16:36:43 +01:00
Jiachi Liu
c5f1b45923
Fix metadata alternate and refactor twitter item (#45480)
x-ref: https://github.com/vercel/next.js/discussions/41745#discussioncomment-4827270

refactor twitter related items based on @gnoff 's feedback

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-02-01 13:43:12 +00:00
Jiachi Liu
a1c04b0162
Support generateMetadata export (#45401)Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Closes NEXT-397

Resolve `metadata` and `generateMetadata()` exports along with head
during rendering, this is the easy way for now to collect all the
metadata properly. Since we can access segment params and search params
only in rendering, so I moved all the resolving logic from loader to
render process.

<!--
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 that you're making:
-->


## Feature

- [x] 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]
[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)

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-02-01 12:54:39 +01:00
Jan Kaifer
659a75177b
Update error message for dynamic = "error" (#45432)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-01 11:20:35 +00:00
Tim Neutkens
e01f0e4c4a
Remove leftover server.js files in test suite (#45408)
Removes leftover files that were used for `target: 'serverless'` which has been removed in Next.js 13.


## 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)
2023-02-01 10:00:52 +00:00
Hannes Bornö
e8fcf8b569
Add data attributes on @next/font usage (#45296)
Adds `data-next-font` data attribute to the preload tag if added by
`@next/font`.
```js
// Using `size-adjust` fallback font.
<link data-next-font="size-adjust" rel="preload" href="..." as="font" type="font/woff2" crossorigin="anonymous">

// Not using `size-adjust` fallback font.
<link data-next-font="" rel="preload" href="..." as="font" type="font/woff2" crossorigin="anonymous">
```

If no fonts are preloaded, the tag is added on the preconnect tag.

Fixes NEXT-350

## 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)
2023-01-31 14:16:13 -08:00
Shu Ding
326485c06e
Export the Metadata type (#45445)
This allows people to manually type their exported `metadata` field:

<img width="610" alt="CleanShot 2023-01-31 at 15 43 00@2x"
src="https://user-images.githubusercontent.com/3676859/215792182-8d9cf72a-dedf-4cc9-8613-d4eb49501abc.png">

## 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)

---------
2023-01-31 10:49:07 -08:00
Tim Neutkens
78c5be4e32
Add support for navigating to external urls (#45388)
Adds support for `router.push('https://google.com')`,
`router.replace('https://google.com')`, and
`redirect('https://google.com')`.

<!--
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 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: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-01-31 19:39:36 +01:00
Hannes Bornö
eef157f9df
@next/font change default font-display (#45430)
Change default font-display from `optional` to `swap`.

[slack
ref](https://vercel.slack.com/archives/C03KED0D4N7/p1674949620477649)

Fixes NEXT-430

## 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)
2023-01-31 08:26:38 -08:00
JJ Kasper
b00fd37972
Fix invalid source maps from terser-webpack-plugin (#45423)
This fixes a regression in our source map generating which got lost in
the big diff from the `src` folder restructure in
https://github.com/vercel/next.js/pull/44405

These invalid source maps broken plugins that attempted to leverage them
like `@sentry/nextjs` which only attempts in a production environment
15ec85bead/packages/nextjs/src/config/webpack.ts (L586)

For a regression test in a follow-up we will need to investigate a
production test fixture with `@sentry/nextjs` although this requires a
DSN be configured.

This also ensures we setup `unhandledRejection` and `uncaughtException`
listeners during build so that we have proper stack information when
these occur and the process isn't left hanging.

This also moves the `extensionAlias` config from
https://github.com/vercel/next.js/pull/44177 to an experimental config
as it seems to cause conflicts with ESM packages that define `exports`
in their `package.json` which can be considered a breaking change.

## Bug

- [x] 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)

Fixes: https://github.com/vercel/next.js/issues/45419
x-ref: [slack
thread](https://vercel.slack.com/archives/C03DQ3QFV7C/p1674937545579229)
2023-01-30 17:31:33 -08:00
Jiachi Liu
41e2613aca
Update robots meta and add verification rendering (#45409)
Follow up for: #45237

* Adding more fields for robots meta, most related to googlebot
* Add `me` and `yandex` field and render for verification field
2023-01-30 20:49:30 +00:00
JJ Kasper
d3a9f5a54a
Fix trailing slash redirect applying for data request (#45417)
This ensures we don't apply the trailing slash redirect for `_next/data`
requests as it can cause props to fail to resolve on client transition.
This also fixes `missing` fields not being applied correctly for
`headers` and `redirects` as the field wasn't being passed through.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

Closes: https://github.com/vercel/next.js/pull/45398
Fixes: https://github.com/vercel/next.js/issues/45393
x-ref: https://github.com/vercel/next.js/issues/45340
2023-01-30 12:10:30 -08:00
Hannes Bornö
9e290f9f15
Enable more hydration error overlay tests (#45404)
## 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)
2023-01-30 18:50:54 +00:00
Hannes Bornö
72baaebb92
Move error recovery test to new file (#45407) 2023-01-30 09:00:08 -08:00
JJ Kasper
c7deecfd29
Fix flakey app metadata test (#45391)
We shouldn't use an arbitrary timeout here.

x-ref:
https://github.com/vercel/next.js/actions/runs/4038320521/jobs/6942258801
2023-01-29 20:57:23 -08:00
JJ Kasper
13b32ba981
Ensure PATH env matches CI locally (#45376)
Since the tests are run with `pnpm test` locally this adds the repo's
`node_modules/.bin` to the PATH env variable although in CI `node
run-tests.js` is used which doesn't augment PATH like this so this
strips these from the env when running isolated tests to match behavior.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1674913457101449)
2023-01-28 19:47:13 -08:00
JJ Kasper
2701792516
Update more flakey API support checks (#45373)
x-ref: https://github.com/vercel/next.js/actions/runs/4033048662/jobs/6933337411
2023-01-28 19:24:06 +00:00
Tim Neutkens
4972f2308e
Add support for --experimental-app-only (#45352)
<!--
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 that you're making:
-->

Allows you to `next build --experimental-app-only` which excludes
`pages` altogether. Useful for quickly debugging while migrating.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-01-28 10:48:32 -08:00
Lotte
67468f98c4
Add support for tsconfig 'nodenext' | 'node16' (#44177)
## ESM: support module option for tsconfig.json 

- fixes #37525
- fixes #41961

With [TypeScript 4.7 providing ECMAScript Module Support](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js), we can now set this in our tsconfig.json file for the [module](https://www.typescriptlang.org/tsconfig#module) option.

Webpack added "extensionAlias" to solve importing ts files with .js extension -> https://github.com/webpack/enhanced-resolve/pull/351



Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-01-28 16:17:40 +00:00
JJ Kasper
bcd63af2c9
Fix fetch stack test on deploy 2023-01-27 18:23:27 -08:00
JJ Kasper
23353771d7
Fix next-server trace including dev server dependencies (#45359)
This ensures we aren't including the `dev-server` dependencies in the
`next-server` tracing.

x-ref:
https://dev.azure.com/nextjs/next.js/_build/results?buildId=46884&view=logs&jobId=14d0eb3f-bc66-5450-3353-28256327ad6c
x-ref:
https://dev.azure.com/nextjs/next.js/_build/results?buildId=46889&view=logs&jobId=14d0eb3f-bc66-5450-3353-28256327ad6c
2023-01-27 17:25:44 -08:00
JJ Kasper
1404eedf79
Update flakey app prefetch test (#45361)
x-ref:
https://github.com/vercel/next.js/actions/runs/4028868244/jobs/6926255942
2023-01-27 16:18:27 -08:00
JJ Kasper
ca134f6dce
Update flakey API support tests (#45360)
x-ref:
https://github.com/vercel/next.js/actions/runs/4027758161/jobs/6923946045
2023-01-27 16:06:38 -08:00