Commit graph

237 commits

Author SHA1 Message Date
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