Commit graph

8871 commits

Author SHA1 Message Date
Terry Tan
5e6b92059f
Fix (trailingSlash: true) causes issue in auth0 example (#27010)
I think the issue was due to ```nextjs-auth0``` package on version ```0.8.0```. Upgrading to latest version ```1.4.2``` resolve the issue.

## Bug

- [x] Related issues linked using `fixes` https://github.com/vercel/next.js/issues/19313
2021-07-08 15:54:21 +00:00
Houssein Djirdeh
841ea04d20
[ESLint] Removes image rule as error in Core Web Vitals config (#26967)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-07-08 13:28:10 +02:00
Tim Neutkens
20200ad87f
Provide Next.js postcss version to cssnano-simple (#26952)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-08 13:10:43 +02: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
Steven
f1e6bc9e6b
Rename next/script interface Props to ScriptProps (#26990)
This will ensure `next/script` follows the same naming convention as `next/image`. For example:

```js
import Image, { ImageProps } from 'next/image'
import Script, { ScriptProps } from 'next/script'
```

Fixes #26290
2021-07-07 16:35:50 +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
Anindya Dey
caca389cc1
fix error message during create-next-app (#26980)
Fixes [issue #19588](https://github.com/vercel/next.js/issues/19588)

Here's a screenshot of the error message:
![image](https://user-images.githubusercontent.com/30517208/124733436-d1babd80-df31-11eb-96e4-513505ba07a0.png)
2021-07-07 11:12:58 +00:00
Tim Neutkens
1dd19f5776 v11.0.2-canary.7 2021-07-07 12:39:42 +02:00
Tobias Koppers
75ca8c0eb5
update webpack to 5.43.0 (#26979) 2021-07-07 12:00:41 +02:00
JJ Kasper
697756f8ce
v11.0.2-canary.6 2021-07-06 18:11:34 -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
Paul Schultz
5b1c3e39e1
Updated next-transpile-modules to 8.0.0 (#26971)
## Bug

- [x] Related issues linked using `fixes #26970`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-07-06 20:14:45 +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
f7bc8f4b7c
Fix merge issue and use respondWith (#26961) 2021-07-06 13:34:50 -05:00
Gerald Monaco
53123ad61f
More explicit typing for IncrementalCache API (#26941)
Make the typing for `IncrementalCache` more explicit. With streaming, we’ll want to stream page data as well as HTML. This is a bit complicated now because we’re overloading `pageData` for both redirects and pages.

This PR makes the different types explicit. With streaming, the data for redirects is synchronously available, while the data for pages will become a stream.

A follow up PR will add a “stream through” cache in front of `IncrementalCache`
2021-07-06 15:45:49 +00:00
Jeongyeon Lee 이정연
d476c91a9a
Fix typo in route-loader (#26942) 2021-07-06 11:53:08 +02: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
Gerald Monaco
402f0360ce
Refactor decode failures (#26899) 2021-07-05 18:31:32 +02:00
Houssein Djirdeh
f1fe4bbebf
[ESLint] Update default .eslintrc file created to have .json format (#26884) 2021-07-05 10:58:09 +02:00
Sachin Raja
ba88bfde3e
include image types in create-next-app next-env.d.ts (#26890)
Previous TypeScript template in `create-next-app` only had the following in `next-env.d.ts`
```ts
/// <reference types="next" />
/// <reference types="next/types/global" />
```

New `next-env.d.ts` has this:
```ts
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />
```

Next.js automatically adds the `image-types` reference, but it won't be included in the initial commit. 
## Documentation / Examples

- [x] Make sure the linting passes
2021-07-04 17:21:16 +00:00
JJ Kasper
4fbf961c79
v11.0.2-canary.5 2021-07-02 18:27:50 -05: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
Angelo Ashmore
b4089998e6
Use Prismic CDN URL in cms-prismic example (#26837)
The CDN URL is the recommended URL for the Prismic REST and GraphQL APIs.

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-02 21:03:21 +00:00
JJ Kasper
a6965961bd
Ensure API route errors are propagated in minimal mode (#26875)
This ensures when an error occurs in an API route while using minimal mode the error is bubbled so it can be handled at the top-level 

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-07-02 20:54:53 +00:00
Paweł Tymczuk
3b592e206e
Fix: added the key property to the pre next scripts (#26646)
This fixes the React warning: `Warning: Each child in a list should have a unique "key" prop.` that is thrown when using the `Script` components with the `beforeInteractive` strategy. 

Fixes: #26618
2021-07-02 20:23:11 +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
Lee Robinson
c139f2566a
Reorder docs manifest and rename to Script Optimization. (#26874)
So there's _conformance_ between the other docs / optimizations.
2021-07-02 15:33:46 +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
Alex Castle
277061943a
Don't emit duplicate image files (#26843)
fixes #26607

This change makes it so the image loader plugin only emits a file while processing an image import for the client. The final generated image URL was already the same in SSR and CSR anyway, so this change doesn't have any functional impact.

I also changed the name of the static page in the image component tests, since it was causing some conflicts with the static assets folder.
2021-07-02 11:27:32 +00:00
Paul van den Dool
9039afe75b
Update to environment-variable.md (#26863)
## 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
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes

## Why the change
I lost quite a few hours figuring out why my environment variable was `undefined` in the browser.
I read about the built-in support and was like: "Oh nice" and didn't read much further. I missed the part about how you need to prefix your variables with `NEXT_PUBLIC_` in order to expose them to the browser.
I think a hint to this in the anchor link to that section will make it more discoverable as it's then mentioned near the top and will save people who are like me some time and a headache.
2021-07-02 10:35:53 +00:00
Tim Neutkens
270487d797
Make sure 404 pages do not get cached by a CDN when using next start (#24983)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-02 10:40:13 +02:00
JJ Kasper
138b9ddf99
v11.0.2-canary.4 2021-07-01 17:45:55 -05:00
Steven
acd0fabf83
Update publish-canary script to include checkout (#26840)
* Update `publish-canary` script to include checkout

* Update contrib with publishing section
2021-07-01 17:19:14 -05:00
Steven
03b61778ba
Fix immutable header for image with static import & unoptimized (#26836)
Fixes #26587
2021-07-01 22:14:42 +00:00
Steven
0562cc77bc
Add additional tests for image type detection (#26832)
Adding additional tests. Follow up to #26705
2021-07-01 20:53:26 +00:00
Artur Sedlukha
748b005cda
Fix using-preact example deps (#26821)
Fix after https://github.com/vercel/next.js/pull/26133
2021-07-01 20:20:20 +00:00
Joachim Viide
d670198e7c
Add "Vary: Accept" header to /_next/image responses (#26788)
This pull request adds "Vary: Accept" header to responses from the image optimizer (i.e. the /_next/image endpoint).

The image optimizer prefers re-encoding JPG files to WebP, but some browsers (such as Safari 14 on Catalina) do not yet support WebP. In such cases the optimizer uses the Accept header sent by the browser to send out a JPG response. Thus the optimizer's response may depend on the Accept header.

Potential caching proxies can be informed of this fact by adding "Vary: Accept" to the response headers. Otherwise WebP data may be served to browsers that do not support it, for example in the following scenario:
 * A browser that supports WebP requests the JPG. The optimizer re-encodes it to WebP. The proxy caches the WebP data.
 * After this another browser that doesn't support WebP requests the JPG. The proxy sends the WebP data to the browser.

- [x] Integration tests added
- [x] Make sure the linting passes
2021-07-01 19:59:16 +00:00
Steven
93f625428b
Add onLoadingComplete() prop to Image component (#26824)
This adds a new prop, `onLoadingComplete()`, to handle the most common use case of `ref`.

I also added docs and a warning when using `ref` so we recommend the new prop instead.
 
- Fixes #18398 
- Fixes #22482
2021-07-01 18:51:20 +00:00
JJ Kasper
3c994abc29
Update snapshot for font-optimization test (#26823)
This fixes the `font-optimization` test failing from the links/content changing slightly in the snapshot. 

## 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-01 17:10:01 +00:00
Jiachi Liu
e89b8e466a
fix: detect loop in client error page (#26567)
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-07-01 13:54:54 +02:00
JJ Kasper
612889dfeb
Update repo scripts to separate folder (#26787) 2021-07-01 13:41:27 +02:00
D. Kasi Pavan Kumar
b508d90449
examples: fix typo lunixlinux (#26796)
## 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-07-01 06:20:35 +00:00
JJ Kasper
72318a7ba9
Update codeowners to add new maintainers (#26770) 2021-06-30 19:27:50 -05:00
Jiachi Liu
c51598268a
Leverage blocked page for _error (#26748)
## Enhance

simplify detection for visiting `_error`

x-ref: #26610
2021-07-01 00:08:36 +00:00