Commit graph

4700 commits

Author SHA1 Message Date
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
Shu Ding
e75361fd03
Fix server data cache key (#32506)
Currently we are using `location.href` which doesn't align with the other flight request's cache key (`pathname + search`). This fix unifies 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-14 19:52:37 +00:00
Tim Neutkens
12bb1b1da2 v12.0.8-canary.6 2021-12-14 18:05:17 +01:00
JJ Kasper
2a5c21b65c
Update to filter loader specific files from traces (#32267)
* Update to filter loader specific files from traces

* remove debug log
2021-12-14 10:41:10 -06:00
Tobias Koppers
f7153b13e9
upgrade webpack and watchpack (#32173)
Co-authored-by: sokra <sokra@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-12-14 11:48:49 +01:00
Tobias Koppers
ee220730db
fixes to allow lazy compilation for import() (#32441) 2021-12-14 11:33:04 +01:00
Jiachi Liu
67545bd654
Add vitals and rsc to npm files (#32472) 2021-12-14 11:30:14 +01:00
Shu Ding
8f9aed687a
Fixes for inline embedding data in the web runtime (#32471)
* fix missing renderToString

* workaround tee

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-12-14 00:48:36 +01:00
Oriol Collell
eba9da09eb
Fixes #32338 missing Document components trigger an error for production builds (#32345)
* Only validate _document subcomponents in dev environment

* Replace error by a warning

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-12-13 16:47:34 -06:00
Jiachi Liu
10d814d31a
Fix dynamic routes with pages under index folder (#32440)
Fixes incorrect generated manifest and generated directory for `index/[...dynamic]` pages

Too much normalizing adding extra `index/` prefix to `index/[...dynamic]` routes which lead to the incorrected generated routes like `.next/server/pages/index/index/index/[...dynamic]`

## Bug

Fixes https://github.com/vercel/customer-issues/issues/146

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-12-13 20:36:31 +00:00
JJ Kasper
48cee5485a
v12.0.8-canary.5 2021-12-13 13:07:44 -06:00
Javi Velasco
59f7676966
Fix running server with Polyfilled fetch (#32368)
**Note**: This PR is applying again changes landed #31935 that were reverted from an investigation.

This PR fixes #30398

By default Next will polyfill some fetch APIs (Request, Response, Header and fetch) only if fetch is not found in the global scope in certain entry points. If we have a custom server which is adding a global fetch (and only fetch) at the very top then the rest of APIs will not be polyfilled.

This PR adds a test on the custom server where we can add a custom polyfill for fetch with an env variable. This reproduces the issue since next-server.js will be required without having a polyfill for Response which makes it fail on requiring NextResponse. Then we remove the code that checks for subrequests to happen within the **sandbox** so that we don't need to polyfill `next-server` anymore.

The we also introduce an improvement on how we handle relative requests. Since #31858 introduced a `port` and `hostname` options for the server, we can always pass absolute URLs to the Middleware so we can always use the original `nextUrl` to pass it to fetch. This brings a lot of simplification for `NextURL` since we don't have to consider relative URLs no more.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2021-12-13 18:30:24 +00:00
Shu Ding
438ee9618f
Inline server data response with partial hydration (#32330)
This PR implements the basic inline embedded server response data (#30994) for RSC, as well as partial hydration (#31338) for RSC and React 18 SSR streaming.

For #30994, `renderTargetSuffix` is passed to the `bodyResult` resolver so the stream can inject corresponding hydration scripts and the closing body tag at the correct time. The expected behavior should be _prefix_, _body shell_, _suffix scripts_, _stream and inlined data_, _close body_.

For #31338, we have to force turn on `disableOptimizedLoading` when `concurrentFeatures` is enabled to opt-out of deferred script tags.

## Bug

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-12-13 10:48:18 +00:00
Jiachi Liu
59a4432318
Rename experimental vital hook (#32343)
* Rename vital hook

* update taskfile

* disable hook rule for unstable prefix

* rename at exports

* fix typing

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-12-12 21:14:12 +01:00
JJ Kasper
83e661031c
v12.0.8-canary.4 2021-12-10 10:08:40 -06:00
Jiachi Liu
c21806e54f
fix unstable_useRefreshRoot typing (#32364)
align with re-exports in entry file
2021-12-10 12:45:55 +00:00
Jiachi Liu
6f8cf675d3
Add unstable_useRefreshRoot (#32342)
## Feature

Resolves #32332

- [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`
- [ ] 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`
2021-12-10 10:22:31 +00:00
Pieter Bogaerts
0b1c9ec47d
Compile escape-string-regexp (#32310)
* Update index.js

* Update taskfile.js

* Revert "Update index.js"

This reverts commit 8106c076f92e961cdaeb0431812f676ea219b1ee.

* update compiled

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-12-09 13:31:53 -06:00
Jiachi Liu
b044f42334
Fix RSC link navigation (#32303)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-12-09 14:45:22 +01:00
JJ Kasper
7e055dddbb
v12.0.8-canary.3 2021-12-08 18:01:57 -06:00
JJ Kasper
5011937aff
chore(deps): upgrade browserslist (#32300)
* chore(deps): upgrade `browserlist`

* update compiled

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-12-08 17:51:35 -06:00
Steven
0b86bfa590
Revert "Replace raw-body with get-stream and bytes" (#32305)
Reverts vercel/next.js#21915 since it cannot handle max buffer size.

See https://github.com/sindresorhus/get-stream/issues/42
2021-12-08 22:28:17 +00:00
Gerald Monaco
aa32deb467
Simplify custom Writable (#32247)
* Simplify custom writable

* Fix draining
2021-12-08 12:03:07 -06:00
JJ Kasper
345956f1d2
v12.0.8-canary.2 2021-12-08 10:58:41 -06:00
JJ Kasper
8fb5ef18e7
Update to latest ncc and ensure caniuse-lite data is external (#32064)
* Ensure caniuse-lite data is external for nccing

* lint

* ensure assetBuilds config is set

* update compiled
2021-12-08 10:41:35 -06:00
Bogdan Chadkin
6687b09011
Replace raw-body with get-stream and bytes (#21915)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-12-08 11:34:31 +01:00
JJ Kasper
1a6a1e5fdf
Add docs for leveraging outputStandalone config (#32255)
This adds documentation to explain how the `outputStandalone` config can be leveraged to reduce production deployment size and leverage the output file traces.  This also adds a note for the `outputFileTracingRoot` config as it may be needed in some monorepo setups. 

A follow-up PR will update our Docker example to leverage this config as well. 

## Documentation / Examples

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

x-ref: https://github.com/vercel/next.js/pull/31003
x-ref: https://github.com/vercel/next.js/issues/32252
Closes: https://github.com/vercel/next.js/issues/30822
2021-12-07 23:22:21 +00:00
Axel Mohamed SADAT
d459b5f99a
fix(NODE_ENV): Warn when launching start or build on development (#14033)
The PR aims to fix [#14022](https://github.com/vercel/next.js/issues/14022)

Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2021-12-07 14:25:39 +00:00
Maia Teegarden
21f8c6a7c3
Chore/load bindings improvements (#32191)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-12-07 11:14:38 +01:00
JJ Kasper
2e530ee299
v12.0.8-canary.1 2021-12-06 20:49:13 -06:00
Keen Yee Liau
53e52fefc3
telemetry: collect feature usage for linting during build (#32022)
Currently, we have telemetry to measure how ESLint is invoked,
but we do not have telemetry that tells us how many users have
disabled ESLint during build.

This commit adds a new feature, `build lint` to track this metric.



## Bug

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

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-12-07 02:41:31 +00:00
Shu Ding
db773c4aca
Refactor FS references in the Base Server (#32179)
* move fs

* fix failing tests; remove unused imports
2021-12-07 02:14:55 +01:00
Gerald Monaco
9bcf678e64
Revert support for render prop in <Main /> (#32184)
Reverts support for render prop in `<Main />` in `Document`. This was added just to support the `useFlushEffect` hook, but we've tweaked the design a bit, moving it to `App`.
2021-12-06 21:22:05 +00:00
Shu Ding
c004322d13
Create Base Server (#32154)
Same as #32105 (closed due to conflicts):

> Explained in #32066, rename next-server as base-server and extend NextNodeServer on top of it.
>
> Note that this is just an initial PR so no method is ported.

## 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-05 21:53:11 +00:00
Tim Neutkens
0f0c28a45f v12.0.8-canary.0 2021-12-05 15:44:48 +01:00
JJ Kasper
ebf509539c
v12.0.7 2021-12-04 18:21:43 -06:00
JJ Kasper
1e21c7df13
v12.0.7-canary.0 2021-12-04 17:03:15 -06:00
JJ Kasper
769d68047b
Ensure conf type for createServer is not changed (#32134)
This reverts the type for the `conf` field in `ServerOptions` isn't changed to require all `NextConfig` values as this is a breaking change from what was previously required. We should investigate making sure this field is normalized when it is provided via a user. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/32123
x-ref: https://github.com/vercel/next.js/pull/31858
2021-12-04 22:57:54 +00:00
Tim Neutkens
c1a1aa4ae2
Add test for TailwindCSS JIT mode reloading (#32130)
Test for https://github.com/tailwindlabs/tailwindcss/discussions/6265 

Issue started with https://github.com/vercel/next.js/pull/31798



## 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-04 21:59:32 +00:00
Tim Neutkens
56c68dba51 v12.0.6 2021-12-04 13:12:21 +01:00
Tim Neutkens
e257dbfad5 v12.0.6-canary.0 2021-12-04 11:26:57 +01:00
Tim Neutkens
980e16998c
Fix document type import path (#32117)
There was a mistake in #32077 which imported a different module than _document in the _document .d.ts file. I found that we didn't have a test for a custom _document.tsx and _app.tsx with TypeScript, so I've added one that fails on canary and passes with this fix to ensure this does not happen in the future.

Fixes #32110




## 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-04 10:23:15 +00:00
JJ Kasper
b6162bb6b6
v12.0.5 2021-12-03 16:45:00 -06:00
JJ Kasper
1705020808
v12.0.5-canary.19 2021-12-03 15:32:42 -06:00
JJ Kasper
f0fd4962e9
Revert "Fix running server with Polyfilled fetch (#31935)" (#32100)
This reverts commit 1c199a5e4a.
2021-12-03 15:31:52 -06:00
JJ Kasper
b194664d8d
v12.0.5-canary.18 2021-12-03 13:25:35 -06:00
Tim Neutkens
bc429f50c2
Remove future.strictPostcssConfiguration config (#32098) 2021-12-03 13:25:05 -06:00
Tim Neutkens
e58e7b17aa v12.0.5-canary.17 2021-12-03 19:22:03 +01:00
JJ Kasper
6d98b4fb43
Ensure invalid URLs respond with 400 correctly (#32092)
This ensures we catch any errors in `handleRequest` so that we can respond with a 400 for invalid requests. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/32075
Closes: https://github.com/vercel/next.js/pull/32080
2021-12-03 17:31:09 +00:00
Javi Velasco
1c199a5e4a
Fix running server with Polyfilled fetch (#31935)
This PR fixes #30398

By default Next will polyfill some fetch APIs (Request, Response, Header and fetch) only if fetch is not found in the global scope in certain entry points. If we have a custom server which is adding a global fetch (and only fetch) at the very top then the rest of APIs will not be polyfilled.

This PR adds a test on the custom server where we can add a custom polyfill for fetch with an env variable. This reproduces the issue since next-server.js will be required without having a polyfill for Response which makes it fail on requiring NextResponse. Then we remove the code that checks for subrequests to happen within the **sandbox** so that we don't need to polyfill `next-server` anymore.

The we also introduce an improvement on how we handle relative requests. Since #31858 introduced a `port` and `hostname` options for the server, we can always pass absolute URLs to the Middleware so we can always use the original `nextUrl` to pass it to fetch. This brings a lot of simplification for `NextURL` since we don't have to consider relative URLs no more.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2021-12-03 16:35:28 +00:00
Tim Neutkens
41f87abdf7 v12.0.5-canary.16 2021-12-03 12:30:59 +01:00
Tim Neutkens
c1f6abbe54 v12.0.5-canary.15 2021-12-03 12:30:14 +01:00
Luis Alvarez D
647c06b339
Improve exported root definitions (#32077)
Fixes https://github.com/vercel/next.js/issues/32045

doing `export { default } from 'module'` has some unexpected results for autocompletion in TypeScript, this PR changes root definitions to have a named default export where needed.

## Bug

- [x] Related issues linked using `fixes #number`
2021-12-03 07:16:29 +00:00
Lucas Wiener
80ec93d1bb
Skip warnings for Image not rendered to the dom (#32049)
Some libraries, like react-slick, render their content to a detached element before attaching it to the dom. If the content of such libraries is Image components, they will report warnings because the display/position properties are undefined. This PR squelch the warnings for such cases.
2021-12-03 06:40:45 +00:00
Tobias Koppers
eb65ed37b0
avoid retaining webpack config too long (#32053)
avoids keeping the webpack compiler during after webpack build build steps like SSG etc.

(review with ignore whitespace)

## 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-03 00:47:16 +00:00
JJ Kasper
5763a33a03
v12.0.5-canary.14 2021-12-02 14:55:53 -06:00
JJ Kasper
abe53727b0
Include page for export errors for easier debugging (#32013)
This makes sure to include the `page` for dynamic routes when they encounter an error during prerendering as we currently only include the `path`, e.g. before we would only show `/blog/first` and now we show `/blog/[slug]: /blog/first` 

## 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-02 19:31:36 +00:00
JJ Kasper
cc9e1ea3a1
Fix middleware types with skipLibCheck: false (#32025)
This ensures type checking passes correctly for middleware types when `skipLibCheck: false` is set in `tsconfig.json`. This also moves the `middleware-types` to be an isolated test to ensure it isn't relying on any monorepo dependencies. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/31992#issuecomment-984174872
2021-12-02 18:49:49 +00:00
Tobias Koppers
494e37c026
add experimental.swcFileReading flag to disable file reading in swc (#31995)
automatically disable swc file reading when wasm builds are used and for virtual or yarn cache paths



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


Co-authored-by: Maia Teegarden <2865858+padmaia@users.noreply.github.com>
2021-12-02 04:16:15 +00:00
Eric Matthys
f225179378
fix(Link): Do not ignore onMouseEnter prop with absolute href (#32012)
Fixes #22733

Regardless of whether it's recommended that Link be used with external href values or not, they can be used and `onMouseEnter` being swallowed with an external href value is unexpected behavior.

## Bug

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

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2021-12-01 18:32:27 +00:00
C. T. Lin
332cd06c7d
Allow pre-release React 18 as peer (#31991) 2021-12-01 17:30:22 +01:00
JJ Kasper
32ac918672
v12.0.5-canary.13 2021-12-01 10:07:32 -06:00
Jiachi Liu
928c77958e
Resolve streaming data for flight requests (#32010)
## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-12-01 15:48:31 +00:00
Shu Ding
b7fb315cd7
Ensure that external modules are not bundled into the client for RSC (#31968)
If importing an external module inside a Server Component (`.server.js`), it shouldn't be bundled into the client. Only client components should be kept.

## Bug

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

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-11-30 22:54:47 +00:00
Jeff
a2fa637ab3
fix(types): add missing ua types for NextRequest (#31901)
* fix(types): add missing ua type for NextRequest

add missing ua string type on NextRequest["ua"], returns full agent as string

* Update UserAgent type

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-11-30 15:59:02 -06:00
Steven
b01a6ba665
Add TS types for NextMiddleware (#30578)
This allows TypeScript users to have type safety for middleware functions.

- Closes #30490 

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-11-30 20:43:40 +00:00
JJ Kasper
4410de9ff3
v12.0.5-canary.12 2021-11-30 13:33:32 -06:00
Tim Koopman
8784682a74
Escape string when converting to regexp (#31791)
fixes #31411

## Bug

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-11-30 19:15:13 +00:00
Jiachi Liu
d2cef24d5d
Fix image related link prop warning with react 18 beta (#31895)
## Bug

Fixes #31892 

react 18: requires camelcase for those props 
```
Warning: Invalid DOM property `imagesrcset`. Did you mean `imageSrcSet`
```
react 17: requires lowercase for those props

```
Warning: React does not recognize the `imageSrcSet` prop on a DOM element.
```

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


### Utils

* Add command `yarn next-react-18 test/integration/any-react-18-app/`
* Add util `withReact18`

```js
const withReact18 = require('../../react-18/test/with-react-18')

module.exports = withReact18({
  experimental: {
    concurrentFeatures: true,
  },
})
```
2021-11-30 18:37:22 +00:00
Gerald Monaco
2b5d62dcad
Stop using environment variables in pages/_document (#31946)
Since #31939 is going to move the `Document` components, we can't rely on `DefinePlugin` to provide environment variables. This PR passes them as render opts instead. We can't just force this to be bundled like e.g. `next/dynamic`, because we use it internally.
2021-11-30 17:14:28 +00:00
Jiachi Liu
85e578a906
Enable default functional document when concurrentFeatures is enabled (#31954)
## Bug

Fixes: #31675 

Functional document without gIP should be enabled when streaming is enabled, even without rsc

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-11-30 12:52:14 +00:00
Jiachi Liu
c78930111d
Removng prop writable checking in prod (#31929)
x-ref: #28498, #31784

I can repro the issue #24783 with `next-boost` 0.10.1 and it was fixed in 0.10.2 (ref: eba6d10aab). The actual case is missing setting node env to `"production"`.

React freeze element props and element itself in dev mode (ref: a724a3b578/packages/react/src/ReactElement.js (L194-L196))

Then next.js will reassign props with react development bundle while next-boost is enabled. Those operations are only happened in non-dev mode so it's good to remove now.

This PR + #31898 == revert #31784

cc @styfle @awareness481
2021-11-30 00:56:02 +00:00
Maia Teegarden
0ef87397da
Account for platform/arch not supported by napi (#31938) 2021-11-29 18:05:35 -06:00
JJ Kasper
3b089ae18f
v12.0.5-canary.11 2021-11-29 16:18:39 -06:00
Michel Krämer
c8457e3abf
Fix disabling of built-in CSS support if there is a custom loader (#31078)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Lee Robinson <me@leerob.io>
2021-11-29 15:19:39 +01:00
Steven
b1be180d7d
Fix: Cannot assign to read only property 'children' (#31784)
- Closes #28498 

Co-authored-by: Jesse Jafa <12380586+awareness481@users.noreply.github.com>
2021-11-28 21:19:57 +00:00
Javi Velasco
85cc454023
Add port and hostname options to Next Server (#31858)
A middleware can work as a proxy intercepting requests and then performing a `fetch` to the destination adding headers to the request / response as a "man in the middle". When using `fetch` from a middleware we are not in the context of a browser so we can't really use relative URLs, they must be always absolute.

Now consider the previous case when middleware is running in *server mode*. Typically in order to know the host where we are fetching we can use the `request.nextUrl` which is given to the middleware but in this case the invoker (which is next-server) has no context of the hostname, nor the port. To solve this use case we must make the invoker of the middleware aware of the origin hostname and port.

This PR: 

- Introduces `hostname` and `port` as options for `NextServer`.
- Refactors types in `NextServer` and `NextDevServer` moving type only imports to the top of the file.
- Refactors `startServer` to do a best guess on the `hostname` and `port`, passing them down.
- Exposes `.port` and `.hostname` to be retrieved from the `app`.

In an upcoming PR we will pass the host guess to the middleware to solve the relative URL issue.
2021-11-28 16:48:43 +00:00
Jiachi Liu
cf64e9130e
fix: rsc headers (#31854)
`headers` type should align with `NodeHeaders`
2021-11-26 18:04:36 +00:00
Maia Teegarden
112ca407c0
Do not load external binding if local was found (#31853) 2021-11-26 17:39:05 +01:00
Shu Ding
d577edd206
Fix auto export condition in edge SSR (#31845)
`isAutoExport` should be `false` when `concurrentFeatures` is enabled.

## 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-11-26 15:53:38 +00:00
Juny
4c05de3c7e
fix amp validator message format (#31018)
## Bug

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

fixes https://github.com/vercel/next.js/issues/31012

I referred to the previous code.

```
    if (errors == null) {
      if (Object.keys(amp).length > 0) {
        warnings = (warnings || []).concat(formatAmpMessages(amp) || [])
        if (!warnings.length) warnings = null
      }
    }
```

https://github.com/vercel/next.js/pull/29753/files
2021-11-26 15:13:09 +00:00
Tim Neutkens
e9e8e8b423
Move require.resolve into the module scope (#31799)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-26 15:30:32 +01:00
Luis Alvarez D
77150dac79
Include submodules in exported type definition (#28316) 2021-11-26 14:46:56 +01:00
Heyang Zhou
809d0155ff
Add support for removing React properties. (#31606) 2021-11-26 14:45:03 +01:00
Javi Velasco
2e5218c778
Fix hydration middleware effects (#31800)
Whenever we trigger a route change in the client we check if there route we are navigating to is affected by a middleware. When this is the case we run a preflight and in case there is an effect that tells us that the middleware is responding with content we force a _refresh_. This is fine for navigation in general but it is not ok when the change is triggered for hydration. For example, in cases where the rendered page is a dynamic page this triggers an infinite reload.

In this PR we add a test where we add a `_middleware` that proxies to a dynamic path. When making a request to `/interface/root-subrequest` there will be a middleware that simply performs a fetch against localhost for the same `/interface/root-subrequest`. The new request will skip the middleware to avoid loops and then render the dynamic page. Then client will force a change for hydration resulting in a preflight request that tells that the client must refresh because for that path there is a middleware writing content.

Then we add a fix which simply consist of checking the internal option that tells when a change is triggered for hydration and skip the preflight in such scenario.

## Bug

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

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-11-26 12:46:57 +00:00
Javi Velasco
e52bee37af
Refactor sandbox module cache (#31822)
To run middleware we are using a **sandbox** that emulates the web runtime and keeps a module cache. This cache is shared for all of the modules that we run using the sandbox while there are some module-level APIs that must be scoped depending on the module we are running.

One example of this is `fetch` where we want to always inject a special header that indicate the module that is performing the fetch and use it to avoid getting into infinite loops for middleware. For those cases the cached implementation will be the first one that instantiates the module and therefore we can actually get into infinite loops. This is the reason why #31800 is failing.

With this PR we refactor the sandbox so that the module cache is scoped per module name. This means that one execution of a middleware will preserve its cache only for that module so that each execution will still have its own `fetch` implementation, fixing this issue. Also, with this refactor the code is more clear and we also provide an option to avoid using the cache.

## 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-11-26 12:06:41 +00:00
Tim Neutkens
b2acdbb788 v12.0.5-canary.10 2021-11-25 20:45:30 +01:00
Javi Velasco
f536376f03
Ensure middleware order is preserved (#31801)
The order in which middleware must be invoked conditions its behaviour. Currently, this is not being taken into consideration for server since we are generating the array of middleware based on an arbitrary order of the middleware existing in the filesystem. This PR ships a change to generate the array of middleware preserving the order defined in the manifest.

## 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-11-25 19:13:27 +00:00
Tobias Koppers
db099c5668
update webpack (#31798)
https://github.com/webpack/webpack/releases/tag/v5.64.4
2021-11-25 18:31:25 +00:00
Tim Neutkens
92b397f2b7
Lazy-load postcss (#31762)
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2021-11-25 18:41:20 +01:00
Tobias Koppers
a4159321b2
read file in swc when no loaders follow the next-swc-loader (#31682)
Fixes #31685


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


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2021-11-25 14:00:14 +00:00
Javi Velasco
d1a1a4c0f7
Improve and refactor some types (#31704) 2021-11-25 10:46:00 +01:00
Tobias Koppers
03ecbcf182
Remove some watcher hacks and update version (#31768)
## 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-11-25 08:31:20 +00:00
Maia Teegarden
1bc9b1ac02
Fix wasm loading (#31772)
* Fix wasm loading

* Remove consoles
2021-11-24 15:33:34 -08:00
Tobias Koppers
719fe5291c
update webpack (#31759)
https://github.com/webpack/webpack/releases/tag/v5.64.2
https://github.com/webpack/webpack/releases/tag/v5.64.3
2021-11-24 15:22:24 +00:00
Tim Neutkens
ff816d4bb0
Remove noop import (#31722) 2021-11-24 15:40:58 +01:00
Tim Neutkens
a4cd48e51a
Lazily init getStaticPathsWorker (#31760) 2021-11-24 13:40:08 +01:00
Tim Neutkens
e95c9caca3 v12.0.5-canary.9 2021-11-23 18:51:52 +01:00
Tim Neutkens
fccaa8e27f
Fix initial compile timing incorrect measurment (#31733)
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-23 18:47:36 +01:00
JJ Kasper
4b538e9879
Add error link when hydration error occurs (#31519)
This adds an error document/link for hydration errors to help users debug these easier. While looking at adding this also noticed a typo in the dev-overlay which is fixed. 

<details>

<summary>screenshot</summary>

<img width="1109" alt="Screen Shot 2021-11-16 at 15 56 29" src="https://user-images.githubusercontent.com/22380829/142078200-6c036ed9-ca7f-4d26-ae07-eb9bd89e991a.png">

</details>

## Documentation / Examples

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


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2021-11-23 13:10:56 +00:00
Tim Neutkens
f584722fcb
Remove trace_target env var in favor of .next/trace (#31697) 2021-11-22 20:58:49 +01:00
Jiachi Liu
7f58a2e49f
Add cookies and headers for request using in RSC (#31623)
* Passdown the request with richer information
* test: access request header as prop from gSSP
2021-11-22 18:53:22 +00:00
Dominik Ferber
feabd54f6b
avoid mutating response.cookie options (#31679)
Previously `response.cookie(name, value, options)` would mutate the passed in `options` which lead to unexpected behaviour as described in #31666.

This PR clones the `options` argument before mutating it.

## 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.
- [x] 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

- [x] Make sure the linting passes by running `yarn lint`
2021-11-22 11:20:01 +00:00
Tim Neutkens
21cb8a1fe8 v12.0.5-canary.8 2021-11-21 15:51:15 +01:00
JJ Kasper
9d699cb11a
Fix dev router usage before router initializing (#31632) 2021-11-21 15:42:19 +01:00
Tim Neutkens
ba89d204e8 v12.0.5-canary.7 2021-11-21 13:07:17 +01:00
Maia Teegarden
a79d4fc366
Extract next-swc Rust code into its own package (#31635)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-21 12:59:56 +01:00
Tim Neutkens
ad6ef01edc v12.0.5-canary.6 2021-11-20 20:27:02 +01:00
Donny/강동윤
3146ed37f8
Update swc (#31639)
The purpose of this PR is to apply

 - https://github.com/swc-project/swc/pull/2779
   - Fixes #31291.
   - Not sure if it's fully fixed, but fixes some bugs related to #31391 

 - https://github.com/swc-project/swc/pull/2818
   - Fixes #31627


I'll undraft this PR once https://github.com/swc-project/swc/pull/2818 is fixed.
2021-11-20 19:25:52 +00:00
Kiko Beats
f52211bad3
fix(middleware): consider localhost variations (#31603)
Since `localhost` is actually an alias for `127.0.0.1` that points to loopback, we should take that into consideration at `NextURL` when we handle local URLs.

The implementation is based on [is-localhost-url](https://github.com/Kikobeats/is-localhost-url); I added some tests over local URLs variations present at the library to ensure other variations are working fine.

Additionally, I refactor some things over the code to avoid doing the same twice and added some legibility that is always welcome when you are working with URLs stuff.

 closes https://github.com/vercel/next.js/issues/31533
2021-11-19 21:24:22 +00:00
JJ Kasper
9652bdd653
v12.0.5-canary.5 2021-11-19 14:44:42 -06:00
Mateusz Burzyński
9ba31bbd77
Remove outdated comment about string children being deprecated in next/link (#30606)
* Bring back accidentally lost deprecation warning for using string as a children for `next/link`

* Wrap warning with the env check

* Remove warning, just go with removed comment about deprecation
2021-11-19 13:58:33 -06:00
JJ Kasper
e8ca334d42
Fix non-concurrent function _document (#31628)
This ensures functional `_document` is rendered correctly when not using concurrent mode. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/31593
x-ref: https://github.com/vercel/next.js/pull/30156
2021-11-19 19:41:19 +00:00
Jiachi Liu
dab7b40618
Add types for geo lat and long (#31624)
Fixes #31620

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-11-19 17:09:52 +00:00
Gerald Monaco
ab712ef310
Move root div to an app wrapper (#31596)
Extracted from #31223.

We need to move the root `<div id="__next">` wrapper to be rendered as part of the page content, rather than the`Document`, so that flush effects (like styles) are flushed before (or after) the div, rather than inside, where they would cause hydration mismatches.
2021-11-19 08:16:05 +00:00
Hannes Bornö
1d2ac3b225
Implement SWC port of next-page-disallow-re-export-all-exports (#31582)
Fixes #30810

Added tests similar to the fixture ones, but the output is stderr. That way the test can make sure the error message and span is correct. Let me know if you think this is a bad idea.
2021-11-19 00:11:25 +00:00
jj@jjsweb.site
a363a4ff6c
v12.0.5-canary.4 2021-11-18 16:30:23 -06:00
JJ Kasper
1d9007307f
Fix accessing router before ready for HMR ping (#31588)
* Fix accessing router before ready for HMR ping

* update test name

* lint-fix
2021-11-18 16:23:21 -06:00
Gerald Monaco
9f7c774665
Minor simplifications to renderToWebStream (#31553)
Simplifies `renderToWebStream` a little bit for #31223
2021-11-18 19:46:15 +00:00
Javi Velasco
5a3d558c9f
Fix HMR for middleware #30791 (#31548)
Fixes #30791

The issue is that with Middleware we are introducing client compilation on a new layer. When a middleware changes (or is dropped after some time), Webpack reorganizes non-user modules as they are duplicated across different layer. This is currently triggering a full reload.

This also brings tests for HMR:
- Refresh on a Middleware change
- HMR works after a middleware compilation change.

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2021-11-18 18:23:52 +00:00
jj@jjsweb.site
01cf08e288
v12.0.5-canary.3 2021-11-18 09:25:26 -06:00
jj@jjsweb.site
2a5e605ab3
v12.0.5-canary.2 2021-11-17 20:33:04 -06:00
JJ Kasper
be2e863dde
Re-add native package folders and ensure wasm artifacts are downloaded (#31561)
* Re-add native package folders and update publish-native

* update jobs

* ensure wasm-binaries are downloaded

* only build-wasm on release
2021-11-17 20:23:02 -06:00
jj@jjsweb.site
eaf6e27deb
v12.0.5-canary.1 2021-11-17 17:15:04 -06:00
JJ Kasper
36d3198e39
Fix unhandled rejection on route change in dev (#31554)
This ensures we properly catch the rejection on route change failure in development so the dev overlay doesn't flash with the unhandled rejection. A test case isn't able to be added for this specific scenario as the unhandled rejection is fired right before the page is navigated so we can't consistently check if the rejection was unhandled or not. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/28560
2021-11-17 21:33:56 +00:00
Steven
44b4dbcd41
Adjust AVIF size so that its smaller than WebP size (#31494)
Generally, AVIF quality can be lower compared to WebP so we can adjust this for the user so that it looks roughly the same depending on if the browser supports AVIF or WebP.

- Fixes #31254 
- Related to https://github.com/lovell/sharp/issues/2850
2021-11-17 20:31:16 +00:00
Gerald Monaco
0cf7061859
Make missing Document components an error (#31505)
* Make missing document components an error

* Fix broken tests
2021-11-17 13:34:16 -06:00
Keen Yee Liau
9ab1709175
telemetry: track usage of 'optimizeFonts' (#31522)
`optimizeFonts` is enabled by default, but the Aurora team would like
to find out how many users explicitly turn it off.
2021-11-17 13:33:37 -06:00
Maia Teegarden
b80c378975
Add/wasm build (#31470) 2021-11-17 20:01:02 +01:00
Donny/강동윤
2df861ac12
Update swc (#31540)
This PR applies
 - https://github.com/swc-project/swc/pull/2784

Closes #31479
2021-11-17 16:51:00 +00:00
Jiachi Liu
055e28ef81
Ensure only one doctype is rendered (#31534)
React-dom renders doctype automatically when `<html>` is detected. We should append `DOCTYPE` prefix only when necessary.
x-ref: https://github.com/facebook/react/pull/21680

## Bug

![image](https://user-images.githubusercontent.com/4800338/142215292-4af4a61d-2d75-48ae-a31a-0af641c72dcf.png)

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-11-17 14:57:48 +00:00
Steven
d87dc2b5a0
Add detection for Google-PageRenderer bot (#31521)
- Fixes https://github.com/vercel/next.js/discussions/31482
2021-11-17 03:49:37 +00:00
jj@jjsweb.site
2ad9dac873
v12.0.5-canary.0 2021-11-16 16:48:33 -06:00
Shu Ding
4ea7d7b177
Refactor the middleware SSR loader (#31508)
Initial step for #31506, to move the adapter logic out of the loader output string so it will be easier to reuse code in the future. Also, more options are passed to the loader to align with the serverless loader.

## 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-11-16 20:43:57 +00:00
Jiachi Liu
55ab4f06b7
Use _error for development in streaming (#31466)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-16 20:18:57 +01:00
Kiko Beats
593d943cd0
NextResponse: add .json static method (#31483)
closes: https://github.com/vercel/next.js/issues/31196

This new API was suggested in a previous version of this feature:
https://github.com/vercel/next.js/pull/31024#discussion_r745035448

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-11-16 18:38:47 +00:00
Tobias Koppers
bf973165fe
update webpack (#31455)
https://github.com/webpack/webpack/releases/tag/v5.64.1
2021-11-16 17:28:42 +00:00
Tobias Koppers
b79591cdaf
simplify output messages (#31454)
remove all `client/server/middleware only` messages and show `client and server` instead only when both compilers has been used.
2021-11-16 15:57:30 +00:00
Javi Velasco
9375485969
Remove TextEncoder and TextDecoder wrappers (#31490)
This PR removes the class wrapper that we have for `TextEncoder` and `TextDecoder`. Since this is merged we will be using directly the Node version in the sandbox.
2021-11-16 14:12:22 +00:00
stefanprobst
f195650f74
fix: allow next lint without eslint-config-next installed (#29823) 2021-11-16 14:07:31 +01:00
Yamagishi Kazutoshi
32f0c9a403
Support ESLint v8 (#29865)
Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-11-16 10:18:27 +01:00
Heyang Zhou
a39a8969d3
Add a swc transform for removal of console.* calls. (#31449) 2021-11-16 10:18:05 +01:00
jj@jjsweb.site
abd87a515e
v12.0.4 2021-11-15 14:43:54 -06:00
jj@jjsweb.site
b204640008
v12.0.4-canary.15 2021-11-15 14:07:57 -06:00
Kiko Beats
b51a020941
middleware: add request referrer support (#31343)
closes: https://github.com/vercel/next.js/issues/30353

According with spec, `'about:client'` is the default value is the user doesn't provide it.

It needs to add a test there, looks like there no unit tests for these classes 🤔
2021-11-15 19:52:44 +00:00
jj@jjsweb.site
66d9b4e14a
v12.0.4-canary.14 2021-11-15 12:54:42 -06:00
Jiachi Liu
ef5795327a
Close stream when fatal error occurs (#31164)
* support custom 500 error in streaming

* remove unused imports
2021-11-15 11:49:50 -06:00
Steven
eb0bd63af4
Fix basePath replacing server-side and normalizeLocalePath() when path is empty string (#30978)
This fixes our `basePath` detection/replacing server-side as we were incorrectly considering `/docss` a match for a `basePath` of `/docs` which caused us to have an unexpected value in the `normalizeLocalePath` function. 

- Fixes #22429
- Regression introduced in #17757 
- Fixes: https://github.com/vercel/next.js/issues/31423

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-11-15 17:33:21 +00:00
Tim Neutkens
2d9ac399c1
Remove moment locale replace from craCompat as it's a default in Next.js 12 (#31431) 2021-11-15 10:36:53 -06:00
Shu Ding
16d56e2c49
Refactor server/render for SSR streaming (#31231)
Initial step to refactor the rendering logic by decoupling the handler and renderer:
1. Delegate Flight rendering to server/render
2. Reuse the piper glue code for both Fizz and Flight streams
3. Add buffering for ReadableStream

In 1), this PR also makes sure that gSSP/gSP are correctly executed before the Flight stream and `pageProps` and `router` are correctly delivered to the component.

Related to #30994.

## 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-11-15 15:29:34 +00:00
Byron
8c547139e4
add filename to babel warning about anonymous function default exports (#31322)
fixes #29667

I didn't add an integration test, but I can take a stab at it if you point me in the right direction!
2021-11-15 14:01:20 +00:00
Tim Neutkens
e5171758d3 v12.0.4-canary.13 2021-11-15 14:19:55 +01:00
Tim Neutkens
9da8d65632
Add minify debug env var to investigate minifier bugs (#31417) 2021-11-15 14:15:18 +01:00
Tobias Koppers
644d361c98
show (middleware only) when a middleware is added to the compiler (#31409)
## 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-11-15 09:20:27 +00:00
Tim Neutkens
8c84b4a1b6 v12.0.4-canary.12 2021-11-15 09:42:05 +01:00
Donny/강동윤
6fd44383f3
Update swc & fix styled-jsx (#31407) 2021-11-15 09:27:45 +01:00
Tim Neutkens
950eb0f489 v12.0.4-canary.11 2021-11-13 18:26:43 +01:00
Tim Neutkens
e0531e30f4
Add support for legacy decorators through tsconfig/jsconfig (#31376) 2021-11-13 18:26:13 +01:00
Matt Kane
9952cc79db
Don't proxy middleware if host is the same (#31180)
This changes the check for whether a rewrite is internal or if it should be proxied. Currently it checks if `protocol` is unset, which is only the case for relative URLs or localhost. This means that requests where there is a hostname set, or if localhost is specified in another way such as `127.0.0.1`, then it will be proxied, which potentially causes a proxy loop or ssl error. This PR changes the test so that it also checks if the hosts match, and only proxies if they are different.

Fixes #31179 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-11-13 00:20:13 +00:00
Hiroshi Ogawa
4a22059b11
fix(30724): clear "x-middleware-next" header when chaining middlewares (#30866)
* fix(30724): clear "x-middleware-next" header when chaining middlewares

* refactor: do not accumulate "x-middleware-next" header

* test: fix grammar of test case title

* Update packages/next/server/next-server.ts

Co-authored-by: Javi Velasco <javier.velasco86@gmail.com>
2021-11-12 17:44:17 -06:00
Tim Neutkens
d9fc3eeb7e v12.0.4-canary.10 2021-11-12 21:54:01 +01:00
Tim Neutkens
a4692d400d
Add support for jsxImportSource in tsconfig/jsconfig (#31358) 2021-11-12 21:51:43 +01:00
JJ Kasper
06f3d398b1
Ensure NODE_ENV is replaced correctly with swc (#31274) 2021-11-12 13:59:21 -06:00
Filip Skokan
f796ea3e7d
fix(middleware): fetch resource may be a URL instance (or any stringifiable value) (#31260)
The `resource` argument[^1] in fetch may also be an instance of URL (or any other stringifiable value) but the sandbox variant of middlewares doesn't support that.

```js
export async function middleware(req, ev) {
  await fetch(new URL('https://www.googleapis.com/oauth2/v3/certs'), {
    redirect: 'manual',
    method: 'GET',
  })

  return new Response(JSON.stringify({}), { status: 200 });
}
```

This is fixing the use of e.g. URL instance in `fetch`.

```
TypeError: initurl.startsWith is not a function
  at getFetchURL (/my-next-app/node_modules/next/dist/server/web/sandbox/sandbox.js:246:17)
  at fetch (/my-next-app/node_modules/next/dist/server/web/sandbox/sandbox.js:77:29)
  at Object.middleware [as handler] (webpack-internal:///./pages/_middleware.js:86:15)
  at async adapter (webpack-internal:///./node_modules/next/dist/server/web/adapter.js:30:22)
  at async DevServer.runMiddleware (/my-next-app/node_modules/next/dist/server/next-server.js:430:26)
  at async DevServer.runMiddleware (/my-next-app/node_modules/next/dist/server/dev/next-dev-server.js:394:28)
  at async Object.fn (/my-next-app/node_modules/next/dist/server/next-server.js:807:34)
  at async Router.execute (/my-next-app/node_modules/next/dist/server/router.js:211:32)
  at async DevServer.run (/my-next-app/node_modules/next/dist/server/next-server.js:1115:29)
  at async DevServer.run (/my-next-app/node_modules/next/dist/server/dev/next-dev-server.js:440:20)
```

[^1]: https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters
2021-11-12 13:22:27 +00:00
Jiachi Liu
cf206a8392
Resolve stream piper on complete shell for renderToReadableStream (#31186)
1. Align `renderToReadableStream` with `renderToNodeStream`, resolve promise of `NodeWritablePiper` only when `onCompleteShell` is called.
2. update webpack to disable chunk loading for web runtime

Item 1 is the preparation for middleware-ssr-loader. Then we can do the following there

```js
try {
   result = await renderToHTML(page)
} catch (e) {
   result = await renderToHTML(errorPage)
}
result.pipe(renderResult)
```
2021-11-12 00:00:54 +00:00
Yunfei He
4551571615
Automatically use different port to start dev server for non-explicit port (#30736)
* Automatically using different port to start dev server for non-explicit port

* return correct port

* more reasonable changes

* fix isExplicitPort

* 1. rename isExplicitPort to allowRetry 2.restrict the number of retries

Co-authored-by: Steven <steven@ceriously.com>
2021-11-11 17:19:20 -05:00
jj@jjsweb.site
51ad2542bb
v12.0.4-canary.9 2021-11-11 14:20:30 -06:00
JJ Kasper
6b89fbf12d
Ensure asPath is correctly normalized in minimalMode with i18n (#31281)
This ensures the `asPath` and `req.url` values are normalized correctly for fallback pages with i18n in minimal mode. This also copies the minimal mode test suite to run against i18n as well. This also fixes an issue where rewrite params weren't passed correctly on the client when no params were already used in the destination. 

The provided reproduction has been deployed against this patch [here](https://nextjs-error-repro-9zdu3sp5r-ijjk-testing.vercel.app/page/test-page) show it working. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/27563
Fixes: https://github.com/vercel/next.js/issues/30203
2021-11-11 20:11:50 +00:00
Jiachi Liu
6abc6699e9
Upgrade webpack (#31313)
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-11-11 19:02:27 +00:00
Tim Neutkens
c4558c913f
Output where preference is saved (#31305)
Fixes #31241



## 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-11-11 16:48:00 +00:00
Tim Neutkens
fbe366f465 v12.0.4-canary.8 2021-11-11 16:36:38 +01:00
Tim Neutkens
7aabcda66e v12.0.4-canary.7 2021-11-11 16:31:33 +01:00
Tim Neutkens
9faf14e0b7
next/jest: Ensure typeof window is not transformed in jsdom environment (#31304)
Found that when the target is `jsdom` instead of `node` the "typeof window" transform is incorrect. This was causing an unexpected failure in on of the tests for vercel.com.


## 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-11-11 15:05:32 +00:00
Tim Neutkens
0ae94488f3 v12.0.4-canary.6 2021-11-11 12:06:30 +01:00
Donny/강동윤
46e1cbc95e
Update swc for jsc.paths (#31290)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-11 11:55:44 +01:00
Tim Neutkens
2800a2b1c0
Ensure next/jest is published (#31296)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-11 11:48:12 +01:00
ihmpavel
bd8003850b
Fix typo in next build log (#31295)
## 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-11-11 10:38:53 +00:00
Tim Neutkens
dfff685207 v12.0.4-canary.5 2021-11-11 09:21:54 +01:00
vordgi
ae1d271f9a
bugfix/i18n Do not support the second locale in the pathname (#31229)
## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

Fixes: https://github.com/vercel/next.js/issues/31228
2021-11-11 02:29:20 +00:00
ericbiewener
c791da0977
correctly assess node equality when nonce attribute is present (#27573)
* add isEqualNode function

* add test

* trying to make integration test work

* revert

* Update test/unit/is-equal-node.unit.test.js

Co-authored-by: Steven <steven@ceriously.com>

* Revert "revert"

This reverts commit d67b9971068d18efcf839666a3a17619fd914fc3.

* Fix tests

* Use TS for unit test

* Revert waitfor

* Start tests with "should"

* Fix lint

* Use cloneNode()

Co-authored-by: Eric Biewener <eric.biewener0@walmart.com>
Co-authored-by: Steven <steven@ceriously.com>
2021-11-10 19:31:32 -06:00
Tim Neutkens
0196b03621
Experimental next/jest config helper (#31246)
* Experimental next/jest config helper

Co-Authored-By: Maia Teegarden <dev@padmaia.rocks>

* Ensure useTypescript is provided

* Move experimental warning to next/jest

* Remove unused code

* Remove unused imports

Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
2021-11-10 16:16:15 -08:00
Stefano Rainieri
52139a41e9
fix: replaced useless let (#31239)
## 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-11-11 00:14:38 +00:00
Jiachi Liu
edb5060fc0
Fix process.env overriden in web runtime (#31261)
Fixes #31258

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-11-10 18:57:27 +00:00
Donny/강동윤
fd9593542a
Update swc minifier (#31242)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-11-10 17:39:34 +01:00
Tobias Koppers
9c4c7123b6
run middleware parser handler only for middleware modules (#31219)
## 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-11-10 15:31:46 +00:00
Donny/강동윤
24f7c21736
Update swc (#31233)
## 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`

This applies

 - https://github.com/swc-project/swc/pull/2699

Fixes https://github.com/vercel/next.js/issues/30839
2021-11-10 09:06:04 +00:00
jj@jjsweb.site
7087adba12
v12.0.4-canary.4 2021-11-09 15:47:35 -06:00
Tobias Koppers
8c8642898f
upgrade webpack (#31034)
* upgrade webpack

* ⚙ Update compiled files

Co-authored-by: sokra <sokra@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-09 22:34:53 +01:00
Genet Schneider
e3135ccde6
Support assetPrefix specific protocol (#31213)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-11-09 15:26:55 -06:00
Filip Skokan
0985b0b472
share collections in middleware vm context (#31043)
When libraries are required outside of the middleware function context and they do checks such as `a instanceof Uint8Array` since the constructors are different between the two contexts they'll always yield false.

This is a problem for libraries validating user input as well as the WebCryptoAPI polyfill used outside of Edge Functions.

- Fixes #30477
- Fixes #30911

This is only a problem for the sandbox runtime, not when ran inside an Edge Function.
2021-11-09 19:57:19 +00:00
Hiroshi Ogawa
764e29c170
fix(31013): add base path to preflight request url (#31101)
Fixes https://github.com/vercel/next.js/issues/31013

My understanding is that there are currently two functions `Router.change` and `Router.prefetch` leading to `Router._preflightRequest` and they pass `options.as` URL differently regarding base path.
In this PR, such difference will be handled in `Router._preflightRequest` to add base path before actually fetching.
Thanks for the review!

P.S.
Since middleware feature is a relatively new, official maintainers might not want external contributions around this area at this stage.
I totally understand such situation, so please let me know if that's the case. I can look for other issues to investigate instead.


## Bug

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

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-11-09 19:03:05 +00:00
Tim Neutkens
3e8b2dcb6c
Disable styled-components displayName in production (#31216)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-11-09 12:24:01 -06:00
Kiko Beats
0bcb7149dc
fix(middleware): expose CryptoKey and globalThis.CryptoKey (#31193)
closes https://github.com/vercel/next.js/issues/30475
2021-11-09 17:39:29 +00:00
JJ Kasper
eb7b40171a
Add initial standalone build handling (#31003)
* Add initial standalone handling

* apply suggestions

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>
2021-11-09 11:03:20 -06:00
Tim Neutkens
31985c5cae v12.0.4-canary.3 2021-11-09 17:18:40 +01:00
Tim Neutkens
b5b315ae04
Add test for styled-components SWC transform disabled (#31214)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-09 17:18:04 +01:00
Tim Neutkens
bcf25289de v12.0.4-canary.2 2021-11-09 15:42:12 +01:00
Tim Neutkens
1941eedd7a Add webpack5 types to right files 2021-11-09 15:40:13 +01:00
Tim Neutkens
14aac0859f
Add all cases where webpack5 type is used (#31206) 2021-11-09 15:18:40 +01:00
Spencer Elliott
a1e76fb966
Use require.resolve to detect "framework" packages (fix pnpm) (#21048)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-11-09 14:42:23 +01:00
Tim Neutkens
a0a08ae9e5 v12.0.4-canary.1 2021-11-09 12:49:23 +01:00
Donny/강동윤
54ca8f41ce
next-swc: Add displayNameAndId of styled-components (#31189)
## 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`




Related to: https://github.com/vercel/next.js/issues/30802
2021-11-09 10:05:31 +00:00
Javi Velasco
5fc4325aa6
Fix middleware i18n rewrites (#31174)
Fixes #30897

This PR fixes the linked issue where rewrites are not being applied for locale. It adds the corresponding test but also, as it was added in debugging process, it introduces a helper to read/write into the `request` object.

We are currently writing directly into the request by casting to `any` and then using flags like `_nextRewrote`. Instead, this PR puts all of this metadata under a symbol so it is not directly accessible. This also allows to have a single place where all of this metadata is listed so we can add comments describing the purpose of each flag.

In the same way, there is metadata written in the querystring. This is adding some types for it in order to throw some visibility on where is this metadata accessed. In an upcoming PR we can move all of it to the `request` object if possible to simplify the system.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2021-11-09 01:28:39 +00:00
Shu Ding
91a6e3af3a
Do not hide body when concurrentFeatures is enabled (#31187)
When Fizz is enabled, we want to always show the content of body even before it's loaded. Please hide whitespace changes when reviewing this PR.

## 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-11-09 00:45:44 +00:00