Commit graph

4700 commits

Author SHA1 Message Date
JJ Kasper
59714db16d
Update server-only changes HMR handling (#34298)
* Update server-only changes HMR handling

* Add failing tests for GS(S)P server only changes

* update test

* normalize backslashes

* Update to xor the chunk hashes

* remove test change

* remove other test change
2022-02-16 16:32:24 -06:00
Tobias Koppers
54dbeb30c1
update webpack (#34444)
https://github.com/webpack/webpack/releases/tag/v5.69.0
2022-02-16 21:59:13 +00:00
JJ Kasper
732b4052bd
v12.0.11-canary.19 2022-02-16 14:36:59 -06:00
Steven
8a55612c0d
Add image config for dangerouslyAllowSVG and contentSecurityPolicy (#34431)
## Feature

- [x] Integration tests added
- [x] Documentation added
- [x] Errors have helpful link attached, see `contributing.md`



Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-02-16 19:28:22 +00:00
Balázs Orbán
9639fe704c
Ensure we don't poll page in development when notFound: true is returned (#34352)
Fixes: #34342

Visiting the following page will call gSSP indefinitely in a loop and logs errors from `on-demand-entries-client`:
```js
const Home = () => null
export default Home
        
export function getServerSideProps() {
  console.log("gssp called")
  return { notFound: true }
}
```

We should not keep fetching the page if it returns 404 as  it can introduce unnecessary data requests.

## 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>
2022-02-16 18:53:48 +00:00
Balázs Orbán
d88793d973
feat: improve opening a new issue flow (#34434)
Ref: [Slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1645003443213449)

When opening a new issue, it is desired that the user has checked if the `canary` release not already have fixed their issue, since we do not backport fixes to previous Next.js versions.

- added a CLI warning when `next info` runs that looks like this:

![image](https://user-images.githubusercontent.com/18369201/154309275-01ccc979-01e5-4ccb-8a22-5deab64765a0.png)

This links to a message docs page with more information and some useful links.

- refactored our bug report templates to be more clear and removed the fields that are now unnecessary (since running `next info` is expected to run on releases that already have it)

- Made browser/deployment optional, as in most cases those fields are irrelevant. We still ask them, but mention that they are only needed if relevant.

- Asking for the exact browser version now

## 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: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-16 17:45:01 +00:00
JJ Kasper
07fe5412c7
v12.0.11-canary.18 2022-02-16 09:38:38 -06:00
JJ Kasper
4f05426053
v12.0.11-canary.17 2022-02-15 14:34:59 -06:00
Aman Mittal
634926d8df
Add Error Handing section for ISR (#34360)
* Add Error Handing section for ISR

* Apply suggestions from code review

* update check

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-15 14:22:15 -06:00
Tim Neutkens
019981882d v12.0.11-canary.16 2022-02-15 19:16:53 +01:00
JJ Kasper
982b65a327
Ensure invalid request to static page is handled correctly (#34346)
* Ensure invalid request to static page is handled correctly

* update test
2022-02-15 11:28:18 -06:00
Tim Neutkens
62b1704e41
Add support for "type": "module" in package.json (#33637)
- [x] Add failing test for development / production
- [x] Add failing test for client-side JavaScript
- [x] Write `.next/package.json` with `"type": "commonjs"
- [x] Fix issue with client-side JavaScript showing `module` is not defined

Production works after these changes. Development breaks on module not existing because of the Fast Refresh loader. Working with @sokra to add alternatives to what is being used in the loader to webpack so that it can be updated.

Fixes #23029, Fixes #24334



## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] 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-02-15 16:24:11 +00:00
Alex Castle
f516304649
Remove experimental image optimization feature (#34349)
This PR removes the experimental `optimizeImages` flag. This feature was designed to automatically add preload tags for images, but I was never able to get it to do a very good job of selecting the images that actually need preloading.

This feature never graduated from experimental and in fact we never even publicized it as an experimental feature for people to try.

Additionally, even if someone was using this feature, it wouldn't have a functional effect, only a performance effect (removal of some preloads).

For those reasons, I believe it is safe to remove this functionality and that it is not a breaking change.
2022-02-15 01:36:51 +00:00
Tobias Koppers
c20e8297bf
Allow dismissing full refresh warning for session (#33868)
x-ref: #31827
x-ref: #34212

![image](https://user-images.githubusercontent.com/1365881/151994766-b9afb349-1a9a-4220-9387-de10165e34e3.png)




## 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: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-14 23:23:45 +00:00
Shu Ding
2f7951892e
fix double render in strict mode (#34333)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-02-14 22:35:05 +01:00
Shu Ding
468833e0b4
Fix <RouteAnnouncer/> shouldn't announce initial path under strict mode and React 18 (#34338)
As the comment mentioned, React 18 with Strict Mode enabled might cause double invocation of lifecycle methods. This makes the `<RouteAnnouncer/>` being non-empty for the initial page, which is a bug (it should only announce page change whenever a navigation happens).

## 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`
2022-02-14 19:18:39 +00:00
Jiachi Liu
1aee93581f
Align reactRoot config between server and webpack config (#34328)
### Changes

* node server and webpack should share the same logic: auto detect react 18 and enable `reactRoot`
* fallback `_error` should use functional document if concurrent rendering is enabled

### Test

* Remove the hard code `reactRoot: true` in test suite
* Test some react-18 test suite with nodejs runtime
2022-02-14 16:18:57 +00:00
Hassan El Mghari
ca8530ffc8
Changed all occurrences of etc to match (#34280)
The [correct](https://www.grammarly.com/blog/et-cetera-etc/) way to use et cetera is to put a period right after and a comma behind it if it's being used as a list. I updated the occurrences in the docs and examples that didn't match these rules.
2022-02-13 00:22:52 +00:00
JJ Kasper
c051af8528
v12.0.11-canary.15 2022-02-11 15:36:59 -06:00
Sebastián Espinosa
c1fd2ca79f
Adding step to build the app with docker in existing projects (#34083)
* Adding steps to build the app with docker in existing projects (without the need to create the app with the with-docker example)

* Update examples/with-docker/README.md

Fix uppercase

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-11 15:27:10 -06:00
Balázs Orbán
7ac9c484c3
feat: allow node-sass@7 as peer dependency (#34107)
* chore(deps): upgrade `sass-loader` to support `node-sass@7

* chore: allow `node-sass@7` as peer dependency of `next`

* chore: updated precompiled `webpack` and `sass-loader`

* ⚙ Update compiled files

* Update packages/next/package.json

Co-authored-by: matamatanot <39780486+matamatanot@users.noreply.github.com>

Co-authored-by: balazsorban44 <balazsorban44@users.noreply.github.com>
Co-authored-by: matamatanot <39780486+matamatanot@users.noreply.github.com>
2022-02-11 15:14:09 -06:00
Jiachi Liu
76d274dbec v12.0.11-canary.14 2022-02-11 20:58:23 +01:00
Shu Ding
6bc7c4d9c2
Optimize the web server size (#34242)
Related to #34185, this PR reduces the size of chunk that contains web-server.ts from 1.14mb to 210.8kb, by splitting base-http and api-utils into different environments.

Only affected thing is we can't have SSG preview mode for the web runtime via `getStaticProps`.

## 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-02-11 19:56:25 +00:00
Shu Ding
931666dd3c
Fix uncaught error in getInitialProps when runtime is set to nodejs (#34228)
This PR ensures that the test "should render 500 error correctly" doesn't break when `runtime` is set to `nodejs` with `serverComponents` enabled.

This test case is now moved to the "basic" suite to ensure it doesn't break in both runtimes. And "should not bundle external imports into client builds for RSC" is enabled for the `nodejs` runtime too.

## 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`
2022-02-11 18:30:39 +00:00
Jiachi Liu
477134d8c9
Enable dynamic HTML in minimal mode (#34222)
Follow up for #34068

Let minimalMode render HTML by streaming facilities
2022-02-11 17:43:39 +00:00
JJ Kasper
516e113d25
v12.0.11-canary.13 2022-02-11 10:26:38 -06:00
Maedah Batool
361ce87221
Fix link for "Delete Query Params in Middleware" error message in next-server.ts (#34230)
The link inside `next-server.ts` [file](46343564a1/packages/next/server/next-server.ts (L1338)) for the "Delete Query Params in Middleware" error message was pointing to a 404 page. 

Since we've moved the `errors` directory to `docs/messages` in the Next.js repo ([See this](a1c752ac46/next-site/pages/docs/messages/%5B...slug%5D.js (L133))). The PR adds these changes.

## Bug

- [x] Related [Slack thread](https://vercel.slack.com/archives/C02F56A54LU/p1644582812712219)

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-02-11 14:44:02 +00:00
JJ Kasper
fa5571a891
Use updated recursive rm fs method for image-optimizer (#34210)
This ensures we handle `EEXISTS` with `fs.rmdir` for Node.js `v12` and use `fs.rm` when available instead as it is the replacement for `fs.rmdir` with the `recursive` option. 

## 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/33860#issuecomment-1035676729
2022-02-11 02:28:55 +00:00
Jiachi Liu
4f8ffed4bf
Fix reuse of inline flight response and 404 for RSC in node runtime (#34202)
### Fixes

* We need give value for `__flight__` query or it will lost in node runtime
* Match the cache key of flight response (`path + search`, `route, `id`)
* Flight response should return `200` instead of `404` for 404 page

### Tests

* Run rsc for node runtime test suite
* Add more cases for 404
2022-02-10 21:13:52 +00:00
JJ Kasper
8060bcb38c
v12.0.11-canary.12 2022-02-10 11:59:04 -06:00
Balázs Orbán
46e32ae184
feat: copy .env file in standalone mode (#34143)
Ref: #33897

I took a naive approach and simply added `.env` to the files that need to be copied.

Do we want to include `.env.production` as well? Ref: https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables

(I haven't tested what happens if the file does not exist on copy.)

Other files like `.env.*local` or `.env.{test,development}` don't make sense to copy.

## 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: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-10 17:48:14 +00:00
Steven
8dfaaf5573
Bump nft to 0.17.5 (#34190)
Related to https://github.com/vercel/nft/issues/265

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-10 17:14:11 +00:00
JJ Kasper
b37d49c130
Ensure standalone server handles SIGTERM (#34151) 2022-02-10 12:13:27 +01:00
Vladlen Grachev
46343564a1
Add _document and _app pre-import (#23261)
* Add _document and _app pre-import

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-09 20:53:04 -06:00
Simon Knott
abf9f75821
Fix bug with "Circular Structure" error (#23905)
* Fix bug with "Circular Structure" error

Since `-1` is truthy, every JSON.stringify error is mistaken to be `circular structure`. This commit fixes that behaviour, so that other errors like `Do not know how to serialize Bigint` (see https://github.com/blitz-js/babel-plugin-superjson-next/issues/63) aren't swallowed.

* Add integration test

This may be thought of as being a pretty contrived example, but it's exactly what happened in https://github.com/blitz-js/babel-plugin-superjson-next/issues/63.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-09 20:28:24 -06:00
Maia Teegarden
01ee7e0b22
Chore/stable swc compiler options (#34074)
Mark some previously experimental swc compiler options as stable under a new `compiler` option

## 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-02-10 01:54:28 +00:00
JJ Kasper
f7eaf006c0
v12.0.11-canary.11 2022-02-09 13:26:12 -06:00
Jiachi Liu
52c3d07c95
Fix required files matching in rsc (#34137)
Fix the wrong filename evaluation of `MIDDLEWARE_FLIGHT_MANIFEST` in required files. Besides checking the generated files, check if they're declared correctly in `required-server-files.json`
2022-02-09 19:24:05 +00:00
JJ Kasper
28f65ff411
Fix image-optimizer requires in next-server (#34141) 2022-02-09 12:37:55 -06:00
Steven
228640eedd v12.0.11-canary.10 2022-02-09 09:17:49 -05:00
Gerald Monaco
3e6035937a
Fix: Use react-dom/server.browser when reactRoot: true (#34116)
Since we want to use the streaming renderer when `reactRoot: true`, we have to make sure we use the right server implementation too.
2022-02-09 03:48:52 +00:00
Jiachi Liu
0f5d9dce72
Fix included flight manifest on node runtime (#34113)
We need to switch to json flight manifest on node deployment for RSC
2022-02-09 01:26:50 +00:00
JuniorTour
e2d6c311b5
fix: next/image usage from node_modules (#33559)
fix: image config not work for `node_modules`

Co-authored-by: Steven <steven@ceriously.com>
2022-02-08 19:55:53 -05:00
JJ Kasper
130f8645a2
Update to leverage response-cache for image-optimizer (#34075)
This updates to leverage our `response-cache` used for ISR for our `image-optimizer` as well. 

Co-authored-by: Steven <steven@ceriously.com>
2022-02-08 18:46:59 -05:00
Jiachi Liu
c735de8550 v12.0.11-canary.9 2022-02-08 22:46:00 +01:00
Shu Ding
eb3cba388c
Polyfill pipeTo and pipeThrough (#34112)
* polyfill pipeTo

* add pipeThrough

* covert pipeThrough calls

* use pipe

* invert logic

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-02-08 22:40:25 +01:00
Shu Ding
b5d757e046
Fix static result being piped (#34111)
We need to check if the render result is dynamic or not, before using `pipe`.
2022-02-08 21:03:38 +00:00
Gerald Monaco
df29561ae3
Use renderToStream with React 18 (#34106)
As per React 18 recommendation, we should use e.g. `renderToReadableStream` whenever we use `createRoot`. This is particularly important for currently supported suspense features like `React.lazy` to work properly during SSR.

However, unless you have opted in to streaming support (via [the `runtime` flag](https://github.com/vercel/next.js/pull/34068)), we will wait until `onCompleteAll` before sending it (via the `generateStaticHTML` flag).

---

Fixes #33879
2022-02-08 19:39:27 +00:00
Jiachi Liu
fb80055a1f
fix: arrow function export in rsc client component (#34105)
The `export default xxx` statement is slightly different from estree when exporting an arrow function instead of identifier in swc.
We also need to capture arrow exports.
2022-02-08 19:09:47 +00:00
Tim Neutkens
66062722f1
Remove experimental warning from next/jest (#34096)
## 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-02-08 16:52:05 +00:00