Commit graph

6943 commits

Author SHA1 Message Date
Grace Yun
43c9d8940d
Wrap CSS variable in var (#44153)
Adds missing CSS var() wrapper + spelling error, caught in [Discussion
#9094](https://github.com/vercel/vercel/discussions/9094).

Closes: #44126
Closes: https://github.com/vercel/next.js/pull/44127 

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

## 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)
2022-12-19 12:05:46 -08:00
Grace Yun
68d06fe015
Update README templates to include snippet on next/font (#44088)
Updates the README templates for `create-next-app` to include
information on the addition of the `next/font` library.

## 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)
2022-12-19 11:49:41 -08:00
Jason Long
4796fb3dd4
Upgrade undici to 5.14.0 to fix fetch redirect bug (#44133)
<!--
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:
-->

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

## 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)
2022-12-19 11:27:41 -08:00
Jiachi Liu
ded93bf645
should not contain pages css in app dir (#44151)
* Filter out the css chunk from `pages/`
* add indent for flight manifests in dev mode for development convenience

## 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)
2022-12-19 17:51:34 +00:00
l1qu1d
723311bde9
Revert "Remove useState from next/image (#43587)" (#44094)
# Reverts vercel/next.js#43587

PR #43587 breaks the `placeholder="blur"` property on the `<Image />`
component by keeping the `blurStyles`, e.g. the blurred image, after the
image is loaded.

**This regression does _not_ introduce any breaking changes or bugs.**

---

The reason for the original PR was:
> This PR remove `React.useState()` from the `next/image` component. It
was only used in the `onError` case and it was causing Safari to become
very slow when there were many images on the same page. We were seeing
1s delay blocking the main thread when there were about 350 images on
the same page. Chrome and Firefox were not slow.

The original PR is a performance improvement for Safari on a corner
case.

Additionally, when tackling this performance improvement again, the
`blurStyle` needs to know when the the image is done loading so it can
get rid of the blur. The state is updated in `handeLoading()` and isn't
just used `onError`.

## Fixes issues

- Fixes #43829
- Fixes #43689

## To reproduce

For reference this when #43587 was pulled into Next.js
[v13.0.6-canary.3](https://github.com/vercel/next.js/blob/v13.0.6-canary.3/packages/next/client/image.tsx)

- Regress the `image.tsx` to
[v13.0.6-canary.2](https://github.com/vercel/next.js/blob/v13.0.6-canary.2/packages/next/client/image.tsx)
- Do a local build with the regressed `image.tsx` on (current canary
build)
[v13.0.8-canary.0](https://github.com/vercel/next.js/releases/tag/v13.0.8-canary.0)
- Example code, (import any image you like) make sure to use
`placeholder="blur"`
```typescript
import Image from 'next/image'
import CatImage from '../public/cat.png'

<Image
    src={CatImage}
    width={500}
    height={500}
    alt="Cat"
    priority
    placeholder="blur"
/>
```
- Image will still have the blur after the image is loaded
- Before and after screenshot


![before](https://user-images.githubusercontent.com/1037693/208206084-bd6fa143-ca19-4fda-9f4e-8fcec9836848.png)


![after](https://user-images.githubusercontent.com/229881/208470446-3a00eac6-f82e-4017-bd9f-7c6145456959.png)

Co-authored-by: Steven <steven@ceriously.com>
2022-12-19 12:10:23 -05:00
Tim Neutkens
e45bbbe734
Add jsdoc/no-types eslint rule for TypeScript files (#44049)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-12-19 10:21:08 +01:00
JJ Kasper
b8ae447b0f
Fix dev session stopped handling (#44112)
This ensures we properly handle the dev session stopped event now that
the dev server runs in a different worker so the telemetry globals are
no longer available by default in the main process. No additional tests
have been added as the existing test caught this.

Fixes:
https://github.com/vercel/next.js/actions/runs/3715725536/jobs/6301287357
x-ref: https://github.com/vercel/next.js/pull/43958

## 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)
2022-12-17 17:18:49 -08:00
Tim Neutkens
04e325d1d2
Add lodash to server components external packages (#44022)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-17 09:06:15 +01:00
OJ Kwon
b45c81577c
refactor(next-swc): introduce next-binding to consolidate dependencies. (#43473)
<!--
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:
-->

Partial solutions for WEB-225.

One of the issue we want to improve is version bump process across
multiple dependencies sharing same transitive dependencies. There were
known cases of last-minute build failures of next-swc due to this. The
biggest thing is we have lot of dependenceis rely on swc_core, and
consolidating it altogether is tricky.

PR introduces `next-binding`, which reexports all the related
dependencies that next-swc and turbopack commonly uses. Unfortunately,
this is not a complete solution, but at least it'll make `upfront` cost
to turbopack when it try to update swc_core and others, so by the time
upgrading it in next-swc we expect minimal friction. Note not 0
friction: due to how cargo behaves for the merging all of the features,
there's still chances to have some build failures but meaningfully less
I believe.

I think the easiest way to describe before / after is having some
diagrams. This is rather simplified to illustrate problems easily, i.e
when it comes to actual build if there are same version of deps cargo
will dedupe, so below illustaration only would occur for non-compatible
version cases, etcs.

**Before**
```mermaid
graph TD
    A[next-swc] --> B(next-dev)
    A --> C(swc_core)
    A --> D(swc_emotion)
    D --> E(swc_core)
    A --> F(styled_jsx)
    F --> E
    A --> G(mdxrs)
    G --> H(swc_core)
    B --> I(swc_core)
    B --> J(swc_emotion)
    J --> K(swc_core)
```

**After**
```mermaid
graph TD
    A[next-swc] --> B(next-binding)
    B --> C[swc_core]
    B --> D[swc_emotion]
    D --> I[swc_core]
    B --> H[styled_jsx]
    B --> F[next-dev]
    B --> J[node-file-trace]
    F --> C
    H --> I
    B --> E(mdxrs)
    E --> G(swc_core)
 ```

You can see repeated dependencies (`swc_core`, `swc_emotion`) occurs lot more in next-swc in `before`, including next-swc top level direct import itself. In result, update process have to align between next-swc, turbopack, swc-plugins and others.

With newly proposed changes, `next-swc` no longer directly owns deps reduces those repetaed deps. At the moment of version bump, only `next-binding` need to be updated.

This brings small caveat however : next-swc does not directly update `swc_core`, but have to bump turbopack and its transitive dependencies. Given our bump process usually requires to bump up turbopack anyway, I wouldn't consider this as hard blocking though.
2022-12-16 11:47:56 -08:00
Jiachi Liu
137a63b90d
Fix ignoring dev warning for preload component (#44065)
Fix ignoring warning added in #41519
2022-12-16 17:47:30 +01:00
Jiachi Liu
595ecdbfdc
feat: app dir error-global component (#44066)
## Feature

NEXT-54

When there's an error in the one of the root level pages, there's no way to handle it. The team discussed this and decided there should be a global error boundary to pick up anything not handled further down in the tree. It can be called `global-error.js`.

Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2022-12-16 11:04:43 +00:00
Jan Kaifer
ab328c6c39
Add tracing for testing tools (#44046) 2022-12-16 09:58:04 +01:00
Jiachi Liu
0715af8e6a v13.0.8-canary.0 2022-12-15 20:54:35 +01:00
Shu Ding
64d3ba505a
Hash both pitch and main loader for server CSS imports (#44063)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>

This should solve the problem that CSS hash happens before PostCSS
loaders.

## 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: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-15 20:37:38 +01:00
Jiachi Liu
327634eb24
Fix windows slashes for app client entry (#44052)
Fixes #43854 , followup for #44011. Normalize the bundlePath so it works
in all cases

## 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)
2022-12-15 19:34:02 +01:00
Tim Neutkens
892eb618f7 v13.0.7 2022-12-15 12:21:57 +01:00
Tim Neutkens
6a00737533 v13.0.7-canary.7 2022-12-15 12:04:40 +01:00
Damien Simonin Feugas
35f1a3501a
feat: enables 'edge' as a possible runtime for API routes (#44045) 2022-12-15 10:08:03 +01:00
Jiachi Liu
6aae39c759
Fix app client entry key for windows (#44011)
## Bug

The app client entry key was in win32 slashes like `app\blog`, and when
we add the new layer checking logic in #43197, `name.startsWith('app/')`
doesn't work.

Fixes #43854
Fixes #43902

<img width="862" alt="image"
src="https://user-images.githubusercontent.com/4800338/207641886-08ffc159-0516-4609-9a1f-8c8693586122.png">


- [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)
2022-12-14 19:52:52 +01:00
Steven
d5fd2d75d1
Fix .images.remotePatterns[0].port warning (#44032)
The json schema was incorrectly warning because `port: ''` is valid and we document and use it in examples. The empty string is different than undefined

- empty string: match only URLs without a port
- undefined: match URLs with any port

I noticed this when running one of our examples:

```
pnpm next dev examples/image-component
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - Invalid next.config.js options detected:
  - The value at .images.remotePatterns[0].port must be 1 character or more but it was 0 characters.
See more info here: https://nextjs.org/docs/messages/invalid-next-config
```
2022-12-14 16:39:07 +00:00
Tim Neutkens
16a1116a4b
Replace taskr.watch for core compilation (#44027)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-14 16:06:53 +01:00
Janicklas Ralph
6d3be75b08
Adding data attr to inlined font definition (#44008)
Adding data attr to inlined font definition from optimizeFonts feature
2022-12-13 21:22:47 +00:00
JJ Kasper
0269f1cbda
v13.0.7-canary.6 2022-12-13 09:21:39 -08:00
Jiachi Liu
60dd6dfc9b
Fix module error for findDOMNode on edge (#43998)
## Bug

The `findDOMNode` will be exported from ReactDOM in esm mode, but it's
not defined for SSR since SSR is using react-dom server stub bundle
which doesn't contain any thing. So `import { findDOMNode } from
'react-dom'` will error in that case with bundling.

Since it's only being used on client, we import ReactDOM and call
`ReactDOM.findDOMNode` to avoid bundling error and adding a condition to
tree-shake it off on client

[slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1670608621289259)

- [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)
2022-12-13 09:16:01 -08:00
Hannes Bornö
04c2509daa
Fast refresh should recover from event handler errors in app dir (#43882)
Component state should not be lost due to a full reload after an error occurs in an event handler. Only do a full reload if an error was caught by the error overlay error boundary.

Closes NEXT-182

## 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)
2022-12-13 04:48:18 +00:00
Klein Torres
a34b20e6f2
Fix browser navigation buttons not working with shallow routing and middleware (#43919)
This PR fixes #41064.
In some particular cases, while using a middleware and shallow routing
the navigation get stucks and stop refreshing the page. After futher
investigation it seems that a line of code was added that causes the
router pathname to be incorrect and then making Next believe it's the
same page that is loading.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] 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: JJ Kasper <jj@jjsweb.site>
2022-12-12 20:02:06 -08:00
Jiachi Liu
be90c0b909
Add default head for app dir (#43963)
Add default head to app dir, when there's no`head.js`, use the default
head with the following meta tags

```html
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
```

It will be replaced if there's custom head.js in child layout.

NEXT-169
2022-12-12 19:10:42 -08:00
Ngô Đức Anh
482d78e1c2
Fix: fix pages in Route Groups returning 500 with output: "standalone" (#43746)
<!--
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:
-->

Fixes [#43367
(comment)](https://github.com/vercel/next.js/issues/43367#issuecomment-1338617317)

This fixes the issue in which pages that are in Route Groups return
status code 500 when built with `output: "standalone"` because of the
lack of required chunks in `.next/standalone/.next/server/chunks` by
handling their `.nft.json` files properly through using their
denormalized page paths, rather than their normalized ones to resolve
those files in `copyTracedFiles`.

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

## 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)
2022-12-12 19:06:40 -08:00
Steven
297459d534
Update no-img-element lint rule (#43982)
This updates the `no-img-element` lint rule to explain the trade-offs of enabling or disabling Image Optimization.
2022-12-13 01:50:59 +00:00
JJ Kasper
5e50fce03b
v13.0.7-canary.5 2022-12-12 16:12:38 -08:00
Wyatt Johnson
cba7070c08
Added support for query params on not found pages (#43836)
Previously, query parameters were not available on 404 pages because
calling the router methods would change the pathname in the browser.
This change adds support for the query to update for those pages without
updating the path to include the basePath.

This additionally narrows some Typescript types that were previous set
to `any` which highlighted some type errors that were corrected.

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

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-12-12 16:10:44 -08:00
Josh Story
f012eab00f
use a function expression to access arguments binding (#43987)
arrow function was trying to use arguments binding but wanted arguments
of the lambda not the nearest normal function. The narrowest change is
to convert to function expression. We could also use varargs rest syntax
since this runs in runtimes that should all support that I think. I
don't think it really matters though.

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
2022-12-12 14:39:12 -08:00
Jiachi Liu
8e04398343
Erase dynamic ssr:false imports on server (#43974)
Fixes #43895

There's a `is_server_components` condition introduced in #42426 but it's
always truthy so the `ssr:false` is not erased properly. Then in #42589
the flag is removed but also the optimization is removed as well. This
PR reverts the unexpected change removed in #42589 to keep the removal
for client dynamic imports on server side. Add tests to keep there's no
trace

## 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)
2022-12-12 14:32:54 -08:00
Matt Probert
3cb7adb915
Fix: status log when NEXT_TELEMETRY_DISABLED env is set (#43948)
Fixes: https://github.com/vercel/next.js/discussions/43947

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-12-12 15:23:18 -06:00
Jimmy Lai
662344c3a5
next-dev: restart dev server exceeds the memory limits (#43958)
## Context

There has been [some reports ](https://github.com/vercel/next.js/issues/42514)of OOMs-related crashes with Next 13. Whilst we're fixing the memory leaks that are causing this, some of which are caused by upstream issues, this PR makes Next.js' dev server restarts if it detects that it is gonna crash soon.

You can disable this behaviour by passing `__NEXT_DISABLE_MEMORY_WATCHER=1` to the env process.

## Details

Under the hood, we're using Node's cluster API to create a child worker that will basically watch the memory usage after every request and then kill itself if it goes over 90% of the maximum heap allowance.


## Test plan

I added manually a  leaking function that I called before handling a request. I then manually tested that the server re-started when we were near the limit.

```

function createMemoryLeak() {
  console.log('createMemoryLeak', process.memoryUsage().heapUsed / 1024 / 1024)
  for (let i = 0; i < 10; i++) {
    buffer.push(new Array(1000000).fill('a'))
  }
}

```


## 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)
2022-12-12 18:54:55 +00:00
Hannes Bornö
45eea0a57e
Open server component errors fullscreen (#43887)
https://github.com/vercel/next.js/pull/43844 continued.

Make sure Server Component errors always open in fullscreen mode. Currently they only open in fullscreen on initial load - not when adding an Error when updating the file.

If in test env, call `self.__NEXT_HMR_CB` after server component HMR was successful, used in tests for the error overlay.

Closes NEXT-202

## 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)
2022-12-12 12:27:06 +00:00
Hannes Bornö
b3dfa03767
useSearchParams - bailout to client rendering during static generation (#43603)
Currently `useSearchParams` bails out of static generation altogether, forcing the page to be dynamic. This behaviour is wrong. Instead it should still be statically generated, but `useSearchParams` should only run on the client.

This is achieved by throwing a "bailout to client rendering" error. If there's no suspense boundary the whole page will bailout to be rendered on the client. If there is a suspense boundary it will only bailout from that point.

~This PR also adds handling for `export const dynamic = 'force-static'` combined with `useSearchParams`. If it is enabled it will return an empty `ReadonlyURLSearchParams` and skip the bailout to client rendering. Since the `staticGenerationAsyncStorage` only is available on the server - `forceStatic` is sent to the `app-router` to enable sending an empty `URLSearchParams` to match the server response.~
https://github.com/vercel/next.js/pull/43603#discussion_r1042071542 the implementation was wrong, added skipped tests and todo comment for now.

## 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)
2022-12-12 11:53:38 +00:00
Steven
d2c23bb5e8
Refactor image optimization util (#43868)
This PR doesn't change any behavior, its just refactoring.

- renamed `webpack/loaders/next-image-loader.js` to `.ts`
- moved duplicate code into shared function `optimizeImage()`
  - support `height` as optional param
  - convert `extension` to `contentType`
2022-12-12 05:02:52 +00:00
Hannes Bornö
f6f1f50238
Increase stack trace limit on the server (#43800)
Increases `Error.stackTraceLimit` on the server to match the client.
Adds `if (typeof window !== 'undefined') {` in `use-error-handler`,
otherwise it also affects the server - but only after that file is
compiled.

Closes NEXT-125

 ### Before

![image](https://user-images.githubusercontent.com/25056922/206123948-0c92009a-e5e8-4519-9862-1c1b83d88168.png)

### After

![image](https://user-images.githubusercontent.com/25056922/206124053-ba792463-76d4-457c-ac3b-d3e5b95b7bf9.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)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-12-11 22:35:55 -06:00
Hannes Bornö
5cf7408bb2
Update @next/font data (#43883)
Update @next/font data

## 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)
2022-12-11 20:51:07 -06:00
Hannes Bornö
50caf8b191
Add helpful error for createContext used in Server Components (#43747)
Format runtime server errors similarly to how build errors [are
formatted](https://github.com/vercel/next.js/blob/canary/packages/next/client/dev/error-overlay/format-webpack-messages.js).
Add helpful message when createContext is used in Server Components.

## 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)
2022-12-11 20:46:29 -06:00
Shu Ding
6cfebfb02c
Skip creating VSCode config and .gitignore if running in CI (#43935)
NEXT-233

## 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)
2022-12-11 00:08:07 +00:00
Shu Ding
1fb4cad2a8
Add auto completion for prop names and types to the TS plugin (#43909)
For example, [named
slots](https://nextjs.org/blog/layouts-rfc#convention:~:text=After%20this%20change%2C%20the%20layout%20will%20receive%20a%20prop%20called%C2%A0customProp%C2%A0instead%20of%C2%A0children.)
should be hinted when typing:

```ts
export default function Layout({ f|
                                  ^foo
```

And the prop type:

```ts
export default function Layout({ foo }: { f|
                                           ^foo: React.ReactChildren
```

And
[params](https://beta.nextjs.org/docs/api-reference/file-conventions/page#params-optional):

```ts
export default function Page({ p|
```

NEXT-178

## 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>
2022-12-10 20:07:56 +01:00
Jiachi Liu
3833aed08d
Fix next/dynamic types for resolving named export module (#43923)
## Bug

Fixes: #43915

- [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)
2022-12-10 17:35:13 +00:00
Shu Ding
8ded79728e
Support for named slots in type checking (#43906)
Follow up to #43903, this PR adds named slots to the generated typings,
and provides better error messages for `next build`.

For example, a layout can have `test` as a prop because it has `@test`
co-located. But `invalid` is not a possible prop here:

![CleanShot 2022-12-09 at 21 24
21@2x](https://user-images.githubusercontent.com/3676859/206790150-0e2d7905-fad8-4b26-86ee-d5e69a5ad0f9.png)

And here's the error when running `next build`:

<img width="651" alt="CleanShot 2022-12-09 at 21 21 11@2x"
src="https://user-images.githubusercontent.com/3676859/206789969-8bbd75bd-e7e3-4109-9e0d-d5f8f9a4bbb5.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)
2022-12-09 23:29:57 +01:00
Shu Ding
582070eb7b
Improve type checking error message for invalid props (#43903)
Previously when you have wrong props for a page or layout:

<img width="639" alt="CleanShot 2022-12-09 at 20 27 25@2x"
src="https://user-images.githubusercontent.com/3676859/206782176-a91ec178-a7b7-4e17-b990-a0fe90402ebf.png">

With this PR:

<img width="643" alt="CleanShot 2022-12-09 at 20 27 30@2x"
src="https://user-images.githubusercontent.com/3676859/206782204-4623c830-86e9-4b95-abc9-b0819475a74b.png">

Next step is to generate prop types for named slots.

## 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>
2022-12-09 21:15:57 +01:00
Jiachi Liu
d8545e6273
fix: forwarding props to no ssr dynamic (#43901)
## Bug

Fixes: #43764

- [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)
2022-12-09 19:00:28 +00:00
Shu Ding
5415a0d954
Fix error message for invalid runtime option in app dir (#43900)
Currently it shows `Provided runtime "undefined" is not supported`.

## 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)
2022-12-09 18:35:27 +00:00
JJ Kasper
9d97a1e34a
v13.0.7-canary.4 2022-12-09 09:04:30 -06:00
Jiachi Liu
a7f29108f4
Alias next/head to noop for rsc and add upgration warning (#43885)
This will reduce the bundle size and also give user proper hint to upgrade to `head.js`

* Mark `next/head` as noop in app dir
* Add warning for users to check the upgration guide to migrate it to head.js
2022-12-09 14:45:31 +00:00