Commit graph

1901 commits

Author SHA1 Message Date
Tobias Koppers
4b33cef977
upgrade to webpack 5.47.0 and webpack-sources 3.1.1 (#27538)
* improve source-map performance
* improve watch performance
* bugfixes
* improvements to Data URIs
2021-07-29 16:10:51 +00:00
stefanprobst
0833f83c86
Fix eslint config next/core-web-vitals (#27567)
fixes what i messed up in #27363. cf. https://github.com/vercel/next.js/pull/27363#issuecomment-888495697

also added an integration test for extending from `next/core-web-vitals` eslint config

## Bug

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

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-28 19:07:54 +00:00
Tim Neutkens
c7e2a1df6a
Use SWC for Next.js core client files (#27196)
Replaces Babel with SWC for Next.js core client-side files.

## 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-28 15:10:51 +00:00
Paweł Tymczuk
36b81f989c
Fix: Added the content-disposition header (#27521)
In this PR I've added the `Content-Disposition` header to the response of the image `/_next/image` route. That header is used by the browser when showing the dialog for the `Save image as...` action. 

There are some differences between the browsers, ex:
When requesting the image `test.jpg`,  the response header `Content-Type: image/webp` - in FF the filename from the `Save image as...` dialog would be `test.webp` but in Chrome `test.jpg` even if the `Content-Disposition: inline; filename="test.webp"` is present in the headers.  The same about png images, the rest types are fine.  It looks like FF is checking the `Content-Type` for the extension but the Chrome does not and is doing another type of check.

Fixes #26737

## Bug

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

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-27 23:22:48 +00:00
Maia Teegarden
4172a4c0a6
Add initial next swc package with first transform (#27355)
* Set up next-swc package with no custom transforms

* Add hook_optimizer transform

* Fix lint

* Build next-swc on CI

* Add toolchain in rust action

* Build binaries in manual workflow

* Commit from GitHub Actions (Build next-swc native binaries)

* Update dependencies

* Update swc and use stable rust

* Build next-swc binaries

* Test compiled code

* Dedupe @node-rs/helper

* Add workflow to check next-swc binaries

* Fix check native

* PR feedback

* PR feedback

* Pr feedback

* Build next-swc binaries

* Combine native workflows

* Add docs for contributors on less common platforms

* PR feedback

* Compare JsWord instead of converting to string

* Fix workflow formatting

* Add docs for building binaries for CI

* Build next-swc binaries

* Fix workflow if syntax

* Add license info to copied code

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-07-27 17:07:28 +02:00
Sojin Park
23ac4351f4
fix: Make router ready in case of custom _app getInitialProps (#27473)
From https://github.com/vercel/next.js/pull/20628,  when the page is rendered server-side, `Router`'s `isReady` field needs to be initially set to `true`. However, when `_app` has custom `getInitialProps`, it seems that it is not the case, even though the page is rendered on the server. 

This leads to a bug that `Router.isReady` is never set to `true`.

This pull request fixes the problem by fixing the initial calculation logic of `isReady` of `Router`.

## Bug

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

## Feature

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

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-26 20:25:55 +00:00
Artur Muller
c88898be12
Clarify error message in isSerializableProps (#22856)
I recently received the "Props must be returned as a plain object" error when I accidentally dropped an array directly inside `props`. This is a trivial error to fix once you know what you did, but I spent good 30 minutes looking in all the wrong places. I hope that this slight clarification in the error message would save someone from wasting their time if they make a similar mistake like myself.
2021-07-25 06:08:30 +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
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
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
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
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
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
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
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
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
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
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
Steven
5cd37d9b32
Fix placeholder=blur inside <noscript> (#27311)
We shouldn't be setting `placeholder=blur` styles when JS is disabled because we'll have no way to know when the image is loaded and it will be stuck in blur permanently as mentioned in [this comment](https://github.com/vercel/next.js/pull/19052#issuecomment-882886068).

This PR avoids blur styles on the `<noscript>` version of the image.
2021-07-20 01:23:16 +00:00
Steven
b123942694
Fix minimumCacheTTL so it doesn't affect browser caching (#27307)
In a previous PR (#27200), we added `minimumCacheTTL` to configure the time-to-live for the cached image. However, this was setting the `max-age` header.

This PR ensures that `minimumCacheTTL` doesn't affect browser caching, only the upstream header can affect browser caching.

This is a bit safer in case the developer accidentally caches something that shouldn't be and the cache needs to be invalidated. Simply delete the `.next/cache/images` directory.

- Related to #19914
- Related to #22319
2021-07-19 22:38:03 +00:00
Janicklas Ralph
dda23f5d9b
Fix inline scripts being duplicated when used with next/script component (#27218)
Fixes inline scripts being duplicated when used with `next/script` component

## Bug

- [x] fixes #26860 
- [x] Integration tests added


## Documentation / Examples
 Updated docs to indicate that `id` is needed for inline scripts
2021-07-16 18:58:34 +00:00
Houssein Djirdeh
6645248d41
[ESLint] Remove error when file patterns are unmatched + ESLint setup changes (#27119)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-07-16 20:19:08 +02:00
JJ Kasper
4b1bf758b0
Add additional stats app pages (#27202) 2021-07-16 12:13:04 -05:00
Thomas Marshall
ccb62f8636
Add x-forward headers to external rewrites (#17557)
* Add x-forward headers to external rewrites

This commit configures the proxy used for external rewrites to include
x-forward headers [1]. This is particularly useful for incremental
adoption, where some routes will be handled by Next.js and others by a
different website. For example, a Rails app will use the
X-Forwarded-Host header to determine which host to use for URL
generation and redirects [2].

[1]: 91fee3e943/lib/http-proxy.js (L31)
[2]: 41139f6ba2/actionpack/lib/action_dispatch/http/url.rb (L221-L227)

* Handle image-optimizer case

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-16 10:11:12 -05: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
Janicklas Ralph
3b388c346c
Fix Script beforeInteractive on navigation (#26995)
## Bug

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


## Documentation / Examples

- [x] Make sure the linting passes
2021-07-15 22:51:01 +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
Jiachi Liu
71665b2437
Fix gsp generation with file extension (#27144)
Fixes #11831 
Fixes #12212

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-07-15 18:50:17 +00:00
Houssein Djirdeh
c46b405ba7
adds no duplicate head rule (#27179) 2021-07-15 13:04:17 -05:00
Steven
437ad9ff6a
Fix css minify incorrectly duplicating variables (#27150)
Fixes #26902 

See 507963a480
2021-07-14 21:16:11 +00:00
JJ Kasper
8c3c2b7ea2
Update redirect regexes to not match _next (#27143)
This updates redirects' regexes to not match `/_next` paths since this is currently unexpected and can easily cause a multi-match redirect to break loading client-side assets. This also fixes custom-routes not matching correctly when `trailingSlash: true/false` is used

## Bug

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

x-ref: https://github.com/vercel/next.js/discussions/24683
x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1626159845474000)
2021-07-13 19:38:14 +00:00
Gerald Monaco
cb8da5778e
Replace withCoalescedInvoke with ResponseCache (#26997)
By itself, `withCoalescedInvoke` with a separate `this.incrementalCache.set(...)` isn't really suitable for streaming responses. Since streaming is asynchronous, updating the cache separately introduces a gap where another origin request for the same resource could be made.

This could potentially be addressed by moving the cache update, but then `IncrementalCache` itself would need to be made to support streaming, in addition to the many other responsibilities it has. In this case, it seemed best to just use composition to add another caching layer in front of it, which is a familiar and understandable concept. Eventually, we might want to move this cache to the HTTP layer, which will also be simpler with this change.

As an added bonus, `renderToResponseWithComponents` becomes significantly simpler, and we delete some duplication.
2021-07-12 19:47:39 +00:00
Steven
9777707d67
Add test for placeholder=blur with assetPrefix (#27120)
Follow up to https://github.com/vercel/next.js/pull/27061#pullrequestreview-703527621
2021-07-12 18:58:20 +00:00
Steven
31c3f33639
Enhance next dev performance with placeholder=blur (#27061)
This PR changes the implementation of `placeholder=blur` when using `next dev` so that it lazy loads on-demand.

This will improve the developer experience for web apps with many blurred images.
2021-07-10 20:27:14 +00: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
Michiel Van Gendt
d22ecd97f4
Include message body in redirect responses (#25257)
### Description
The redirect responses from the redirect function do not contain a message body. This is in conflict with the RFCs below and causes Traefik (a reverse proxy) to invalidate the responses. In this pull request, I add a response body to the redirect responses.

### References
- https://datatracker.ietf.org/doc/html/rfc7230#section-3.3
> All 1xx (Informational), 204 (No Content), and 304 (Not Modified) responses must not include a message-body. All other responses do include a message-body, although the body may be of zero length.

- https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3
> The server's response payload usually contains a short hypertext note with a hyperlink to the different URI(s).

- traefik/traefik#4456
- https://github.com/auth0/nextjs-auth0/pull/399
2021-07-09 16:32:48 +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
Steven
b6c590bce1
Loosen next/image TS types for src (#26996)
### Description
This changes the strict TS types to a looser implementation such that the user can pass `src` without TS errors.

### Pros vs Cons
- **Pros**: better support for wrapping `next/image` so that TS won't report false errors
- **Cons**: using `src: string` without `blurDataURL` will no longer show TS errors and instead fail with a runtime error

### Issues
- Fixes #26892 
- Related to #26991
2021-07-07 21:31:30 +00:00
destruc7i0n
12aa56123b
Fix hash change events not firing with i18n (#26994)
My last PR (#26205) made the hash change events not fire when in i18n was enabled, as seen in #26853. This PR fixes that and adds a test for this case.

fixes #26853 

## Bug

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

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-07 20:54:56 +00:00
Darsh Patel
226e81c733
Add dangerously-unoptimized loader for next/image (#26847)
* add support for static loader

* update existing test

* add test

* add prettier-ignore

* update docs

* apply suggestions from review

* remove un-needed normalize

* Apply suggestions from code review

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

* update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2021-07-07 15:20:16 -05:00
Steven
23a47b9f87
Loosen next/image TS types for width and height (#26991)
### Description
This changes the strict TS types to a looser implementation such that the user can always pass `width` and `height` (even when `layout=fill`) without TS errors.

### Pros vs Cons
- **Pros**: better support for wrapping `next/image` so that TS won't report false errors with `layout=fill`
- **Cons**: omitting width/height when using other `layout` will no longer show TS errors and instead fail with a runtime error

### Issues
- Fixes #26531 
- Fixes #25440
2021-07-07 19:15:31 +00:00
Alex Castle
8066e423a7
Don't lazy-load already-loaded image in client-side transition (#26968)
fixes #19074 
This change disables image lazy-loading when both of the following are true:
1) A image is being rendered following a client-side page transition
2) The image has been previously loaded during this session.

Before this change, all images with lazy-loading enabled have a visible flicker during client-side page transitions, even though they're already loaded.

With this change, there's are two performance risks:

1) There's a chance that some offscreen images will have lazy-loading disabled unnecessarily because they were previously loaded. I think the performance hit here is pretty negligible and the situation is unlikely to come up very often.

2) There's a chance a different-sized version of the image will be selected by the browser, but lazy-loading will be disabled anyway. This seems even more unlikely to me, and anyway the performance hit from a stray un-lazy-loaded image (on a client-side transition) is very minor.

In both cases, I think the performance risk is outweighed by the UX improvement of getting rid of the image flicker on page transition.
2021-07-07 17:51:16 +00:00
JJ Kasper
556216b1ad
Add page with next/image to stats-app (#26973)
* Add page with next/image to stats-app

* Update stats-config

* Update globs

* Only run prettier on js outputs

* only add image page for non-webpack 4 mode

* update config

* Re-add moving page chunks
2021-07-07 09:50:24 -05:00
JJ Kasper
c53b60a885
Fix forward slash encoding while interpolating (#26963) 2021-07-06 16:28:43 -05:00
Alexander
f8269fd4a6
Fix: (rewrites) incorrect parsing of destination query (#26619)
fixes #26609

## Bug

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

## Documentation / Examples

- [x]  Make sure the linting passes
2021-07-06 21:20:53 +00:00
Theo Strahlen
38a4e56cfa
(next/image): Merge query string params in imgix loader (#26719)
If the `Image` src url had existing query params, the imgix loader would simply append another query string with `?` causing both query strings to break.

This PR adds a way to safely merge query strings if needed using [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).

## Bug

- [X] fixes #26288
- [X] Integration tests added
2021-07-06 19:51:50 +00:00
Gerald Monaco
2795b79959
Add initial ResponsePayload support (#26938)
Refactors the internals of `next-server` to use `ResponsePayload` instead of `string | null` and manual `sendPayload` calls. This is the first step toward streaming support.

I split `renderToResponseWithComponents` into a separate `renderToResponseWithComponentsInternal` function for ease of review: GitHub's diff rendering was highly misleading, making it seem as though more of the function had changed. The separate function just makes the actual change clearer: we split `renderToHTMLWithComponents` into two promises; one that represents the actual render result, and one that represents all of the work (including background work for e.g. revalidation) that needs to be done as part of generating the result.

These changes make it easier to bubble up a `ResponsePayload`, instead of sometimes calling `sendPayload` out-of-band, centralizing all payload handling in `sendResponse` and eventually a similar function for public APIs that return a string. This centralization will make it much easier to handle a response that needs to be streamed, which is coming soon in another PR.
2021-07-06 09:41:51 +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