Commit graph

3401 commits

Author SHA1 Message Date
JJ Kasper
ca9f808cd5
v10.0.9 2021-03-15 14:12:40 -05:00
Shu Ding
732c49cdc8
Revert "[a11y] Route Announcements" (#23082)
Reverts vercel/next.js#20428 temporarily to move this feature into the next canary release.
2021-03-15 19:09:24 +00:00
Kyle Boss
688611a582
[a11y] Route Announcements (#20428)
# Route Announcements

## Summary
This PR improves the accessibility of NextJS's client-side navigation by announcing route changes to screen readers.

## Context
When a user who is sighted clicks on a link, they can see the content change. It's an affirmation that what the user intended to do by clicking a link actually worked! Users navigating the page via a screen-reader will not get this feedback on NextJS sites (This is an issue on many SPA-like architectures).

https://user-images.githubusercontent.com/4213649/103017382-63b02b00-44f8-11eb-9940-fb530d2d3018.mov

## Solution
Whenever there is a route change, the new `<RouteAnnouncer />` will look for a name to give the new page and then announce it! The name is found by first looking for an `h1`, falling back to `document.title`, and lastly to `pathname`. `<RouteAnnouncer />` is a visually hidden component placed within the `<AppContainer />`.

## Demo
https://user-images.githubusercontent.com/4213649/103017401-6ad73900-44f8-11eb-8050-b3e9a7e0c3f2.mov

## Inspiration
First and foremost, this PR was inspired by @marcysutton's studies and writing, [What we learned from user testing of accessible client-side routing techniques with Fable Tech Labs
](https://www.gatsbyjs.com/blog/2019-07-11-user-testing-accessible-client-routing/) as well as @madalynrose's [Accessible Routing](https://github.com/gatsbyjs/gatsby/pull/19290) PR for Gatsby.

There were also learnings gleaned from the conversations within #7681.

### Related Issues & PRs
- Resolves #7681
- Relates to #19963
2021-03-15 18:36:55 +00:00
JJ Kasper
4f894a3a33
v10.0.9-canary.8 2021-03-15 13:02:13 -05:00
Lee Robinson
a63c64a02d
Update error message for next export and next/image. (#23061) 2021-03-15 13:01:12 -05:00
Lee Robinson
c4508d1d13
Update README to fix broken links. (#23058)
Also put current maintainers at the top of the list.
2021-03-15 16:36:24 +00:00
JJ Kasper
9afcdfcbc4
Ensure i18n index prefetch is correct with trailingSlash (#22746)
This fixes index data route loading for i18n with `trailingSlash: true` enabled and also fixes prerendering `asPath` values not containing a trailingSlash when enabled. 


Fixes: https://github.com/vercel/next.js/issues/17813
Fixes: https://github.com/vercel/next.js/issues/22747
2021-03-14 12:58:34 +00:00
JJ Kasper
0ec58c6328
v10.0.9-canary.7 2021-03-12 09:40:31 -06:00
JJ Kasper
7e63bd7d54
Ensure export only triggers when static pages are present (#22996)
This makes sure we don't trigger the export step if we aren't exporting any static pages during a build. This also adds an invariant to ensure we don't attempt creating a progress with 0 items.

Fixes: https://github.com/vercel/next.js/issues/22994
2021-03-12 08:36:28 +00:00
JJ Kasper
97ebc742e8
v10.0.9-canary.6 2021-03-11 13:54:57 -06:00
Dale Bustad
ffbb10fa9a
Silence trace debug messages (#22988)
These messages aren't necessary in the normal course of using Next.js.  Hiding behind a flag to reduce the noise.
2021-03-11 19:51:43 +00:00
JJ Kasper
014a2f8495
v10.0.9-canary.5 2021-03-10 15:50:50 -06:00
Dale Bustad
e27b7e996d
Telemetry-compatible tracing (#22713)
A number of changes here.  I recommend viewing the diff with the <a href="?w=1">whitespace flag enabled</a>.

- OpenTelemetry is replaced with a custom and lightweight tracing solution.
- Three trace targets are currently supported: console, Zipkin, and NextJS.
- Tracing is now governed by environment variables rather than `--require instrument.js`.
  + `TRACE_TARGET`: one of `CONSOLE`, `ZIPKIN`, or `TELEMETRY`; defaults to `TELEMETRY` if unset or invalid.
  + `TRACE_ID`: an 8-byte hex-encoded value used as the Zipkin trace ID; if not provided, this value will be randomly generated and passed down to subprocesses.

Other sundry:

- I'm missing something, probably a setup step, with the Zipkin target.  Traces are captured successfully, but you have to manually enter the Trace ID in order to view the trace - it doesn't show up in queries.
- I'm generally unhappy with [this commit](235cedcb3e).  It is... untidy to provide a telemetry object via `setGlobal`, but I don't have a ready alternative.  Is `distDir` strictly required when creating a new Telemetry object?  I didn't dig too deep here.

As noted, there are a lot of changes, so it'd be great if a reviewer could:

- [ ] pull down the branch and try to break it
- [ ] check the Zipkin traces and identify possible regressions in the functionality

Closes #22570
Fixes #22574
2021-03-10 21:00:20 +00:00
JJ Kasper
7f1800e175
v10.0.9-canary.4 2021-03-09 13:12:16 -06:00
Shu Ding
7dd99faee7
Fix next/image being downloaded multiple times on Safari (#22902)
Currently if you have `sizes` set in `next/image`, the image will likely be downloaded multiple times (usually twice) on Safari (macOS and iOS): the correct size for the viewport, and the original size specified in `src`. 

Also make sure you have "Ignore Resource Cache" disabled in the Safari Devtools when trying to reproduce:

![CleanShot 2021-03-09 at 21 05 54@2x](https://user-images.githubusercontent.com/3676859/110476820-6399f180-811d-11eb-93ec-5b2482c87884.png)

The root cause is the way Safari handles `<img>`'s attribute updates. Although React updates all the attributes one by one synchronously and programmatically, Safari will still try to fetch the resource immediately and won't wait for other DOM changes to be finished. 

That means if we set the following 3 attributes in this order: `src`, `srcSet`, `sizes`. Safari will fetch the image when `src` is set. And then once `srcSet` is there it will fetch the resource again based on it. And finally, when `sizes` is updated it might correct the resource URL again.

So the fix here is simple: by just reordering those to `sizes`, `srcSet`, `src`, it will only load the image with the correct size only once:

<img width="1498" alt="CleanShot 2021-03-09 at 21 05 30@2x" src="https://user-images.githubusercontent.com/3676859/110477852-a27c7700-811e-11eb-88dc-d6e7895f67bd.png">

Fixes #19478.
2021-03-09 19:07:01 +00:00
JJ Kasper
e84571d8e3
Add appDir field to server files manifest (#22915)
This adds an `appDir` field to the `required-server-files` manifest signifying where the app source is located. 

x-ref: https://github.com/vercel/next.js/issues/22847
2021-03-09 18:41:57 +00:00
Tim Neutkens
969ef1676d v10.0.9-canary.3 2021-03-09 13:00:58 +01:00
JJ Kasper
d951b2385f
Update /500 page exporting when _error has custom GIP (#22887)
This updates to not automatically export `/500` from `_error` if a custom `getInitialProps` is used since logic may be used inside of this method that causes the export to fail. Users can still opt-in to the static `/500` by adding a `pages/500.js` file. 

This also refactors checking `_app` for custom `getInitialProps` to outside of the static check loop to prevent a potential race condition where we could run this check multiple times un-necessarily.  

Fixes: https://github.com/vercel/next.js/issues/22815
2021-03-09 09:55:28 +00:00
JJ Kasper
38964ab09c
v10.0.9-canary.2 2021-03-08 10:58:24 -06:00
JJ Kasper
e9506773a3
Ensure env is loaded before next config (#22879)
This ensures we load all env values before loading `next.config.js` since these values can be used in there. This also updates to ensure we're testing these values are available while loading `next.config.js` so we don't regress on this. 

Fixes: https://github.com/vercel/next.js/issues/22811
2021-03-08 16:53:52 +00:00
Tim Neutkens
9e06f82af4
Upgrade webpack 5 (#22864)
Upgrades webpack 5 to the latest version.
2021-03-08 15:20:42 +00:00
Sadra Bahrami
42b3b162df
Remove extra work on cli functions (#22855)
Hi I saw you wrote extra async await code for command line function that doesn't need. I fixed that and code become very smaller and prettier.
![ts](https://user-images.githubusercontent.com/48912836/110254867-442c8880-7fa6-11eb-9f0f-3b853d5db94c.png)
2021-03-08 13:47:05 +00:00
Tim Neutkens
e7a1cb86e3 v10.0.9-canary.1 2021-03-08 11:46:03 +01:00
JJ Kasper
cdf8f9a1d0
Ensure /404 is not exported during build un-necessarily (#22825)
This ensures we don't export `/404` during the automatic static optimization during build when the `/404` isn't static and won't be used/copied to the final output. 

x-ref: https://github.com/vercel/next.js/issues/22815
2021-03-08 08:30:44 +00:00
JJ Kasper
e17398f40e
v10.0.9-canary.0 2021-03-05 13:26:54 -06:00
Shu Ding
2d207fb11d
Dedupe in-flight server data requests (#22781)
This PR adds request deduplication for `_getServerData`. If a request with the same URL is already in-flight, we don't send another new request. When a request succeeds or fails, we delete the cache.

A potential improvement this brings is, when `getServerSideProps` of a new route is slow to load, the user might keep clicking on the link which causes new requests, and the route will never update because results of old requests were ditched. Also adds a test case for this scenario.

Closes #19238.
2021-03-05 17:16:02 +00:00
Shu Ding
afc8ce4d0d
Fix idleTimeout error being thrown in route loader (#22775)
In the current implementation, `idleTimeout` will always be thrown even if it didn't time out and `Promise.race` was resolved. This causes the error `Error: Route did not complete loading` on every route transition and Chrome Devtools will pause code execution if you have "Pause on exceptions" enabled.

This PR adds `resolvePromiseWithTimeout` which does the same thing as `Promise.race` and `idleTimeout`, but it cancels the rejection when it resolves successfully, in which case the error won't be thrown.

Fixes #21543.
2021-03-05 16:32:00 +00:00
Joe Haddad
33255b7f4e
v10.0.8 2021-03-05 10:26:50 -05:00
JJ Kasper
c493791165
v10.0.8-canary.17 2021-03-04 16:23:09 -06:00
JJ Kasper
27555c8ef9
v10.0.8-canary.16 2021-03-04 16:10:20 -06:00
JJ Kasper
3417164c1d
Fix index revalidate with dynamic route in minimal mode (#22783)
This fixes the case where index page revalidation would match a dynamic page instead of the index page from the pathname not being denormalized. 

Fixes: https://github.com/vercel/next.js/issues/22750
2021-03-04 22:09:45 +00:00
Joe Haddad
2046648fa7
v10.0.8-canary.15 2021-03-03 14:53:19 -05:00
Joe Haddad
61dae380a8
chore: upgrade webpack 5 version (#22737) 2021-03-03 19:52:20 +00:00
JJ Kasper
1435de15bc
Ensure component load order (#22731)
This ensures we load `_document` then `_app` and then the page's component in all cases which matches behavior between the serverless target and the default server target.  Additional tests to ensure this order is followed has been added to prevent regression. 

Fixes: https://github.com/vercel/next.js/issues/22732
2021-03-03 19:20:48 +00:00
Tim Neutkens
5b479b609a v10.0.8-canary.14 2021-03-03 10:39:10 +01:00
JJ Kasper
b80fdfb828
Update webpack server chunks output (#22697)
This updates to output server chunks to a nested folder to prevent bundling the entire folder when tracing. This also fixes the webpack 5 tests not actually using webpack 5 since https://github.com/vercel/next.js/pull/22583 since the webpack 5 enabling check didn't account for the test environment variable used to enable webpack 5. This also clears up some deprecation warnings from webpack 5 in the mini-css-extract-plugin.

Fixes: https://github.com/vercel/next.js/issues/21297
2021-03-03 09:37:24 +00:00
JJ Kasper
ac47795d37
v10.0.8-canary.13 2021-03-02 13:55:31 -06:00
JJ Kasper
e037c22997
Ensure optional params are normalized in minimal mode (#22676) 2021-03-02 13:51:53 -06:00
Janicklas Ralph
a107dcb732
Experimental script loader changes (#22038)
Making experimental script work in _document.js - Fixes for server to client transition
Adding additional test for _document.js
2021-03-02 19:17:33 +00:00
Joe Haddad
103422ce70
v10.0.8-canary.12 2021-03-02 13:20:40 -05:00
Joe Haddad
72ce0173e1
v10.0.8-canary.11 2021-03-01 14:00:25 -05:00
Joe Haddad
7aaebee14e
v10.0.8-canary.10 2021-03-01 09:17:17 -05:00
Joe Haddad
04f37d0978
fix: load webpack hook before config is required (#22583)
This pull request ensures the webpack hook is installed before an attempt is made to load the configuration.

This pull request is tested by the PnP tests, which should now be passing as a result of this change.

---

Fixes #21679
2021-02-27 06:19:35 +00:00
Jan Potoms
1ebc9bbb5e
Load next.config.js async (#22578)
Just the conversion of config loading from sync to async from https://github.com/vercel/next.js/pull/22153

cc @Timer
2021-02-27 00:29:32 +00:00
Adrien MILLE
7380f20cdb
Forward log argument from loadEnvConfig to processEnv (#22440)
We do have a third argument on `processEnv` to customize the console instance, however `processEnv` relies on `processEnv` which also have the same argument for the same purpose but it's not forwarded from `processEnv`. 

Was there a purpose for it to be left out ? If not I would expect it to be forwarded 😄 

Closes: https://github.com/vercel/next.js/pull/21788
2021-02-25 19:30:38 +00:00
lindsaylevine
b1a1c80e7c
bug (#21943): remove incorrect rewrite of parsedUrl.pathname in serverless handler (#22445)
Fixes https://github.com/vercel/next.js/issues/21943

i confirmed in a personal test repo that this solves the issue of infinite 307s on root level non-default locales :)  let me know what else this needs if anything! thanks for the time/help @ijjk ❤️
2021-02-25 18:43:51 +00:00
JJ Kasper
0088caa1ea
v10.0.8-canary.9 2021-02-25 09:36:47 -06:00
JJ Kasper
6d068aed4f
Fix experimental optimizeCss for SSR (#22513)
This ensures `distDir` is set under `renderOpts` in `next-server` so that it is present when experimental `optimizeCss` is enabled. 

x-ref: https://github.com/vercel/next.js/pull/16539
2021-02-25 09:56:11 +00:00
Alex Castle
a0d44ca311
Allow smaller sizes in srcset for image with fill layout and sizes prop (#21670)
Currently, the image component doesn't handle use of the `sizes` property with `layout="fill"` and `layout="responsive"` very well for small viewports. It will never include sizes smaller than the smallest viewport (640px) in the srcset, so even if you specify `sizes="30vw"` in your image, you have to download the full-viewport-width image on small devices. 

This PR adds logic such that if you use `layout="fill"` and include a `sizes` property, the image component will include the full range of image sizes in the `srcset`.

It also includes an optimization where it finds the smallest `vw` value in the sizes value and combines that with the smallest viewport width, and uses that as the floor of the srcset. It does this so it doesn't unnecessarily increase transfer size by including ALL sizes. This is still a conservative optimization--for 95% of cases, taking the _largest_ `vw` size would work, but I don't see a way to do that without breaking a few corner cases.

The case of a sizes prop with `px` values is fixed but not optimized--though generally that case is less of a good fit for the fill or responsive layout anyway.
2021-02-24 22:57:19 +00:00
JJ Kasper
b90b4b503c
v10.0.8-canary.8 2021-02-24 10:26:52 -06:00