Commit graph

4503 commits

Author SHA1 Message Date
Balázs Orbán
3ad2035ae6
feat(cli): introduce next info CLI command (#32972)
This PR adds a new command to the `next` CLI.

Running `next info` will print useful information to the terminal about how/where Next.js is run. This information can be added to the Bug report when opening an issue in the repository.

This makes reporting issues more accurate and doesn't require the user to guess certain details, the command will retrieve it on their behalf.

Example output:

```sh
$ npx --no-install next info

    Operating System:
      Platform: linux
      Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021
    Binaries:
      Node: 16.13.0
      npm: 8.1.0
      Yarn: 1.22.17
      pnpm: 6.24.2
    Relevant packages:
      next: 12.0.8-canary.14
      react: 17.0.2
      react-dom: 17.0.2


```

The idea is based on #32858

## Bug

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

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-01-04 15:35:32 +00:00
JJ Kasper
69a56759ee
v12.0.8-canary.16 2022-01-03 18:58:27 -06:00
JJ Kasper
e01ef297e7
Ensure middleware is output in standalone mode (#32967) 2022-01-03 18:47:18 -06:00
JJ Kasper
5378db8f80
v12.0.8-canary.15 2022-01-03 15:46:09 -06:00
Devin Wall
d0e72fd9fa
Fixes issue with makeStylesheetInert (#32027)
Fixes https://github.com/vercel/next.js/issues/32024

Fixing makeStylesheetInert.
Fixes log import.



## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: Devin Wall <87490815+DevinWallKcl@users.noreply.github.com>
2022-01-03 20:35:57 +00:00
JJ Kasper
52cf7fe51e
Ensure setImmediate and punycode are polyfilled (#32768)
* Ensure setimmediate and punycode are polyfilled

* update compiled
2022-01-03 13:31:23 -06:00
Javi Velasco
82adaee0cd
Allow to opt-out from preflight cache (#32767)
Fixes #32727

With this PR we introduce a new header that can be used to respond from Middleware `x-middleware-cache`. When the value of this header is set to `no-cache`, the client will **not** store the effects read from a preflight response to be used in an upcoming check.

Instead of using `Cache-Control` we are using a custom header to not mess with browser specific caching. Accepting a specific value to opt out (`no-cache`) opens the future opportunity of having other caching strategies.

This feature solves the issue of having a preflight request whose parameters can change from the client affecting the effects. For example, having a cookie that would make a middleware rewrite to one pathname or another and allowing to change that cookie from the client. In that case we'd always need to revalidate the effects on navigation synchronously.

Of course when using this feature it is possible that we add some latency on navigation so the preferred mechanism will be caching by default since it covers the most common use cases.
2022-01-03 18:13:28 +00:00
JJ Kasper
4d307716f7
Fix issue with escape-string-regexp in IE11 (#32708)
* Fix issue with escape-string-regexp in IE11

* remove escape-string-regexp dep

* Update compiled

* Link to original repo
2022-01-03 11:41:50 -06:00
JJ Kasper
c9c3183292
Remove un-needed test dependency (#32616)
* Remove un-needed test dependency

* update test

* update compiled
2022-01-03 10:08:30 -06:00
Balázs Orbán
be1d308417
fix(router): scroll to top when href="/" and hash already present (#32954)
When the URL already contains a hash (like `/#section`) and a `Link` with `href="/"` is clicked, the page should scroll to the top on the first click. Currently, it only happens with the second click (after `#section` has been removed from the URL).

Fixes #32931

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-01-03 02:57:02 +00:00
JJ Kasper
381ca374e5
v12.0.8-canary.14 2022-01-02 16:36:23 -06:00
Tim Neutkens
88a5f263f1
Move resolve-url-loader into Next.js (#32932)
* Move resolve-url-loader into Next.js

Fixes #32157

Moves resolve-url-loader into Next.js and strips out all features that are not used like `rework` support. Will reduce install size as well as allow for optimizing the approach in the near future.

* Update precompiled

* Use loader-utils 2

* Update trace test

* Revert "Update trace test"

This reverts commit 7c09a07871cc0ab72d5fcd4151a2d8efbc1aad8f.

* Add es5-ext as it's used in trace tests

* Update join-function.js

* Update bundle5.js
2022-01-02 16:16:17 -06:00
Tim Neutkens
a5bfc1eecc
Simplify trace span id generation (#32946)
Uses a simple counter for span ids, previously these required to be randomly generated but I've changed the importer script to ensure it gets prepended `0`s to make sure it gets to 16 characters which Jaeger requires.



## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-01-02 21:22:01 +00:00
ryuurock
0bbbfa4818
Fix next/image noscript tag to only render when lazy (#32918)
Noscript is not required for Image that are loaded immediately

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-01-01 22:46:49 +00:00
Thibaut SABOT
9d1fbbca7b
ignore .d.ts files inside pages folder (#30728)
Fixes https://github.com/vercel/next.js/issues/30698 and https://github.com/vercel/next.js/discussions/30618

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
2022-01-01 17:16:03 +00:00
Tim Neutkens
e3776989bf
Remove anonymous default export rule from Babel (#32763)
We didn't port this plugin to next-swc given that the eslint setup warns for this automatically. Given that we still get issues opened for this particular warning coming from the plugin it'd be good to remove it.



## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-12-23 17:31:38 +00:00
JJ Kasper
265f71e225
v12.0.8-canary.13 2021-12-22 13:03:32 -06:00
Steven
54f0cef9c0
Bump nft to version 0.17.1 (#32737)
https://github.com/vercel/nft/releases/tag/0.17.1

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-12-22 18:44:33 +00:00
Jiachi Liu
ec3ca398cb
Reduce styled-jsx size in client bundle (#32730)
We introduced the `StyleRegistry` on server side to make it concurrent safe for requests. For client we can have only 1 registry since there's only 1 instance per browser window. Keep consistence with previous usage

Closes vercel/next.js#32417
Closes vercel/next.js#30377

Revert change in #31357, it's not required anymore
2021-12-22 13:38:27 +00:00
JJ Kasper
b6fb52bbb0
Update web runtime externals (#32717)
As mentioned in https://github.com/vercel/next.js/pull/32679#discussion_r773357113 it looks like these externals need to be updated to the compiled path not that they are ncc'd. Also updated the test readme a bit to reduce confusion in https://github.com/vercel/next.js/issues/32367#issuecomment-997969759
2021-12-22 02:34:36 +00:00
Jiachi Liu
6581ba9dae
Bust cache for RSC in each render (#32710)
* flight response should not be cached since it's could be changed per fetching
* delete cache after readRoot has constructed react tree
2021-12-21 23:37:23 +00:00
JJ Kasper
d85e5ab48e
v12.0.8-canary.12 2021-12-21 14:46:52 -06:00
Dan Weaver
13bac7c739
fix popstate detection for safari when basepath is present (#32687)
* fix popstate detection for safari when basepath is present

* Add test case

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-12-21 14:11:10 -06:00
Jiachi Liu
c5291406aa
Escape from next head in rsc _error page (#32624)
* Don't render `next/head` in _error for RSC
* Save an error in `__next_s` for client to be aware RSC rendering is errored
* Fix `req.url` when errored
* Refactor some changes in middleware ssr loader
2021-12-21 19:24:57 +00:00
David Ramos
36a6e436b3
Don't swallow test failures caused by POSIX signals (#32688)
* Don't swallow test failures caused by POSIX signals

* Update tests to not import() inside jest

* Update tests

* apply suggestion

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-12-21 12:52:07 -06:00
Kiko Beats
0eba5b2558
web runtime: add AbortController & AbortSignal (#32089)
It adds AbortController and AbortSignal Web runtimes APIs to be used by the user at Edge Functions.

For doing that it delegates into `abort-controller` dependency that has been frozen to prevent any modification.

Co-authored-by: Zhang Zhi <20026577+fytriht@users.noreply.github.com>
2021-12-21 17:12:53 +00:00
JJ Kasper
3667eba385
Pre-compile more dependencies continued (#32679) 2021-12-21 16:13:45 +01:00
Steven
738a964ead
Fix style reset on image with placeholder=blur (#32680)
This PR is a follow up to PR #32623 to fix the remaining blur styles.

These are unlikely to be overridden by the user but this PR is necessary to make `placeholder=empty` (default behavior) and `placeholder=blur` end up with the same inline styles on the loaded image.

Related to https://github.com/vercel/next.js/issues/18398#issuecomment-997114428
2021-12-20 17:49:35 +00:00
JJ Kasper
725f6b44d6
v12.0.8-canary.11 2021-12-20 09:28:17 -06:00
Jiachi Liu
b3b92b610f
Upgrade react 18 to rc, drop prerelease warning (#32619)
### Enhancement

* Auto enable reactRoot API for react 18 since the legacy render in `react-dom` is dropped
* Remove prelrease warning
2021-12-20 13:43:42 +00:00
JJ Kasper
e8408c7086
Pre-compile more dependencies (#32627)
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-12-20 14:01:35 +01:00
Balázs Orbán
6ffa2baa4d
fix(next/jest): do not watch .next folder (#32659)
`jest --watch` looks for [changes in dotfiles and folders by default](https://github.com/facebook/jest/pull/10075), which resulted in the tests being re-run when navigating between pages with `next dev`.

Fixes #32650

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-12-19 19:03:54 +00:00
Shu Ding
8b12b174e5
Fix writing strings to the writable stream writer (#32637)
Only chunks are allowed to write to writable. This fixes the following error in the web runtime:

```
Uncaught (in promise) TypeError: This TransformStream is being used as a byte stream, but received a string on its
writable side. If you wish to write a string, you'll probably want to explicitly UTF-8-encode it with TextEncoder.
```

It doesn't fail in the Node.js sandbox since we polyfilled this case (which should be reverted back later).

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-12-18 18:39:36 +00:00
JJ Kasper
3e83205eab
v12.0.8-canary.10 2021-12-17 20:24:59 -06:00
Steven
079c4be439
Fix style.filter on image with placeholder=blur (#32623)
Fixes https://github.com/vercel/next.js/issues/18398#issuecomment-995871025
2021-12-18 02:08:48 +00:00
Jiachi Liu
b58a3f0b9d
Add options to defaultGetInitialProps and upgrade styled-jsx-with-csp example (#32594)
x-ref: https://github.com/vercel/styled-jsx/issues/763

* Add 2nd arg `options` to `docCtx.defaultGetInitialProps` to make customization easier
* Upgrade styled-jsx to fit typing
* Update styled-jsx csp example
2021-12-17 23:27:56 +00:00
Jiachi Liu
bb6d4d71fd
Move fs API for inc cache to node server (#32604)
Move fs API for incremental cache to node-server, leave a small group of mock file system for base server
2021-12-17 22:56:26 +00:00
JJ Kasper
d7811d3207
v12.0.8-canary.9 2021-12-17 15:47:01 -06:00
Antoine Apollis
83b04c8983
Feat/14701 full reload notification (#28866)
## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issue: #14701
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`

<details>

<summary>Screenshot</summary>

<img width="1388" alt="Screen Shot 2021-12-17 at 2 07 04 PM" src="https://user-images.githubusercontent.com/22380829/146602057-9675455d-cf10-435a-b121-bc462a87fbf3.png">


</details>

Closes: https://github.com/vercel/next.js/issues/14701


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-12-17 21:24:13 +00:00
JJ Kasper
f61e3566bf
Ensure AMP optimizer is only excluded from trace when not used (#32577) 2021-12-17 13:57:03 -06:00
Shu Ding
346670ca6c
Fix ReadableStream.pipeTo() being unimplemented in the web runtime (#32602)
Currently we are using a TransformStream to process the forwarded stream for the inlined data, but unfortunately the `pipeTo` method is not implemented in the web runtime. This PR changes it to a naive way of doing so.

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-12-17 12:27:53 +00:00
Jared Palmer
ed022eda0f
Add turbo / improve Rust build caching in GitHub Actions (#31464)
Implements Turborepo for the Next.js repository and leverage it for native build caching.

Co-authored-by: Maia Teegarden <2865858+padmaia@users.noreply.github.com>
2021-12-16 20:10:45 +00:00
Tim Neutkens
e90f0aec7a v12.0.8-canary.8 2021-12-16 14:50:34 +01:00
Ben
04fbc663f9
Check stack property for page export exceptions (#32289)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-12-16 09:41:45 +01:00
Justin Braithwaite
db91fbf407
Prevent NEXT_PHASE env change in workers (#28941)
`process.env.NEXT_PHASE` was moved in https://github.com/vercel/next.js/pull/20900 to be set during `staticCheckSpan.traceAsyncFn`. I believe this to be a mistake, the NEXT_PHASE should be set earlier in the code execution.

On a personal note, this impacts an application I am developing where we rely on the environment variable `NEXT_PHASE` to be set but is `undefined` when we check it.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-12-16 00:17:42 -06:00
Michiel Van Gendt
d7062dddcc
Include message body in redirect responses (#31886)
# Description

The redirect responses do not contain a message body. This is in conflict with the RFCs (below) and causes Traefik (a reverse proxy) to invalidate the responses. In this pull request, I add a response body to the redirect responses. 

This PR is similar to https://github.com/vercel/next.js/pull/25257, it appears that there are some other locations where redirection is handled incorrectly in next.js.

# References
- https://datatracker.ietf.org/doc/html/rfc7230#section-3.3

> All 1xx (Informational), 204 (No Content), and 304 (Not Modified) responses must not include a message-body. All other responses do include a message-body, although the body may be of zero length.

- https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3

> The server's response payload usually contains a short hypertext note with a hyperlink to the different URI(s).

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-12-16 05:41:43 +00:00
JJ Kasper
f221f8857d
v12.0.8-canary.7 2021-12-15 13:31:38 -06:00
Tim Neutkens
048d89c63a
Ensure experimental SWC options invalidate the cache (#32540) 2021-12-15 12:54:25 -06:00
JJ Kasper
5d606ebae4
Ensure image-optimizer is traced for standalone mode (#32522)
This ensures we trace the `image-optimizer` for the standalone output mode as previously this was always ignored under the assumption image optimizing would be handled at the CDN level in standalone mode. 

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`

Fixes: https://github.com/vercel/next.js/issues/32513
2021-12-15 14:19:16 +00:00
Javi Velasco
3da1f17d5a
[middleware] Fix hydration for rewrites to dynamic pages (#32534)
Fixes #32302 

This PR fixes an issue on hydration where we rewrote using a middleware to a dynamic path. In such cases we need to run preflight to find out the middleware operation metadata.

## Bug

- [X] Related issues linked using `fixes #number`
- [X] Integration tests added
- [X] Errors have helpful link attached, see `contributing.md`
2021-12-15 13:33:13 +00:00