Commit graph

518 commits

Author SHA1 Message Date
Steven
da8d1984d2
Add experimental wildcard remotePatterns config for upstream images (#36245)
## Description 
This PR implements a new configuration object in `next.config.js` called `experimental.images.remotePatterns`.

This will eventually deprecate `images.domains` because it covers the same use cases and more by allowing wildcard pattern matching on `hostname` and `pathname` and also allows restricting `protocol` and `port`.

## Feature

- [x] Implements an existing feature request.
- [x] Related issues linked
- [x] Unit tests added
- [x] Integration tests added
- [x] Documentation added
- [x] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`

## Related 

- Fixes #27925 
- Closes #18429 
- Closes #18632
- Closes #18730
- Closes #27345
2022-05-05 02:19:16 +00:00
LongYinan
2012f4e7c6
Update components in GitHub Actions (#36669)
`build-native` jobs tested on https://github.com/vercel/next.js/runs/6288266017
2022-05-04 18:51:25 +00:00
Houssein Djirdeh
fd2ba11763
Adds inline script functionality to next/script for worker and beforeInteractive strategies (#36364)
Adds inline script functionality to `next/script` for `worker` and `beforeInteractive` strategies. 

- fixes #36318 
- fixes #26343
- fixes #26591
- fixes #26343
- fixes #26240


Co-authored-by: Janicklas Ralph <6142074+janicklas-ralph@users.noreply.github.com>
2022-04-29 15:20:31 +00:00
JJ Kasper
4f5c2deb4c
Add note about lockfile causing swc to fail to load (#36484)
* Add note about lockfile causing swc to fail to load

* Apply suggestions from code review

Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
2022-04-26 14:48:52 -05:00
Jiachi Liu
d5e767b20d
Add process env NEXT_RUNTIME (#36383)
* To help determine the current running environment is in server nodejs / edge runtime
* Remove usage of `process.browser`
2022-04-26 17:54:28 +00:00
Maedah Batool
60488e68e3
Fix broken data fetching links in docs (#33766)
* Fix broken links for Data Fetching

* Fix link data fetching doc

* Improve link file paths

* Update errors/large-page-data.md

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

* Update links

* Fix linting

* Lint tests

* Lint tests

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2022-04-22 14:03:07 +02:00
Janicklas Ralph
0441f816a6
Changes to the beforeInteractive strategy to make it work for streaming (#31936)
Changes to the beforeInteractive strategy to make it work for streaming

Splitting `beforeInteractive` into two strategies `beforeInteractive` at the _document level and `beforePageRender` for page level <Scripts>
2022-04-21 21:15:53 +00:00
Michael Ward
1be5f36123
Adds linting rule to avoid assignment to 'module' variable. Fixes #34859 (#35279) 2022-04-15 14:45:53 +02:00
Vlad Tansky
a11479bad9
docs: failed-loading-swc possible fix for Windows users (#36081)
Apparently, Microsoft Visual C++ Redistributable is required for Windows users. 

> The issue is because the package is failing due to a missing library on the computer. fs-search requires Microsoft Visual C++ 2015 Redistributable (x64).
> You can get the download here -> https://aka.ms/vs/17/release/vc_redist.x64.exe

from https://stackoverflow.com/questions/69859120/the-specified-module-could-not-be-found-d-next-js-firstapp-node-modules-n



## 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
- [x] 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-04-12 18:21:11 +00:00
Samuel
cb565d69cf
Update: Add appropriate error message when for getServerSideProps invalid return value (#35887) 2022-04-06 10:25:27 -05:00
Samuel
739e6f0760
Docs: Add useful link to invalid-getstaticprops-value error message (#35915)
## Documentation / Examples

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

I would like to add useful link to `getStaticProps` invalid return value error message as currently there is no useful link being provided. I believe that this might improve the developer experience.
2022-04-05 18:59:58 +00:00
JJ Kasper
b1a7b88890
Add warning when importing "next" directly (#35884)
* Add warning when importing "next" directly

* Apply suggestions from code review

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

* Apply suggestions from code review

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

* add example

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Steven <steven@ceriously.com>
2022-04-05 10:57:45 -05:00
Jon Espen Kvisler
127bbc0ba6
Update dead link for getStaticPaths in docs (#35814) 2022-04-01 11:51:18 +02:00
Jiachi Liu
27d23f5b7b
docs: update styling support for streaming (#35375)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-03-26 20:19:21 +00:00
JJ Kasper
72478c5c80
Update next/link error when no children are provided (#35453)
* Update next/link error when no children are provided

* update manifest

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-22 13:58:55 -05:00
Sacha
b579a35e83
[examples] Update styled-components to use SWC (#34770)
* rename example with-styled-components to with-styled-components-babel

* update with-styled-components references

* update docs on react hydratation erros for styled components

* clone with-styled-components-babel without babel config

* add styledComponents to compiler options in next.config

* replace babel dependency with Next.js SWC compiler

* upgrade example typescript version

example with-typescript-styled-components had a typescript dependency
lower than the recommended version. Upgraded from 4.2.4 to 4.5.5.

* Apply suggestions from code review

* update readme for with-styled-components-babel

remove Notes section since it describes a workaround which is no longer
required to work with `next/link`.

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-02 03:43:34 +01:00
JJ Kasper
35a1af4cf4
Add redirect for error doc rename (#34791) 2022-02-25 11:09:04 -08:00
Colin Rice
079b507327
Add API config to allow disabling response size warning (#34700)
Adds an API config option that disables warning a user when their API response body is over 4 megs. This has been added for users who'd like to stream larger amounts of data from their API acknowledging the drawbacks. This config mirrors the existing [`externalResolver` config](https://nextjs.org/docs/api-routes/api-middlewares#custom-config).

Closes: [#33162](https://github.com/vercel/next.js/issues/33162)

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-25 02:04:02 +00:00
mxgnus
7d98537f95
added styled-components & replay support in swc (#34647)
styled-components & relay is supported in swc since nextjs 12.1
2022-02-21 12:28:38 -06:00
Lionel
4ad1c5a2bc
Update wrong code snippet (#34520)
Following the [example](https://nextjs.org/docs/advanced-features/custom-document), avoiding the following error:
>  Identifier 'Document' has already been declared



## 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-18 10:03:27 +00:00
Gerald Monaco
944c734d04
Add unstable_useFlushEffects hook (#34117)
Implements https://github.com/vercel/next.js/issues/30997 with some minor tweaks to the design:

* The hook is moved to Client Components (e.g. `pages/_app` instead of `pages/_document`). This was a silly oversight in the original design: the hook needs to be called during server prerendering.

* `useFlushEffects` instead of `useFlushEffect` as there isn't a particularly safe way to implement the singular semantics as a Client Component hook given the current implementation of server rendering.

---

Fixes #30997
2022-02-18 00:18:28 +00:00
JJ Kasper
d4eea7593a
Fix snippet language sh -> bash (#34487) 2022-02-17 11:05:40 -06:00
Gal Schlezinger
f0f322c0d1
Remove deprecation for relative URL usage in middlewares (#34461)
* Remove deprecation for relative URL usage in middlewares

* fix tests

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-17 09:12:36 -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
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
Rich Haines
127f94dc13
Updated failed to load error page to include info about node versions (#34362)
This PR updates the [failed loading swc](https://nextjs.org/docs/messages/failed-loading-swc) error page with information about switching node version and installing deps again.

## 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-15 15:44:10 +00:00
Ben Ilegbodu
41ecd5e6e2
docs: Add link to pageExtensions config in page-without-valid-component.md (#34285)
The [Page Without Valid React Component](https://nextjs.org/docs/messages/page-without-valid-component) explains some ways to fix the problem of Next finding a non-React Component. However, if someone is trying to use `.mdx` as an extension, or wants to include tests, stories or other non-page files in their `pages` folder there's nothing for them.

The [Custom Page Extensions](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions) has all the info to help them out, but adding it to this error page should make it more discoverable.



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

- [x] Make sure the linting passes by running `yarn lint`
2022-02-14 17:25:45 +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
Hassan El Mghari
26c40f3186
Add heading to invalid-api-status-body error (#34150) 2022-02-09 21:01:58 -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
Tim Neutkens
c74e4f21ff
Add support for async fn / promise in next.config.js/.mjs (#33662)
- Add support for async function / promise export in next.config.js/.mjs
- Update docs

Adds support for https://twitter.com/timneutkens/status/1486075973204422665

But also the simpler version:

```js
module.exports = async () => {
  return {
    basePath: '/docs'
  }
}
```



## Bug

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

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Documentation added

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-02-07 08:48:35 +00:00
Chris Patterson
74a65332a4
Changing GitHub Actions cache documentation (#28228)
## 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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-06 19:01:38 +00:00
Lakshya Thakur
8039c6b2b5
fix: Change url to nextUrl inside delete-query-params-in-middlewares.md (#33796)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-06 09:21:28 -06:00
Krychaxp
3055a82ede
Add note about dns-prefetch as fallback (#30385)
## 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-06 02:53:26 +00:00
Kara
24fe279751
Warn in dev mode when stylesheets are added using next/head (#34004)
This commit adds a development mode warning in the console
if you try to include <link rel="stylesheet"> tags in
next/head, e.g.

```
<Head>
  <link ref="stylesheet" href="..." />
</Head>
```

The warning message explains that this pattern will not
work well with Suspense/streaming and recommends using a
custom Document component instead.

## Feature

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-04 22:48:30 +00:00
Jiachi Liu
4812e22992
docs: use function for components in general (#33990) 2022-02-04 09:18:35 -06:00
Kara
61ea8efe42
Warn in dev mode when script tags are added with next/head (#33968)
This commit adds a development mode warning in the console
if you try to include <script> tags in next/head, e.g.

```
<Head>
  <script async src="..." />
</Head>
```

The warning message explains that this pattern will not
work well with Suspense/streaming and recommends using the
next/script component instead.

TODO in follow-up PR: add same warning for stylesheets, etc

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Integration tests added
- [x] Documentation added
- [x] Errors have helpful link attached, see `contributing.md`
2022-02-04 13:06:55 +00:00
Balázs Orbán
b7725133f8
docs: recommend .end instead of .send when no body is being sent (#33611)
Fixes #33536

I was thinking to make `body` optional here instead:

2c6bd1ed1b/packages/next/shared/lib/utils.ts (L262)

But that might result in more errors when not setting the status code correctly. So it's the easiest for us to just recommend `.end()` which `.send()` uses when there is no argument.

c71465d87a/packages/next/server/api-utils.ts (L269)

## 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-03 02:41:28 +00:00
Rich Haines
138361208c
Fixed duplicate data fetching overview page + links (#33774)
This PR removes the duplicate overview link for data fetching, and fixes the corresponding links

## 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: Lee Robinson <9113740+leerob@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-29 02:52:40 +00:00
Gal Schlezinger
7b2ea48745
Allow to delete URL search params in middleware rewrites (#33725)
This allows to have a more streamlined API for rewrites.
Since middlewares are code and not static configurations, we can allow people to
delete query params and not just overwrite them.

**⚠️ Warning ⚠️** this is a breaking change in query parameter behavior with middlewares, but the API will make more sense now. Compare the following:

```diff
  import {NextResponse} from 'next/server'
  export default function middleware({ nextUrl }) {
-   nextUrl.searchParams.set('ignored-query-param', '');
+   nextUrl.searchParams.delete('ignored-query-param'); // 🎉
    return NextResponse.rewrite(nextUrl);
  }
```

Since this is breaking change, we're adding a warning every time we find a query param that is missing, and eventually--the warning will be deleted.
I don't think we need to worry about older versions of Next.js as the current behavior is misleading: merging query parameters make sense for static rewrites, but not for middlewares where you have access to all the query parameters and can manipulate them freely.

Related:
* This is the opposite of #33454
* This supersedes #33574
2022-01-27 22:06:39 +00:00
Karl Horky
5c6c385100
Use relative path for example (#33565)
The paths starting with slashes in the ESLint config examples are absolute, which are almost never the correct configuration for a project. Using a relative path is a much more common configuration, and leads to much less debugging why these examples don't work.

## 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-26 12:41:14 +00:00
Baoshuo Ren
72658c918a
fix(errors/no-cache): netlify-plugin-cache-nextjs has been deprecated (#33629) 2022-01-25 14:59:32 +01:00
Javi Velasco
e5dee17f77
Enforce absolute URLs in Edge Functions runtime (#33410)
We currently have inconsistencies when working with URLs in the Edge Functions runtime, this PR addresses them introducing a warning for inconsistent usage that will break in the future. Here is the reasoning.

### The Browser

When we are in a browser environment there is a fixed location stored at `globalThis.location`. Then, if one tries to build a request with a relative URL it will work using that location global hostname as _base_ to construct its URL. For example:

```typescript
// https://nextjs.org
new Request('/test').url; // https://nextjs.org/test
Response.redirect('/test').headers.get('Location'); // https://nextjs.org/test
```

However, if we attempt to run the same code from `about:blank` it would not work because the global to use as a base `String(globalThis.location)` is not a valid URL. Therefore a call to `Response.redirect('/test')` or `new Response('/test')` would fail.

### Edge Functions Runtime

In Next.js Edge Functions runtime the situation is slightly different from a browser. Say that we have a root middleware (`pages/_middleware`) that gets invoked for every page. In the middleware file we expose the handler function and also define a global variable that we mutate on every request:

```typescript
// pages/_middleware

let count = 0;

export function middleware(req: NextRequest) {
  console.log(req.url);
  count += 1;
}
```

Currently we cache the module scope in the runtime so subsequent invocations would hold the same globals and the module would not be evaluated again. This would make the counter to increment for each request that the middleware handles. It is for this reason that we **can't have a global location** that changes across different invocations. Each invocation of the same function uses the same global which also holds primitives like `URL` or `Request` so changing an hypothetical `globalThis.location` per request would affect concurrent requests being handled.

Then, it is not possible to use relative URLs in the same way the browser does because we don't have a global to rely on to use its host to compose a URL from a relative path.

### Why it works today

We are **not** validating what is provided to, for example, `NextResponse.rewrite()` nor `NextResponse.redirect()`. We simply create a `Response` instance that adds the corresponding header for the rewrite or the redirect. Then it is **the consumer** the one that composes the final destination based on the request. Theoretically you can pass any value and it would fail on redirect but won't validate the input.

Of course this is inconsistent because it doesn't make sense that `NextResponse.rewrite('/test')` works but `fetch(new NextRequest('/test'))` does not. Also we should validate what is provided. Finally, we want to be consistent with the way a browser behaves so `new Request('/test')` _should_ not work if there is no global location which we lack.

### What this PR does

We will have to deprecate the usage of relative URLs in the previously mentioned scenarios. In preparation for it, this PR adds a validation function in those places where it will break in the future, printing a warning with a link that points to a Next.js page with an explanation of the issue and ways to fix it.

Although middleware changes are not covered by semver, we will roll this for some time to make people aware that this change is coming. Then after a reasonable period of time we can remove the warning and make the code fail when using relative URLs in the previously exposed scenarios.
2022-01-19 15:10:25 +00:00
Mosaad
2518a5a4c7
docs: fix url (#33409) 2022-01-18 00:26:24 +01:00
Steven
7f6afa4a89
Update links in next export + next/image error message (#33317)
Minor changes to this error message to link to latest docs
2022-01-14 15:19:52 +00:00
Rich Haines
d291aa9134
Refactor data fetching API docs (#30615)
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-12 08:56:51 +01:00
JJ Kasper
57a87050e7
Add util for normalizing errors (#33159)
* JSON.stringify generic errors

* Add util for normalizing errors

* lint-fix

* Add better error for null case as well

Co-authored-by: Michael Ozeryansky <mozeryansky@users.noreply.github.com>
2022-01-11 14:40:03 -06:00
JJ Kasper
efabf81e23
Add util for generating new tests/error documents (#33001)
* Add util for generating new tests/error documents

* update compiled

* lint-fix

* apply suggestions

* update wording

* update compiled
2022-01-06 09:45:04 -06:00
Houssein Djirdeh
d72f5bd69d
[ESLint] Adds lint rule to flag usage of <head> (#32897)
## Bug

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

Fixes #30142
2021-12-31 05:09:44 +00:00
Chai
b562b902cb
fix: typo (#32820) 2021-12-26 13:08:19 +01:00
Gustavo Levano
2c709bb587
Fixed syntax error in the example of React Hydration Error (#32773)
## Documentation / Examples

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-12-23 19:25:11 +00:00
Hannes Bornö
802f4dcf5d
next-swc: styled-jsx error checking and reporting updated (invalid-styled-jsx-children.md) (#31940)
Co-authored-by: Hannes Lund <hannes.lund.2@consultant.volvo.com>
2021-12-20 16:17:37 +01:00
Artur Parkhisenko
37d1100825
Change using-preact example dependencies and docs (#30394)
* change use-preact dependencies

* change stackblitz url to use https protocol

* change deprecated thing from the webpack5 doc
2021-12-11 15:19:49 +01:00
Rich Haines
6274733fcb
Fix error page doc for no server import in page (#32164)
* Fix error page doc for no server import in page

* Feedback changes
2021-12-07 18:24:27 +01:00
Hannes Bornö
466687e88e
SWC: Add error checks and tests to next-dynamic (#31683)
fixes #31520

## 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`
2021-11-26 14:22:28 +00:00
Gerrit Alex
d38dd3d7e6
fix: support function components in _document in no-page-custom-font (#31560) 2021-11-26 14:27:13 +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
Thibaut SABOT
d1adf1d503
Add eslint rule to prevent importing next/server outside of _middleware (#30973)
* Add eslint rule to prevent importing next/server outside of _middleware

* add error to manifest.json

Co-authored-by: Javi Velasco <javier.velasco86@gmail.com>
2021-11-12 17:44:39 -06:00
Maia Teegarden
bc88831619
Add next-swc jest transform (#30993)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-11-08 17:35:04 +01:00
Steven
14841c9430
Fix incorrect _document.js error when disableStaticImages: true (#30768)
Fixes #30600
2021-11-02 20:25:12 +00:00
Erlend Åmdal
31f3d69332
Fix link to documentation from deprecated target config message (#30607)
The page links to itself, but was presumably meant to link to "Output File Tracing" under "Advanced Features".
2021-10-29 09:18:25 +00:00
JJ Kasper
59712b16c7
Add note about no-optional to swc error doc (#30566) 2021-10-28 14:04:20 -05:00
JJ Kasper
00c53d632c
Update SWC failed error with link to discussion (#30469)
Links the failed to load bindings error document to the new discussion here: https://github.com/vercel/next.js/discussions/30468

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2021-10-27 18:25:08 +00:00
Javi Velasco
c497b3a5ff
Improve deprecation errors for new middleware API (#30316)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2021-10-26 17:03:39 +02:00
Kara
f6c58cb83a
Warn when mutating res if not streaming (#30284)
In #29010, we started throwing an error if the res was mutated after
getServerSideProps() returned. This was to support classic streaming,
where it would be possible to accidentally mutate the response headers
after they were already sent. However, this change also caught [a few
non-streaming cases](https://github.com/vercel/next.js/pull/29010#issuecomment-943482743) that we don't want to break.

As such, with this change, we only throw the error if res is mutated
after gSSP returns *and* you've opted into using classic streaming.
Otherwise, we will only add a warning to the console.
2021-10-25 20:18:03 -05:00
JJ Kasper
a25c1dd15a
Add warning for large amount of page data (#29956)
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-10-25 21:07:05 +02:00
JJ Kasper
1a10ab8c39
Update error for failing to load SWC bindings (#30269) 2021-10-25 12:23:44 -05:00
Tim Neutkens
bc3ab3ce94
Move swcMinify out of experimental (#29810) 2021-10-25 13:49:11 +02:00
JJ Kasper
649b41704b
Add deprecation note for target (#30200)
* Add deprecation note for target

* Apply suggestions from code review

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

* Mention Vercel leverages the traces

Co-authored-by: Steven <steven@ceriously.com>
2021-10-24 10:38:24 -05:00
Tim Neutkens
08a7f7f31a
Enable SWC by default when there is no custom Babel config (#29811)
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
Co-authored-by: padmaia <padmaia@users.noreply.github.com>
2021-10-23 10:21:44 +02:00
Steven
ca65fd8f87
Change AVIF to opt-in via configuration (#30180)
AVIF (shown in purple) is generally slower to encode than WebP (shown in yellow) so it is probably not a good default for on-demand Image Optimization.

Instead, we'll let users opt-in via `formats` configuration.

![performance](https://user-images.githubusercontent.com/229881/138511198-b987d307-17c2-47c2-816f-766a43d77efd.png)
2021-10-22 21:08:03 +00:00
JJ Kasper
67681fe097
Replace middleware flag with warning (#30160)
Follow-up to https://github.com/vercel/next.js/pull/30154 this replaces the experimental flag with a warning that is shown once on usage instead.
2021-10-22 06:40:57 +00:00
Steven
6f3e9470a6
Ensure error message prints next.config.mjs (#30152)
This PR ensures we print the correct error message for either `next.config.js` or `next.config.mjs`, whichever was detected.
2021-10-21 23:04:40 +00:00
Thibaut SABOT
3b34626fc8
docs: remove mention of experimental pageDataCollectionTimeout (#30107)
Removing the mention of `experimental.pageDataCollectionTimeout` in the docs as it doesn't exist anymore.

Related discussion: https://github.com/vercel/next.js/discussions/29992
2021-10-20 19:35:32 +00:00
JJ Kasper
f068319d4d
Enable shared worker pool by default (#30110) 2021-10-20 14:06:43 -05:00
paul-creates
4bbe2651af
Update documentation to fix github cache key (#29983)
`?` is any optional character, it isn't the same as the `?` in regex which will match the preceding character 0 or more times.



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

- [x] Make sure the linting passes
2021-10-18 22:19:22 +00:00
Steven
0daaae32dc
Update docs for Prerender Error message (#30044)
Update docs to mention `undefined` doesn't work, use `null` instead
2021-10-18 20:49:34 +00:00
Steven
cc1f3b8a38
Add support for AVIF to next/image (#29683)
Add support for AVIF to `next/image`

- Fixes #27882 
- Closes #27432 

## Feature

- [x] Implements an existing feature request
- [x] Related issues linked
- [x] Integration tests added
- [x] Documentation added
- [x] Update manifest output
- [x] Warn when `sharp` is outdated
- [x] Errors & Warnings have helpful link attached
- [ ] Remove `image-size` in favor of `squoosh`/`sharp` (optional, need to benchmark)
2021-10-11 23:17:47 +00:00
Tim Neutkens
aa8a885599
Remove webpack 4 support (#29660)
Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
2021-10-06 17:40:01 +02:00
Thien Do
f0eb9283f0
Update invalid-getstaticpaths-value.md (#29397)
Add the `fallback: 'blocking'` option to "Invalid getStaticPaths Return Value" error
2021-09-26 07:13:13 -05:00
JJ Kasper
ead56eaab6
Fix invalid project dir casing breaking Next.js on Windows (#29205)
This fixes Next.js running into unexpected errors on Windows when invalid casing for a project directory is used. I was able to reproduce the issue on my local Windows machine and this resolved the issue there. 

<details>

<summary>screenshot of error while reproducing</summary>

<img width="838" alt="Screen Shot 2021-09-18 at 23 21 40" src="https://user-images.githubusercontent.com/22380829/133915825-ac4abdd2-fcf8-4309-9873-e6d88dfe485d.png">

</details>

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/27396
Fixes: https://github.com/vercel/next.js/issues/16535
Fixes: https://github.com/vercel/next.js/issues/17592
2021-09-22 21:29:27 +00:00
JJ Kasper
e66908412b
Ensure manifests check has correct exit code on fail (#29183) 2021-09-17 11:30:54 -05:00
Kara
41484f62cc
Throw error if res is accessed after gSSP returns (#29010)
* Throw error if res is accessed after gSSP returns

Currently it's possible to access the `ServerResponse` through `context.res`
in `getServerSideProps()`. If one was to store that response and mutate
its headers or status code after gSSP returns (e.g. during rendering), it
would currently happen to work because of when headers are sent. However,
this is an anti-pattern that relies an implementation detail of the framework
and shouldn't be allowed. This will be particularly important once Next.js
starts to support basic streaming (two-part flush: routing then data) because
then the headers will be sent as soon as gSSP returns, which explicitly breaks
this pattern.

With this commit, the framework now throws an error in development mode if
the ServerResponse is accessed after gSSP returns.

* fixup! Throw error if res is accessed after gSSP returns
2021-09-13 17:10:46 -05:00
Tim Neutkens
9572b30849
Deprecate webpack 4 support (#28840) 2021-09-13 09:18:04 +02:00
Konstantin Popov
93bac0f2b7
Fix minor typo in no-img-element.md (#29027)
Fix minor typo: 

image optimization -> Image Optimization
2021-09-12 00:39:43 +00:00
Ismail Ghallou
8921d9115b
chore(examples): switch to Script component on the google analytics example (#27674)
## Documentation / Examples

- [x] Make sure the linting passes

Fixes https://github.com/vercel/next.js/pull/27674
2021-09-08 21:03:23 +00:00
Perry Olsson
3b55a37c81
Webpack rule to block importing images into _document (#28475) 2021-09-06 13:41:18 +02:00
matamatanot
71771df6fa
Add error page path for next-script-for-ga (#28643)
## Documentation / Examples

- [x] Make sure the linting passes

**My console**

> src/pages/_document.tsx#L14
> Use the `next/script` component for loading third party scripts. See: https://nextjs.org/docs/messages/next-script-for-ga

https://nextjs.org/docs/messages/next-script-for-ga is 404 now.
2021-08-31 07:41:27 +00:00
JJ Kasper
ead10f1f81
Fix handling for 204 status code with a body (#28479)
This ensures we handle 204 and 304 status codes correctly in API routes.  

## 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/28464
2021-08-25 15:52:43 +00:00
Steven
cb6290adf3
Update docs for sharp usage to mention Vercel (#28476)
There was some confusion in [this tweet](https://twitter.com/mtliendo/status/1430269174459338759) so I revised the docs around `sharp` usage.
2021-08-24 22:51:28 +00:00
stefanprobst
da4203d032
Add eslint rule for id attribute on inline next/script (#27853)
This adds a new ESLint rule to `eslint-plugin-next` to check that `next/script` components with inline content have the required `id` attribute.

Also adjusted the code example for inline scripts in the `next/script` docs, which were actually missing an `id` attribute.
And also updated the `next/scripts` integration test to also have the required `id` attribute.

Unsure about the required heading levels in the errors .md document (other examples have h1 and h4??)

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-08-19 20:08:04 +00:00
Brody McKee
0d3fb75cb6
Add docs for ESLint plugin settings and rule options (#28059)
This PR adds documentation for the new `rootDir` setting (#27918), and for `next/no-html-link-for-pages`.

## Documentation / Examples

- [x] Make sure the linting passes
2021-08-19 09:07:30 +00:00
Jiachi Liu
7ea7c23866
Document usage of suspense option of next/dynamic (#28210)
## Documentation / Examples

- [x] Make sure the linting passes
- [x] Errors have helpful link attached, see `contributing.md` (for #28165, #27611)
- [x] Update test case
2021-08-18 01:21:22 +00:00
Rahul Gaba
da4d65252f
ESLint Plugin: Prefer next script component when using the inline script for Google Analytics. (#25147)
* Add a lint rule for using next script component when using inline script for Google Analytics.

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>

* Update errors/next-script-for-ga.md

Co-authored-by: JJ Kasper <jj@jjsweb.site>

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-08-16 13:55:07 -05:00
JJ Kasper
039735350c
Add proper error when failing to load next.config.js (#28099)
This adds a proper error when we fail to load a user's `next.config.js` as the default node error can be confusing on its own and makes it seem like something failed internally in Next.js. We can expand on the included error doc added and potentially also add better syntax errors by parsing with acorn when we fail to load this file in the future. 

<details>

<summary>screenshot</summary>

<img width="962" alt="Screen Shot 2021-08-13 at 21 46 09" src="https://user-images.githubusercontent.com/22380829/129432211-6d858062-eea0-4bb9-8725-5bde98bdc47b.png">

</details>
2021-08-14 13:52:18 +00:00
Jesse Jafa
a28e775e88
[ESLint] Disallow <Script /> inside _document.js & <Script /> inside the next/head component (#27257)
## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. [Feature Request](https://github.com/vercel/next.js/discussions/26365)
- [x] Eslint unit ests added
- [x] Errors have helpful link attached, see `contributing.md`

Let me know if this looks good or something needs to be changed. I still need to add the error links and improve the eslint error messages.

I don't know if the CI runs the ESLint tests, but current all pass locally
2021-08-13 23:16:15 +00:00
Tobias Koppers
8bbb1cd353
use a shared worker pool for collecting page data and static page generation (#27924)
this avoid loading all code twice and hopefully improving performance
2021-08-12 19:54:49 +00:00
JJ Kasper
f56a1505c2
Fix incorrect error manifest path (#27970) 2021-08-11 12:07:09 -05:00
JJ Kasper
e61ea6f27b
Add manifest check step and add missing items (#27934) 2021-08-11 11:17:57 +02:00
Tim Neutkens
331fed89f3
Add Import trace for requested module when it fails to resolve (#27840)
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-08-09 14:38:26 +02:00
JJ Kasper
5eaca0ffe5
Document i18n locale limit (#27542)
Add check for i18n locale count and ensure the limit is documented

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-27 20:09:36 +00:00
Luís Galete
57501fa745
Fix typo in placeholder-blur-data-url error docs (#27510)
2021-07-26 17:04:47 +00:00
brijendravarma
74b159c850
Updated the Error message describing the alternative and added styles… (#14652)
The error message indicates better alternatives and added styles.css sample snippet for good visibility.

![Global_error_msg](https://user-images.githubusercontent.com/38159218/85950309-ac3bc100-b979-11ea-9a8d-4a356cb8007c.JPG)
![CSS-Global](https://user-images.githubusercontent.com/38159218/85950319-b2ca3880-b979-11ea-829a-24335fcfc93d.JPG)
2021-07-25 04:53:33 +00:00
Steven
1d347ba5dc
Fix typo in error message (#27438)
Fixes typo mentioned in https://github.com/vercel/next.js/pull/27346#discussion_r675477904
2021-07-23 14:07:09 +00:00
Alex Castle
1b733423d6
Use Sharp if available for Image Optimization (#27346)
* Use sharp for image transformations when available

* Refactor resizeImage and add sharp warning

* only show sharp warning once per instance

* Modify sharp error message

* Add documentation for optional sharp dependency

* Update docs/basic-features/image-optimization.md

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

* Import types for sharp

* Update lockfile

* Add testing against sharp

* use fs-extra for node 12

* Rename test sharp path variable

* Apply suggestions from code review

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

* update squoosh specific test

* Apply suggestions from code review

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

* update tests

* Apply suggestions from code review

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

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-22 18:11:17 -05:00
Rodrigo Roim
a3b2205b42
[errors/no-cache] Prevent GitHub Actions cache from going stale (#27362)
Closes: https://github.com/vercel/next.js/issues/27129

This configuration is similar to what we've been using at Statsig, and it's the best general purpose config I could think of.

At Statsig we also invalidate our caches weekly, since sometimes we spend weeks without updating dependencies for some of our NextJS apps, and the artifact bloat means GitHub starts invalidating other caches in our repo. I could add that step to this diff as well, but I think that's a bit too specific (likely only a problem in monorepos with several caches). In any case, the previous example also has this problem.

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-22 03:12:39 +00:00
Josh Flayhart
ddef873b3b
Update next-image-unconfigured-host.md (#24953)
* Update next-image-unconfigured-host.md

the docs are misleading because I tried this and still got yelled at by compiler, and then added domains and it worked?

* Update next-image-unconfigured-host.md

* Update next-image-unconfigured-host.md

* Update next-image-unconfigured-host.md

* Update next-image-unconfigured-host.md

* Update next-image-unconfigured-host.md

* Update next-image-unconfigured-host.md

* remove unrelated section

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-19 19:40:52 -05:00
JJ Kasper
14dd7c2954
Add warning for large number of routes (#27214)
This adds a warning when more than 1024 routes are added since it can have performance impacts and includes a document that we can add suggestions to reduce the number of routes being added. 

## 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
2021-07-16 14:59:54 +00:00
Tobias Koppers
f9795fdd26
improve static generation UX (#27171)
#### improve export spinner

update at least once a minute in non-tty
update progress regularly when using the spinner
decrease frequency of the spinner (windows console output is expensive)

#### restart static page generation and collecting page data worker pools when hanging

when for 1 minute no activity happens on the worker pool, restart it
log a warning for hanging jobs

#### add page generation duration to summary tree

![image](https://user-images.githubusercontent.com/1365881/125750454-8845f1b1-faf0-4598-b7a4-ea796b884691.png)

for `[+n more pages]` is will show `(avg 321 ms)` when the average is over the threshold.
It will allocate 8 lines for preview pages (instead of 4) when they contain slow pages

## 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.
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-16 09:21:44 +00:00
Steven
8151a7e0dc
Add minimumCacheTTL config for Image Optimization (#27200)
- Closes #23328  
- Related to #19914 
- Related to #22319 


## 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
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`
2021-07-15 19:55:12 +00:00
Houssein Djirdeh
c46b405ba7
adds no duplicate head rule (#27179) 2021-07-15 13:04:17 -05:00
Tobias Koppers
7a8da9741d
add support for esm externals (#27069)
add `experimental.esmExternals: boolean | 'loose'` config option

remove `output.environment` configuration in favor of `target`

|                          | `esmExternals: false` (default) | `esmExternals: 'loose'` | `esmExternals: true` |
| ------------------------ | ------------------------------- | ----------------------- | -------------------- |
| import cjs package       | `require()`                     | `require()`             | `require()`          |
| require cjs package      | `require()`                     | `require()`             | `require()`          |
| import mixed package     | `require()` ***                 | `import()`              | `import()`           |
| require mixed package    | `require()`                     | `require()`             | `require()`          |
| import pure esm package  | `import()`                      | `import()`              | `import()`           |
| require pure esm package | Error **                        | `import()` *            | Error **             |
| import pure cjs package  | `require()`                     | `require()`             | Resolving error      |
| require pure cjs package | `require()`                     | `require()`             | `require()`          |

cjs package: Offers only CJS implementation (may not even have an `exports` field)
mixed package: Offers CJS and ESM implementation via `exports` field
pure esm package: Only offers an ESM implementation (may not even have an `exports` field)
pure cjs package: CommonJs package that prevents importing via `exports` field when `import` is used.

`*` This case will behave a bit unexpected for now, since `require` will return a Promise. So that need to be awaited. This will be fixed once the whole next.js bundle is ESM. It didn't work at all before this PR.
`**` This is a new Error when trying to require an esm package.
`***` For mixed packages we prefer the CommonJS variant to avoid a breaking change.

## 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.
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-10 16:49:02 +00:00
Steven
1a8ad14089
Rename next/image dangerously-unoptimized to custom and warn when applicable (#26998)
Since we are no longer accepting new built-in loaders, users may wish to use a different cloud provider.

So this PR renames `dangerously-unoptimized` to `custom` to handle this case as well as the intention of `next export`.

If the user doesn't add a `loader` prop, we throw an error.
If the user adds a `loader` prop but it doesn't return the width, we print a warning.

- Follow up to #26847 
- Fixes #21079 
- Fixes #19612 
- Related to #26850
2021-07-08 19:35:19 +00:00
Maia Teegarden
b8f3a6d2d9
5MB -> 4MB body size limit (#26887)
This decreases the body size limit that triggers a warning from 5MB -> 4MB, which provides a little more wiggle room. Certain things like using base64 on body, headers, path, etc can cause the response to be larger than initially calculated. 

Initial PR: https://github.com/vercel/next.js/pull/26831
2021-07-02 23:17:56 +00:00
Maia Teegarden
538095c936
Warn when response body is larger than 5mb (#26831)
This PR adds a warning when api responses exceed 5mb since this will end up failing once deployed. In a future version this scenario will throw an error.

## Bug

- [x] Integration tests added

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-02 19:27:33 +00:00
hiro
bdd1d85813
Fix typo on "occured" to "occurred" (#26876)
- Fix typo on "occured" to "occurred"
2021-07-02 16:06:50 +00:00
Tim Neutkens
59c742ee7f
Add instructions on how to add nextjs.org/docs/messages urls (#26865)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-07-02 13:39:00 +02:00
Peter Mekhaeil
94d7450a6e
chore: Enable Alex documentation linting for error pages (#26526) 2021-06-23 23:33:58 -05:00
Duc Le
4f3674cc37
Correct the word "remove" (#26258) 2021-06-17 13:47:02 +02:00
Vadorequest
75016716dc
Doc "no-sync-scripts" remove experimental notice (#26225)
It's not experimental anymore.




## Documentation / Examples

- [ ] Make sure the linting passes
2021-06-17 08:19:26 +00:00
Ivan Kalinin
c851da25f4
Fixed no-img-element documentation snippet. (#26154)
Module "next/image" has no exported member 'Image'.
It must be `import Image from "next/image"`
2021-06-16 08:57:45 +02:00
JJ Kasper
225b784393
Ensure all errors are added in manifest (#26129)
* Ensure all errors are added in manifest

* Add script doc to manifest
2021-06-15 13:36:25 -05:00
Gerald Monaco
775c7be517
Update react-version.md (#26093)
Forgot to update this in a previous PR.
2021-06-14 20:24:36 +00:00
Tim Neutkens
de08b1fff1
Remove unsupported examples (#26075)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-14 20:27:06 +02:00
JJ Kasper
1628e6d16c
Update client-side default error (#25997)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-06-11 16:23:45 +02:00
Steven
d8b59f3e46
Add errors for invalid placeholder=blur usage (#25953)
There are strict conditions for using `placeholder=blur` documented in #25949 but this will give the user a better understanding during `next dev` and links to the error.

- Error when `placeholder=blur` and no `blurDataURL`
- The Error for small images with `placeholder=blur` has been changed to a warning
- Added support for blurring a webp image
- Added error page linking to relevant docs
2021-06-10 18:51:35 +00:00
John Jago
c6ba29da00
docs: use descriptive links instead of "click here" (#25897)
* docs: use descriptive links instead of "click here"

Linking text such as "here" or "click here" is not accessible (and
doesn't look that great either). The best example of why it's better to
use link text that provides context is that some screen readers allow
navigation by links alone. If all links say "click here", then how does
the user know which one to go to?

I tried to make the minimal change necessary to make the link text
descriptive but had to reword a few sentences that didn't read well.

* Apply suggestions from code review

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-09 13:23:16 -05:00
Tim Neutkens
e1502bc9a5
Enable webpack5 for all apps (#25639)
* Enable webpack 5 by default for all apps

Still provides a way to opt-out using `webpack5: false` in next.config.js. Also throws an error for `future.webpack5`.

* Update tests

* Update test to run on webpack 4 instead of webpack 5

* disable webpack5 for legacy tests

* Fix stats-config for webpack4

* update tests

* update size for webpack4 test

* move basic suite first

* update basic test

* Add logs

* remove outdated testFutureDependencies job

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-07 15:48:29 -05:00
Houssein Djirdeh
8ae12db1e3
ESLint Plugin: Fix Document and Head import rules (#25730) 2021-06-07 12:40:28 +02:00
Tim Neutkens
9890565983
Add helpful error for link with multiple children (#25657)
Makes sure a helpful error is shown for `<Link>` with multiple children



## Bug

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

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-05-31 19:41:57 +00:00
Houssein Djirdeh
7426ebcbc3
ESLint Plugin: Image rules (#23402)
Adds a new image rule to `eslint-plugin-next`:

```
Do not use `<img>`. Use Image from `next/image` instead
```
2021-05-17 13:06:48 +00:00
Janicklas Ralph
7b0fe0d73b
Fix no-sync-scripts doc (#25062)
## Bug

Fix no-sync-scripts doc
2021-05-13 10:08:07 +00:00
Alessandro Ursino
2f142b622f
fix typo in path (#24978) 2021-05-11 13:05:03 +02:00
Houssein Djirdeh
6d0150f02e
ESLint Plugin: Prevent bad imports of next/document and next/head (#24832)
Adds lint rules to the Next.js ESLint plugin to:

- Disallow importing `next/head` inside `pages/_document.js`
- Disallow importing `next/document` outside of `pages/_document.js`

Both rules will be surfaced as **errors** within the recommended config of the plugin.

Fixes #13712 #13958
2021-05-10 21:28:06 +00:00
Houssein Djirdeh
44072205d8
ESLint Plugin: Custom Font at page-level rule (#24789)
Adds a lint rule warning to the Next.js ESLint plugin if a custom Google Font is added at page-level instead of with a custom document (`.document.js`)

_Note: This will be generalized to include more font providers in the near future._
2021-05-10 19:08:14 +00:00
Houssein Djirdeh
569da9d286
ESLint Plugin: passHref is not assigned (#24670)
Adds a lint rule warning to the Next.js ESLint plugin if `passHref=true` is not assigned for `<Link>` wrapping a custom component.

Fixes #23713
2021-05-10 18:35:11 +00:00
Houssein Djirdeh
59d50ff76d
ESLint Plugin: Google Font rules (#24766) 2021-05-10 10:03:28 +02:00
Houssein Djirdeh
656c2ef649
ESLint Plugin: Disallow <title> in Head from next/document (#24868)
Adds lint rule warning to the Next.js ESLint plugin to disallow `<title>` in `Head` imported from `next/document`.
2021-05-07 08:49:37 +00:00
Anthony Oyathelemhi
467ec2115c
Add additional reason for the Prerender Error when running next export (#24828)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-06 14:51:53 +02:00
Houssein Djirdeh
e783b0a2e8
Adds ESLint with default rule-set (#23702)
This PR re-includes ESLint with some notable changes, namely a guided setup similar to how TypeScript is instantiated in a Next.js application.

To add ESLint to a project, developers will have to create an `.eslintrc` file in the root of their project or add an empty `eslintConfig` object to their `package.json` file.

```js
touch .eslintrc
```

Then running `next build` will show instructions to install the required packages needed:

<img width="862" alt="Screen Shot 2021-04-19 at 7 38 27 PM" src="https://user-images.githubusercontent.com/12476932/115316182-dfd51b00-a146-11eb-830c-90bad20ed151.png">

Once installed and `next build` is run again, `.eslintrc` will be automatically configured to include the default config:

```json
{
  "extends": "next"
}
```

In addition to this change:

- The feature is now under the experimental flag and requires opt-in. After testing and feedback, it will be switched to the top-level namespace and turned on by default.
- A new ESLint shareable configuration package is included that can be extended in any application with `{ extends: 'next' }`
  - This default config extends recommended rule sets from [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), and [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next)
- All rules in [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next) have been modified to include actionable links that show more information to help resolve each issue
2021-04-30 11:09:07 +00:00
tarunama
7fd5a24d94
feat: add type to previewData (#21574)
`previewData` was already [typed declare variable](https://github.com/vercel/next.js/compare/canary...tarunama:feature/remove-any1?expand=1#diff-bd7baf53ff559d84461af8b2fd62cade7e2d8eb203f489e24a27c5b83a79a9d3L1380).
So I have defined `PreviewData` type, and adapt for avoiding error by type safe.
2021-04-20 18:13:48 +00:00
Gergo Tolnai
997b37ace3
Docs: add info about fallback to prerender-error (#22828) 2021-04-20 08:15:02 +00:00
JJ Kasper
6e7245cddb
Add error for getStaticPaths on non-dynamic page (#24188)
Noticed in this issue the reproduction was using `getStaticPaths` on a non-dynamic page incorrectly although we don't currently show an error for this. 

## Bug

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

x-ref: https://github.com/vercel/next.js/issues/22931
2021-04-18 09:31:40 +00:00
Tim Neutkens
92e14f8d60
Update webpack5.md 2021-03-29 15:22:05 +02:00
Tim Neutkens
7da0f9c4cf
Update manifest.json 2021-03-29 15:16:10 +02:00
Tim Neutkens
46fa9b6421
Temporarily remove the automatic opt-in for webpack5 (#23497) 2021-03-29 13:42:04 +02:00
Tim Neutkens
7ecf24489a
Update static-dir-deprecated.md 2021-03-23 14:45:36 +01:00
Tim Neutkens
e52a224c21
Add manifest of error pages (#23310)
## Bug

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

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

## Documentation / Examples

- [x] Make sure the linting passes
2021-03-23 12:53:17 +00:00
Lee Robinson
a63c64a02d
Update error message for next export and next/image. (#23061) 2021-03-15 13:01:12 -05:00
Chris Meagher
bdc20c2657
Add Azure Pipelines example to no-cache docs (#22708)
I added this in to my own pipeline to fix the no-cache error and thought it may be of use to others.
2021-03-03 09:47:19 +00:00
Azeez Lukman
00d453d74b
expanded on No Router Instance (#21248)
Added more detailed explanation of why there is no router instance, and other ways to fix the error
2021-01-26 10:27:53 +00:00
Tobias Koppers
9c4d368459
use webpack resolve api to resolve in externals config (#21205) 2021-01-17 20:02:20 +01:00
Gerald Monaco
cd5ea7db1f
Bump minimum suggested React version (#21046)
* Upgrade React version warning

* Fix font/stylesheet plugin

* Fix size-limit tests

* Fix build-output test

* Add tests for React 16

* Fix react-dom version
2021-01-14 22:29:57 -05:00
Lee Robinson
dc87a8436b
Update redirected or broken Vercel docs links. (#21119) 2021-01-14 15:37:21 +00:00
JJ Kasper
9caca2784c
Add proper error when conflicting paths are detected (#20918)
This helps catch conflicting paths returned from `getStaticPaths` with a friendly error

<details>

<summary>
Preview of error
</summary>


<img width="962" alt="Screen Shot 2021-01-08 at 5 03 04 PM" src="https://user-images.githubusercontent.com/22380829/104074719-6e481100-51d6-11eb-9397-938aee3ae30b.png">
<img width="962" alt="Screen Shot 2021-01-08 at 5 03 41 PM" src="https://user-images.githubusercontent.com/22380829/104074722-6f793e00-51d6-11eb-90f6-7cdf9882bf00.png">

</details>




Closes: https://github.com/vercel/next.js/issues/19527
2021-01-11 20:50:17 +00:00
Tim Neutkens
4dc077956d
Error when exporting to static directory (#20969)
Fixes #20408
Fixes #20925
2021-01-11 13:34:58 +00:00
Luc Leray
b442acbe1c
Replace zeit/next.js with vercel/next.js (#20849) 2021-01-07 08:41:04 -05:00
Jeremy Balog
bb05e42698
Fix typo in error markdown (#20825) 2021-01-07 10:22:43 +01:00
JJ Kasper
8b803d79a9
Update error when internal href and external as are used (#20658)
* Update error when internal href and external as are used

* Update to handle error outside invariant

* Update err.sh components
2021-01-01 12:14:42 -06:00
JJ Kasper
c93c9fcc78
Add error for invalid webpack 5 version (#20558)
Closes: https://github.com/vercel/next.js/issues/20545
2020-12-29 04:43:57 +00:00
Tim Neutkens
c792317295
Clear up production build missing message for next start and next export (#19777)
Adds an err.sh link to the production build missing message. Also clears up `valid` as `production`.

Also fixes an edge case where an unhelpful error would be thrown because we checked for `.next` instead of `.next/BUILD_ID`

Added the out directory location as the list line during export to make sure people know where the files are output. 

Fixes #19778
Fixes #19788
2020-12-08 15:16:56 +00:00
Jeff Escalante
b86a1731e1
Error Message Clarity (#16052)
* make the error message more clear if webpack config comes back undefined

* Update check and add test

* bump

* Update build-output test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-12-01 15:58:52 -06:00
Laurent Meyer
6095119970
Typo (#19475) 2020-11-24 14:21:32 +00:00
JJ Kasper
9f6d5b14df
Add test and errsh for mixed notFound/redirect error (#19076)
This ensures the mixed `notFound`/`redirect` error is shown correctly and adds an err.sh for the error. 

Closes: https://github.com/vercel/next.js/issues/18727
2020-11-11 22:02:11 +00:00
Steven
917d594ca8
Print error during next export with default image loader (#19032)
Fixes #18356
2020-11-11 15:46:48 +00:00
Gerald Monaco
80671273ca
Revert "Remove next-head-count (#16758)" (#18713)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-11-10 16:35:47 -05:00
Steven
2b94b1eea6
Update default widths configuration to handle 2x/3x DPI (#18717)
- Update default `deviceSizes`
- Add default `imageSizes`
- Use `layout` value to determine which `srcset` to use

Fixes #18420 
Closes #18714
2020-11-03 02:12:46 +00:00
Lukáš Huvar
a6759c62ad
docs: fix missing comma in invalid redirect gssp (#18580)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-10-31 23:37:06 -04:00
Steven
b7daae418b
Update install-sharp.md (#18508)
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
2020-10-30 10:56:11 -04:00
JJ Kasper
8b4d6246f3
Add err.sh for i18n config errors (#18425)
This adds an err.sh with info that can help when tracking down errors from invalid i18n config in next.config.js
2020-10-29 03:48:24 +00:00
JJ Kasper
e20dba2cf0
Add err.sh for image config errors (#18424)
* Add err.sh for image config errors

* Apply suggestions from code review

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

Co-authored-by: Steven <steven@ceriously.com>
2020-10-28 20:53:58 -05:00
JJ Kasper
27f56eb325
Add err.sh for missing images domain (#18325)
* Add err.sh for missing images domain

* Apply suggestions from code review

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

* Update test

Co-authored-by: Steven <steven@ceriously.com>
2020-10-27 16:55:21 -05:00
Steven
80bf81a3cf
Move sharp to optionalDependencies (#18068)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-10-21 12:21:42 +02:00
Steven
d3741d5ec5
Add support for Image Optimizer (#17749)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-10-16 13:10:01 +02:00
JJ Kasper
782b7e48ec
Add warning when exporting with custom routes (#17538)
This adds a warning when `next export` and custom routes are defined  outside of a platform that supports them since they won't be applied anymore.
2020-10-05 07:11:06 +00:00
Joe Haddad
c6ff918777
Update no-document-viewport-meta.md 2020-09-21 21:31:51 -04:00
Sam Dornan
0c4022e419
Fix invalid href error message (#17183) 2020-09-18 15:50:02 +00:00
Joe Haddad
9adf3bb637
Improve Document Component Error (#17047) 2020-09-12 13:39:16 -04:00
JJ Kasper
47d983f71f
Add error when href interpolation fails (#16946)
This adds an error when interpolation fails to make sure invalid `href`s aren't accidentally used and an invalid URL is built. 

Closes: https://github.com/vercel/next.js/issues/16944
2020-09-10 20:05:02 +00:00
Gerald Monaco
039eb817e1
Remove next-head-count (#16758)
Removes `next-head-count`, improving support for 3rd party libraries that insert or append new elements to `<head>`.

---

This is more or less what a solution with a `data-` attribute would look like, except that instead of directly searching for elements with that attribute, we serialize the elements expected in `<head>` and then find them/assume ownership of them during initialization (in a manner similar to React's reconciliation) based on their properties.

There are two main assumptions here:
1. Content is served with compression, so duplicate serialization of e.g. inline script or style tags doesn't have a meaningful impact. Storing a hash would be a potential optimization.
2. 3rd party libraries primarily only insert new, unique elements to head. Libraries trying to actively manage elements that overlap with those that Next.js claims ownership of will still be unsupported.

The reason for this roundabout approach is that I'd really like to avoid `data-` if possible, for maximum compatibility. Implicitly adding an attribute could be a breaking change for some class of tools or crawlers and makes it otherwise impossible to insert raw HTML into `<head>`. Adding an unexpected attribute is why the original `class="next-head"` approach was problematic in the first place!

That said, while I don't expect this to be more problematic than `next-head-count` (anything that would break in this new model also should have broken in the old model), if that does end up being the case, it might make sense to just bite the bullet.

Fixes #11012
Closes #16707

---

cc @Timer @timneutkens
2020-09-09 01:41:04 +00:00
JJ Kasper
bc80fb4fb2
Add handling for redirects from getStaticProps/getServerSideProps (#16642)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-09-08 09:23:21 +02:00
JJ Kasper
a7550bf1d7
Add error when document component isn't rendered (#16459)
If a custom `_document` is added but not all of the expected document components are rendered it can cause unintended errors as noticed in https://github.com/vercel/next.js/issues/10219 so this adds detecting when one of the expected document components isn't rendered and shows an error. 

Closes: https://github.com/vercel/next.js/issues/10219
2020-08-24 02:42:51 +00:00
Joe Haddad
fc98c13a2e
Warn on duplicate Sass deps (#16398)
Fixes #13953
2020-08-20 16:05:29 +00:00
Kevin Mårtensson
aa4b87e357
Handle cases where config is exported after its declaration (#16211)
AMP will still not work correctly when switching between non-AMP and AMP pages in development mode because of https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/plugins/next-page-config.ts#L116-L120.

Fixes #15704.
2020-08-17 17:24:18 +00:00
Joe Haddad
882288b532
Warn when Fast Refresh is disabled (React <16.10) (#15931) 2020-08-06 10:41:11 -04:00
matamatanot
2c424446b8
fix typo in export-all-in-page (#15925) 2020-08-06 00:11:11 +00:00
Joris
0fd1958ae4
Disallow re-export all exports from Next.js pages (#14325)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-08-05 16:21:40 -04:00
Jan Potoms
92304404a4
Disallow basePath: false for internal routes (#15837) 2020-08-04 17:50:09 +00:00
Jan Potoms
ad5c736798
Remove unused error (#15748)
Irrelevant since https://github.com/vercel/next.js/pull/15379
2020-07-31 17:29:09 +00:00
Joe Haddad
63e66ef0b0
Update gssp-export Error (#15529)
This pull request updates the `gssp-export` error for clarity.

Fixes #15527
2020-07-27 18:47:00 +00:00
Jan Potoms
e4e3ad38fd
Upgrade actions/cache to v2.1.0 (#15415) 2020-07-23 00:06:50 -04:00
Necmettin Karakaya
c2f38f2af0
[Fix] common misspelling errors (#15288)
For reference: https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-07-19 04:38:20 +00:00
Ashik Paul
4af7f6c7f5
Fixed a minor typo (#15077) 2020-07-12 18:28:24 +00:00
George Arthur
9d1d9c5235
Update prerender-error.md (#14875)
This is to further give more insight on one of the ways to fix prerendering errors especially with dynamic pages.
2020-07-10 19:01:17 +00:00
Eric Goerens
48aeb9fc4e
fixed typo in page-without-valid-component.md (#15022) 2020-07-10 18:44:17 +00:00
Ty Mick
1f5bbb3a8c
Add warning when viewport meta tag is added to _document.js (#13452)
Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-07 01:43:16 -04:00
Yang Sun
a8d2c1ee95
modify global css import error message (#14639)
Fixes #14464
2020-06-30 05:25:02 +00:00
JJ Kasper
61b68730f8
De-experimentalize custom-routes (#14602)
This moves the custom-routes configs outside of the experimental section to prepare them for being made stable

Fixes: https://github.com/vercel/next.js/issues/14184
2020-06-27 09:18:18 +00:00
James Mosier
435bf65784
Warn/revert custom devtool in development mode (#14285)
Warn users and revert their `devtool` when they manually change the `devtool` in development mode. For this addition, I check to ensure the `devtool` is custom (i.e. different than what is set by Next) and has a value (`false` is fine as a custom `devtool`!).

As described in [this issue (13963)](https://github.com/vercel/next.js/issues/13963), changing the `devtool` in development mode can cause issues with performance.

Fixes #13963
2020-06-24 04:15:57 +00:00
stefanprobst
279ae19c7e
docs: update links to docs site (#14305)
this updates some links to the docs site to their new location
2020-06-18 09:54:07 +00:00
Timothy
d1c16124b5
Update instances of Now to Vercel where applicable (#13760)
This pull request renames various instances of `now` to `vercel` etc. in order to match content that's being updated on the Vercel platform.
2020-06-04 14:57:17 +00:00
Todor Totev
bad376127e
Detailed error and warnings upon next() call (#13539)
**First, apologies for a second PR on the same issue but I was working on this already so I thought I'd push it and let you decide which you want to merge.**

The PR is related to [13466](https://github.com/vercel/next.js/issues/13466).

Based on my research, the error happens if the options are empty, null, or undefined. That's why I have decided that the most proper check would be using the! post-fix expression operator may assert that its operand is non-null and non-undefined. ``if (options == null)``

(Optional)
I have also added a warning, which warns the user if the passed "dev" variable is not a boolean.

It's my first PR on the "packages" part of the repo so I'd be glad to receive all kinds of critics. If you want me to change or remove anything, I'm open to suggestions.

---

Fixes #13466
2020-06-03 03:19:29 +00:00
Joe Haddad
aab1fff861
Better NODE_ENV explanation (#13476)
After #12361, I've seen a few users ask "but why".

This PR updates the err.sh link to better explain the restriction.

It also provides an alternative!
2020-05-28 09:10:22 +00:00
Joe Haddad
b7e17e09e5
Update references to zeit/next.js (#13463) 2020-05-27 17:51:11 -04:00
Karl Horky
6ca00bfe31
Remove beta label from Netlify Plugins (#13465)
Netlify Plugins are out of beta!

https://www.netlify.com/blog/2020/05/27/netlify-build-plugins-are-here/
2020-05-27 20:30:39 +00:00
JJ Kasper
e2619359ec
Add warning when reserved pages are nested (#13449)
This adds a warning when a user has nested a reserved page `_error`, `_app`, or `_document` in their pages directory since it causes it to not be picked up and used by Next.js in the expected way

x-ref: https://github.com/zeit/next.js/pull/13425

<details>
<summary>Example of warning</summary>

<img width="927" alt="Screen Shot 2020-05-27 at 10 39 09" src="https://user-images.githubusercontent.com/22380829/83042315-24276c00-a007-11ea-9dc4-cabcc93571d2.png">
</details>
2020-05-27 16:45:53 +00:00
JJ Kasper
ef422467dc
Add error when exporting pages with fallback: true (#13063) 2020-05-19 09:29:34 -04:00
Joe Haddad
86160a5190
Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
Tim Neutkens
313b552026
Enable .env support by default (#12911)
* Enable .env support by default

Given we've had tons of reports from various people that expected .env support to work even though they had dotenv installed already I think it's fine to enable it as a default:

Fixes #12728

* Remove old test

* Fix duplicate env loading

* Update docs

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-05-15 14:02:16 -05:00
JJ Kasper
6972a09f43
Add message when automatic dotenv loading is disabled (#12744) 2020-05-11 16:32:33 -04:00
JJ Kasper
467b65a889
Add note about HoC possibly adding GIP to _app (#12491) 2020-05-05 00:11:25 -04:00
JJ Kasper
3af0fe5cf2
Add warning for non-standard NODE_ENV value (#12361) 2020-05-04 11:21:58 -05:00
Karl Horky
ed66d14ddd
Document persisting cache with Netlify Plugin (#12242) 2020-05-02 00:24:57 -04:00
Tim Neutkens
483bd3ddda
Rename ZEIT to Vercel (#12075)
* Find/replace

* Update more URLs

* More rename

* Fix remaining examples

* More updates

* Update create-next-app

* Update remaining text

* Update

Co-authored-by: Shu Uesugi <shu@chibicode.com>
2020-04-21 11:47:12 +02:00
Bhaskar Murthy
b6f44e66f8
Add Heroku to list of cache examples (#12037) 2020-04-20 10:09:38 +02:00
JJ Kasper
20c7b5c50d
Add initial process.env stubbing for new env support (#11893)
* Add initial process.env stubbing for new env support

* Fix server process.env being stubbed in production

* bump

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-15 02:42:37 -04:00
JJ Kasper
0648c35508
Update auto export opt-out warning and err.sh (#11801) 2020-04-10 12:31:19 +02:00
Joey Tepperman
cdc7f01954
Add warning when a page is rendered without a starting / (#11418)
* Add error/warning when a page is rendered without a /

Throws an error for development and gives a warning in production

* Add tests for error when rendering without starting slash

* Update to always warn and add err.sh

* Update errors/render-no-starting-slash.md

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-04-06 11:54:42 -05:00
JJ Kasper
1cdc607968
Warn when user has pages/_error but no pages/404 (#11603)
* Warn when user has pages/_error but no pages/404

* Update test

* Update custom-error-no-custom-404.md

* Apply suggestions from code review

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-04-05 13:19:14 +02:00
JJ Kasper
7f8f149f99
Add error when GSSP methods are added as page component members (#11645) 2020-04-03 19:08:17 -04:00
Jan Piotrowski
845f2a98fb
make providers headlines so they become linkable (#11613)
(hopefully)
2020-04-03 09:51:46 +02:00
JJ Kasper
d8155b22ff
Add initial support for new env handling (#10525)
* Add initial support for new env config file

* Fix serverless processEnv call when no env is provided

* Add missing await for test method

* Update env config to .env.json and add dotenv loading

* ncc dotenv package

* Update type

* Update with new discussed behavior removing .env.json

* Update hot-reloader createEntrypoints

* Make sure .env is loaded before next.config.js

* Add tests for all separate .env files

* Remove comments

* Add override tests

* Add test for overriding env vars based on local environment

* Add support for .env.test

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

* Use chalk for env loaded message

* Remove constant as it’s not needed

* Update test

* Update errsh, taskr, and CNA template ignores

* Make sure to only consider undefined missing

* Remove old .env ignore

* Update to not populate process.env with loaded env

* Add experimental flag and add loading of global env values

Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-03-26 13:32:41 +01:00
JJ Kasper
eeea53c04b
Fix warning for API routes with next export (#11330)
* Fix warning for API routes with next export

* Update warning copy
2020-03-24 13:38:22 -04:00
JJ Kasper
203f43c1fe
Add error when attempting to export GSSP page (#11154)
* Add error when attempting to export GSSP page

* Update errors/gssp-export.md

* Update errors/gssp-export.md

* Update errors/gssp-export.md

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-03-18 09:33:10 +01:00
Joe Haddad
9d9f7a5873
Improve Sass Error (#10982)
* Improve Sass Error

* test sass error massage

* use quotes

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-03-11 16:34:14 -04:00
JJ Kasper
fde1ce2924
Add warning when built-in CSS/SCSS support is disabled (#10942) 2020-03-10 14:29:40 -04:00
Shu Uesugi
c52c0389fd
Add params to getStaticProps on err.sh (#10751)
* Add params to getStaticProps

* Update errors/invalid-getstaticprops-value.md

Co-Authored-By: JJ Kasper <jj@jjsweb.site>

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-03-01 15:20:28 +01:00
JJ Kasper
c9d9f1131c
Remove unstable_ prefix from new methods (#10723)
* Rename getServerProps to getServerSideProps

* Remove unstable_ prefix from new methods

* Add error when legacy methods are detected

* Add legacy methods for babel transform

* Add unstable_getServerSideProps also

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

* Update types import

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-27 11:57:39 -06:00
JJ Kasper
2789e7e0c2
Rename getServerProps to getServerSideProps (#10722) 2020-02-27 11:04:30 -06:00
Joe Haddad
47ff1eb95a
Ability to Disable SSG Fallback (#10701)
* Ability to Disable SSG Fallback

* Throw error when value is missing

* Fix existing tests

* Adjust error message

* Do not render fallback at build time for `fallback: false` page

* Fix existing fallback behavior

* fix build

* fix version

* fix some tests

* Fix last test

* Add docs for get static paths

* Add explicit mode tests

* test for fallback error message
2020-02-27 13:23:28 +01:00
JJ Kasper
395714a475
Update url prop handling for pages with new data methods (#10653)
* Make sure to show error when url prop is returned for a page

* Update test and handle undefined pageProps

* Handle empty props

* Apply suggestions from code review

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>

* Update tests

* Update to not add url prop for SSG/SSP pages

* Update errsh for reserved prop

* Update errsh wording some more

* Update tests and to warn instead of error

* Update reserved prop warning

* Include page in url prop warning

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-26 13:26:55 -05:00
JJ Kasper
40abd708e1
Show better error when non-array is returned from custom-routes (#10670)
* Show better error when non-array is returned from custom-routes

* bump

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-24 17:01:02 -05:00
Armand Abric
156a77409b
Fix typo in invalid getStaticPaths value example (#10657) 2020-02-24 07:16:30 -05:00
JJ Kasper
95071730b6
Add err.sh for getStaticProps error (#10619)
* Add err.sh for getStaticProps error

* Prettify error

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-21 00:45:50 -05:00
Tim Neutkens
80bdf73929 Remove extra whitespace 2020-02-20 12:29:22 +01:00
JJ Kasper
db445db790
Add err.sh for invalid getStaticPaths return value (#10605)
* Add err.sh for invalid getStaticPaths return value

* Update error link

* Apply suggestions from code review

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-02-20 10:05:49 +01:00
JJ Kasper
db90ffe1ea
Implement experimental pages/404.js for custom 404 page (#10329)
* Implement experimental pages/404.js for custom 404 page

* Make sure to show error for getInitialProps in pages/404 in dev mode also

* Update routes-manifest tests for new value

* Make sure page404 is boolean in routes-manifest

* Rename variables for consistency

* Make sure to only use 404 page for 404 error
2020-02-01 15:47:42 +01:00
JJ Kasper
afc278f567
Add support for runtimeConfigs in serverless mode (#10365)
* Add support for runtimeConfigs in serverless mode

* Update test
2020-02-01 14:24:22 +01:00
Dmitry Rybin
41d1757b4e
fix: 9919 Add warning when no config is exported from next.con… (#10228)
* fix: 9919 no exported config found

* fix: 9919 remove isolated test, add integration

* fix: 9919 add check for successfull compilation and fix warnin check

* Add test for development output

* fix: 9919 add error page and link to it in warning

* Update empty-configuration.md

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-01-29 09:12:30 +01:00
Joe Haddad
3f9b930815
Error on Invalid PostCSS Shape (#10244)
* Error on Invalid PostCSS Shape

* Add link to docs
2020-01-23 16:27:07 -05:00
Arek Mytych
9d7ee34d2c Add info on storing cache in GitHub Actions (#10231)
* Add info on storing cache in GitHub Actions

* Specify yaml for code formatting

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Fix wording

Co-Authored-By: Joe Haddad <timer150@gmail.com>

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-23 15:40:02 -05:00
Joe Haddad
32ded0539e
PostCSS Error When Exporting Function (#10242)
* PostCSS Error When Exporting Function

* Update postcss-function.md
2020-01-23 15:39:50 -05:00
Joe Haddad
c713741f51
Explain Ignored PostCSS Plugin (#10240) 2020-01-23 15:28:37 -05:00
Joe Haddad
945f726590
Fix Linting 2020-01-23 08:30:18 -05:00
Martin Grubinger
60e62241a8 Add Bitbucket Pipelines to errors/no-cache.md (#10229)
* Update no-cache.md: add Bitbucket Pipelines

Add section on how to setup caching for Bitbucket Pipelines

* Update no-cache.md

Change wording of referencing the next cache in bitbucket pipeline
2020-01-23 11:18:00 +01:00
Naggar
71c2354ecd fix broken link in error page (#10159)
This commit updates the link for Automatic Static Optimization page in the Documentation
2020-01-19 16:02:44 +01:00
Joe Haddad
243c038222
docs(errors): CSS Modules Imported by a Dependency (#10034) 2020-01-10 11:45:01 -05:00
Joe Haddad
dd020fb888
docs(errors): CSS Imported by a Dependency (#10032) 2020-01-10 10:40:28 -05:00
Joe Haddad
fa81a4df83 Add Links to Global CSS Error (#10031)
* Add Links to Global CSS Error

* Add Example
2020-01-10 09:31:38 -06:00
JJ Kasper
163f607160
Add parsing of route source during checking (#9787)
* Add parsing of route during checking

* Update err.sh
2019-12-19 10:48:34 -06:00