Commit graph

8999 commits

Author SHA1 Message Date
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
Michał Bundyra
7fe8a001e2
ESLint: custom directories from next.config.js (#26401)
Attempt to fix #26393

~~Sorry, I wasn't able to run tests on local, but I hope at least test should be valid.~~
Edit: Tests are working correctly on my local :) 

fixes #26393



## Bug

- [x] Related issues linked using `fixes #26393`
- [x] Integration tests added
2021-07-25 04:11:29 +00:00
kaykdm
3b2732bc36
[ESLint] add no-typos rule to eslint (#26650)
* add no-typos rule to eslint

* return early when function name is correct

* Handle null decl.type

* update check

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-24 22:22:19 -05:00
Guilherme Baron
0d49d9f22f
Add --dev flag to bundle-analyzer install command (#27463)
## Documentation / Examples

- [x] Make sure the linting passes
2021-07-25 02:07:21 +00:00
JJ Kasper
2cf9b462ae
v11.0.2-canary.21 2021-07-24 12:10:01 -05:00
Houssein Djirdeh
078cfb59f9
[ESLint] Adds --format flag to next lint (#27052)
Adds `--format` support to `next lint` to allow defining of additional formatters. Fixes #26387.
2021-07-24 01:35:56 +00:00
Arthur Puyou
fac083bcfa
Update max-age in HSTS sample (#27452)
The previous paragraph mentions a max-age of 2 years, so the number of seconds should match.
2021-07-23 18:01:36 -05:00
Steven
9065cdf836
Add warning when next/image component has style prop (#27441)
We've never supported the `style` prop as seen in the docs https://nextjs.org/docs/api-reference/next/image#other-props

TS users already get a build error but JS users were left in the dark.

This PR adds a warning so its clear during `next dev`.
2021-07-23 22:53:27 +00:00
JJ Kasper
c54f168d9a
Add config check for invalid duplicate locale domains (#27451) 2021-07-23 17:16:14 -05:00
Tobias Järvelöv
ee605cb653
Wait for getFilesForRoute promise to fulfill before timeout in dev mode (#27395)
The fix in PR #25749 only works some of the time. The reason why it
doesn't work all of the time is because the `devBuildResolve` function
is called when the assets have been built, but this can happen before
the `getFilesForRoute` promise chain has completed, and thus the
`cancelled` variable could not yet have been updated.

To fix this we wait for the `getFilesForRoute` promise chain to be
fulfilled and then resolve the `devBuildPromise` promise afterwards.
This allows the `getFilesForRoute` promise chain to be fulfilled before
and the `cancelled` variable can be updated accordingly.

If an error is thrown somewhere in the `getFilesForRoute` promise chain,
i.e. due to a failed fetch request, then that will also resolve the
`devBuildPromise` and the error will bubble up to ultimately become a
`routeChangeError` which will reload the page.

With this fix the need to listen for HMR events has become obsolete as
regardless of when the HMR build/sync events complete we still want to
ensure that the `getFilesForRoute` promise chain has been fulfilled
before resolving the `devBuildPromise`.

Co-authored-by: Tobias Järvelöv <tobias.jarvelov@oderland.se>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-23 15:56:14 -05:00
Mohamed ElSaadany
9cbc4aacd5
Add locale switcher to i18n-routing example (#27444)
* add locale switcher to dynamic GSP page in i18n-routing example

* Apply suggestions from code review

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

* Add switcher to other pages as well

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-23 14:33:10 -05:00
stefanprobst
046f7164db
Add eslint config options to NextConfig type (#27446)
This adds missing eslint config options to the public `NextConfig` type.

## 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-23 19:15:26 +00:00
stefanprobst
daf54bb2b0
[eslint] move core-web-vitals config to eslint-plugin-next (#27363)
this pr moves the "core-web-vitals" config from `eslint-config-next` to `eslint-plugin-next`.

Fixes: #27292

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-23 17:58:53 +00:00
JJ Kasper
a8b9c3a3ed
Ensure generateBuildId is not required in config type (#27443) 2021-07-23 12:14:25 -05:00
Steven
bf02cf84d9
Update next/image docs with onLoadingComplete() (#27440)
Follow up to #26824
2021-07-23 15:40:33 +00:00
Yubin
4e74db2d55
Add lazyBoundary prop to Image component (#27258)
This PR adds `lazyBoundary` prop on Image Component.
This feature is to load the images earlier.
I'm not good at English. So, I couldn't explain enough in the documentation what `lazyBoundary` is.

Feature request: https://github.com/vercel/next.js/discussions/24552

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

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-23 14:44:38 +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
JJ Kasper
bb779eceeb
v11.0.2-canary.20 2021-07-22 18:21:12 -05: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
Gerald Monaco
1651129429
Don't cache null responses (#27403)
It's possible for `renderToHTML` to return `null` if `res.finished || res.headersSent` is `true` after `getInitialProps` or `getServerSideProps`. In such cases, we can't generate a valid `ResponseCacheEntry` or `ResponsePayload`, so we shouldn't try.

I took the opportunity to add an invariant for when we expected a cacheable response, but didn't get one. This could happen because Next.js or an application erroneously mutated the underlying `res` during the rendering of a page with `getStaticProps`. This shouldn't normally be possible because `res` isn't exposed in such cases, but it's theoretically possible with a custom server, so it seemed worth flagging.
2021-07-22 21:04:58 +00:00
JJ Kasper
ebf81223d7
Increase PR stats repo build timeout (#27419)
Follow-up to https://github.com/vercel/next.js/pull/27308 this increases the `exec` timeout to allow more time for the repo to install/build since it can sometimes take longer in GitHub actions.
2021-07-22 19:16:48 +00:00
JJ Kasper
888c7002d6
Fix external redirect with i18n domains (#27415)
This corrects a case when redirecting with i18n locale domains configured the locale domain would be prefixed on external redirects un-necessarily. 

Fixes: https://github.com/vercel/next.js/issues/27405

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2021-07-22 18:32:12 +00:00
Lee Robinson
14fb7df7f1
Clarify automatic updates in deployment. (#27418)
Slightly more clear 😄
2021-07-22 17:49:58 +00:00
Aryan Beezadhur
047347a0b4
Rename utils to lib in with-mongodb-mongoose example (#27407)
Rename the `utils` folder to `lib`, and update file imports since other examples favour `lib` over `utils`.
2021-07-22 16:55:47 +00:00
Aryan Beezadhur
f8947b0133
Rename util to lib in with-mongodb example (#27404)
* Rename examples/with-mongodb/util/mongodb.js to examples/with-mongodb/lib/mongodb.js

* Change file import from `util` to `lib`
2021-07-22 11:32:56 -05:00
Steven
79ed8e13b0
Add keepAlive to node-fetch polyfill (#27376)
Fixes #27109 

This PR adds a default `agent` as described in the [`node-fetch` docs](https://github.com/node-fetch/node-fetch#custom-agent).

We should see about 2x perf according to some [benchmarks](https://github.com/Ethan-Arrowood/undici-fetch/blob/main/benchmarks.md#fetch).
2021-07-22 14:34:33 +00:00
Mandar Patil
c218347faa
Fixed typo and error when using Auth0 service; (#27383)
* Fixed typo and error when using Auth0 service;

`Allowed Web Origin` on Auth0 is now required to be set to `http://localhost:3000`

* lint-fix


Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-21 22:21:36 -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
JJ Kasper
52ae69ac33
Rename spr config to ISR (#27379) 2021-07-21 21:42:33 -05:00
JJ Kasper
5dc5a3fba8
v11.0.2-canary.19 2021-07-21 13:57:48 -05:00
Edward Brey
4c86976b36
Indicate attaching debugger (vs launching) (#27377)
The prior configuration name indicating that it launched the application. Really, it just attaches to an already running application, which the new name indicates.
2021-07-21 12:56:26 -05:00
Stefan Becker
dbfce34ead
Add configuration for ISR Memory Cache Size (#21535) (#27337)
This allows the user to adjust the LRU cache size according to the
application need:

- optimize the cache size based on average page HTML & JSON size
- disable the memory cache by setting the size to 0

The hard-coded default of 50MB has been moved from the code to the
default configuration object.

Fixes #21535
See also #27325



## 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`
- [ ] 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
2021-07-21 17:39:38 +00:00
Javi Velasco
e65c56e7e6
Refactor i18n checks on request handling (#27328)
Currently there is a lot of mutation in the Next.js Server and the checks for Locale are directly coded in the general request handler. Ideally, we should have a function where we just pass the request input (url + headers + config) and generate a bunch of metadata that analyzes it generating all metadata we might require for both the URL and i18n + basePath information.

This PR brings:
- A new parsing function `parseUrl` that joins parsing an absolute/relative URL into a data structure compatible with the Node parsing output but missing redundant properties.
- A wrapper `parseNextURL` that extends `parseUrl` analyzing `i18n` and `basePath` based on the provided configuration, url and headers. This function is pure and stateless so it can be used outside of the Next.js context.
- Types improvements and reuse.
- Refactors `next-server.ts` request handling using the above mentioned functions so that the code there just apply effects to the `req` object and the `parsedUrl.query` leaving the code much more straightforward.
- Refactors `getRouteRegex` decomposing in two different functions where `getParametrizedRoute` can be used to retrieve the serializable data that is used to generate the Regex.
2021-07-21 16:12:33 +00:00
Andres Barbaro
bdcb8b0a71
Allow enabling worker threads on dev server (#23027)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-20 19:12:57 -05:00
Aryan Beezadhur
1b67dc163d
Examples: Delete as prop from <Link> components (#27359)
`as` prop is no longer required on `next/link` components for dynamic routes
2021-07-20 22:05:20 +00:00
JacobLey
527cb97b56
Support multiple pages directories for linting (#25565)
Monorepos may contain multiple NextJS apps, but linting occurs at top-level so all directories must be declared.

Declaring multiple directories via an Array allows loading all to generate a full list of potential URLs.

Updated schema and tests. Also optimized some of the `fs.*Sync` requests that can add up to lots of blocking lookups.

## 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
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

Closes: https://github.com/vercel/next.js/pull/27223
2021-07-20 21:29:54 +00:00
Kyle Holmberg
7b0731af0c
Update docs around ISR revalidation (#25571)
* update docs around revalidation

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-20 15:11:46 -05:00
Isaac Abotsi
09baca03ad
docs: add note for Image responsive layout (#25915)
With the default Next.js template project, the .main and .container divs have `display: flex` style rule. However, as commented in [this issue](https://github.com/vercel/next.js/issues/18489#issuecomment-857146988), if may not display properly an <Image /> placed as direct child.



## Documentation / Examples

- [x] Make sure the linting passes
2021-07-20 20:05:56 +00:00
Peter Mekhaeil
caaa1be5c6
chore: Set Prettier to ignore test output (#26353)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-20 14:37:44 -05:00
fabb
8e34902fb9
Update NextConfig type to not require experimental or future fields (#25517)
when typechecking next.config.js as described [in the docs](https://github.com/vercel/next.js/blob/canary/docs/basic-features/typescript.md#type-checking-nextconfigjs), an error would be thrown if `future` and `experimental` are missing. When using `Partial<>` in the type definition instead, it works as expected.

Fixes #25498

## 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-07-20 18:42:29 +00:00
JJ Kasper
a972579304
v11.0.2-canary.18 2021-07-20 12:36:49 -05:00
Jamie
7c408e7a0f
Fix ISR page re-rendering after revalidate expiry (Fork of #24807) (#27335)
Fixes: #24806 
Fixes: #26689
Fixes: #27325
Closes: #24807

@tommarshall has done us a huge favor with his PR https://github.com/vercel/next.js/pull/24807 which outlines exactly the issue and a pragmatic solution.

I'm not trying to "steal their work", however, the PR seems to have been stuck for some months. I think there's huge value in this for myself and others as essentially **ISR is broken** for people running Next.js at scale 😱 

This PR has cherry-picked @tommarshall's fine fix and added some integrations tests around page revalidation and the edge case when the cache size is exhausted.

✏️ Edits are enabled, so feel free great Vercel staff and other maintainers to improve my bad tests or surrounding code 🙇 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
2021-07-20 17:01:42 +00:00
Gerald Monaco
ade52553b6
Add RequestContext (#27303)
How a page is rendered depends on whether or not we're streaming. For example, if we're just rendering to a `string` or we're generating a response for a crawler or other robot, we don't want React 18 to dynamically flush `<script>` tags to update Suspense boundaries as they resolve. Instead, we just want to wait for the full HTML to resolve and return a result similar to `renderToString`.

This is what `RequestContext` and the new/refactored `pipe` and `getStaticHTML` methods allow.  They add a `requireStaticHTML` option that gets passed down. A follow-up PR will make sure this is `true` when serving a robot, and also ensure React is invoked appropriately.
2021-07-20 16:04:31 +00:00
Sam Taal
a96739fc49
Add extra explanation to next/image about positioning (#27341)
* Add extra explanation to next/image about positioning

In my experience, when using next/image, a lot of devs forget about the `position: relative` when using `layout: fill`. I think it's a small and effective change to implement this one line to make it more clear.

* Update docs/api-reference/next/image.md

* lint-fix

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-20 10:30:08 -05:00
Mahmoud Abdelwahab
c3884e6837
Update graphql example (#27334)
## Documentation / Examples

This is an update to the [GraphQL example](https://github.com/vercel/next.js/tree/canary/examples/api-routes-graphql) to use [apollo server 3](https://www.apollographql.com/docs/apollo-server). This example works with Apollo Studio
2021-07-20 15:19:22 +00:00
Thang Vu
9fc58f88a2
fix: hydration warning in with-mobx-state-tree-typescript example (#27339)
## Bug

- [x] Related issues linked using `fixes #number` fixes https://github.com/vercel/next.js/issues/27290
- [ ] 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-07-20 14:15:02 +00:00
Sam Robbins
e0ca6de832
Update layout-component example to use named functions (#27331)
## Documentation / Examples

- [x] Make sure the linting passes

In line with the PR #27297 which solved issue #27252, this updates the example to also use named functions in order to pass ESLint
2021-07-20 14:02:51 +00:00
Jiachi Liu
41b4fc3688
Upgrade swc for mac m1 compiling issue (#27329)
`@swc/core` will trigger a very rare complication issue on mac m1, it's fixed in version 1.2.66
x-ref: https://github.com/swc-project/swc/pull/1939

cc @kdy1 

## 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-20 11:53:48 +00:00
Sofya Tuymedova
0472f0fa81
Fix image link (#27323) 2021-07-20 10:33:50 +00:00
Mikhail Tsyplakov
2a282a4081
fix type NextWebVitalsMetric (#24780)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-19 20:39:24 -05:00