Commit graph

1521 commits

Author SHA1 Message Date
JJ Kasper
1ee13baf00
Ensure NODE_ENV is not inlined for next/jest (#33032) 2022-01-05 09:22:22 -06:00
JJ Kasper
e01ef297e7
Ensure middleware is output in standalone mode (#32967) 2022-01-03 18:47:18 -06: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
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
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
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
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
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
JJ Kasper
3667eba385
Pre-compile more dependencies continued (#32679) 2021-12-21 16:13:45 +01: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
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
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
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
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
ee220730db
fixes to allow lazy compilation for import() (#32441) 2021-12-14 11:33:04 +01: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
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
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
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
Tim Neutkens
bc429f50c2
Remove future.strictPostcssConfiguration config (#32098) 2021-12-03 13:25:05 -06: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
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
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
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
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
Maia Teegarden
0ef87397da
Account for platform/arch not supported by napi (#31938) 2021-11-29 18:05:35 -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
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
Heyang Zhou
809d0155ff
Add support for removing React properties. (#31606) 2021-11-26 14:45:03 +01: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
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
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
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
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
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