Commit graph

8122 commits

Author SHA1 Message Date
Mokshit Jain
7dc45a325e
Add Typescript section to Redux Toolkit Example (#23166)
I have added a new section to the `with-redux-toolkit` example on setting up Typescript with Redux Toolkit and React-Redux.

It links the redux toolkit documentation and Next.js documentation on adding Typescript to a Next.js project.
2021-03-17 18:59:14 +00:00
Tim Neutkens
7757364fc6 v10.0.10-canary.2 2021-03-17 10:13:36 +01:00
Tobias Koppers
e019ef6acc
update webpack, fix runtime location, fix undeclared variable, omit env vars from cache version (#23113)
* this will fix problems with serverless target which doesn't use a runtime chunk
* It also omit env vars from contributing to cache version as webpack will handle that now
* It moves the webpack-runtime chunk from ./chunks back to ./
2021-03-17 08:32:45 +00:00
JJ Kasper
a9da48d3da
v10.0.10-canary.1 2021-03-16 16:33:31 -05:00
Shu Ding
1bf4cf3e76
Upgrade jest-worker (#23077)
This PR upgrades `jest-worker` and `jest-cli` to the latest pre-release version, also removed `jest-circus` which is included in Jest by default. `jest-worker@next` includes a fix for memory leak that we need (https://github.com/facebook/jest/pull/11187). 

Fixes #22925. This will also improve the OOM issue for `next dev` #15855.
2021-03-16 21:08:35 +00:00
Mokshit Jain
091d56ade8
Simplify redux toolkit example and update packages (#23047)
I have simplified the `with-redux-toolkit` example and changed the directory structure to "feature folders". I have removed the `notes` page and API route as it wasn't directly related to the redux toolkit. This example is also identical to the official [cra redux template](https://github.com/reduxjs/cra-template-redux). All the dependencies have also been updated.
2021-03-16 20:15:54 +00:00
Lee Robinson
f3cbdf0b02
Document how to use basePath with next/image. (#23123)
Supersedes https://github.com/vercel/next.js/pull/23115 for more clarity and a better recommendation.
2021-03-16 19:56:41 +00:00
Shane Rogers
308c2beca2
Add image base path configuration option (#23115)
I similarly [couldn't find this info](https://github.com/vercel/next.js/issues/19711#issuecomment-750414110) in the docs about configuring the image path when using an app `basePath`, so thought I'd add it.
2021-03-16 17:13:24 +00:00
Abdullah Mzaien
e36eb381da
Duplicate scroll description (#23103)
- `scroll` - Optional boolean, controls scrolling to the top of the page after navigation. Defaults to `true` and 
  - `scroll`: Scroll to the top of the page after a navigation. Defaults to `true`
as options for router.push
2021-03-16 16:39:14 +00:00
René Keller
44081d0852
fix(lib/db): type mismatch (#23107)
Fixes "Type 'string' is not assignable to type 'number'." TS warning
2021-03-16 10:31:15 +00:00
Lee Robinson
9431439c6d
Add note about next/export to Image Optimization docs. (#23088)
https://github.com/vercel/next.js/discussions/19065#discussioncomment-484842
2021-03-16 01:05:14 +00:00
JJ Kasper
d680ba65a6
v10.0.10-canary.0 2021-03-15 19:59:56 -05:00
Shu Ding
85499b5375
Revert "Revert "[a11y] Route Announcements"" (#23086)
Reverts vercel/next.js#23082
2021-03-15 20:18:11 +00:00
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
Alex Safian
3063d3b8ff
Update pages.md (#23064)
The `path` variable must be an array of objects which has a `params` key. This code will prevent reader confusion.
2021-03-15 02:44:58 +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
Karthikeyan Ranasthala
c1b2b3f91f
Add an example for styled-jsx with content security policy (#23021)
This is an example on how to use styled-jsx with content security policy.
2021-03-12 19:03:24 +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
Kenneth Lum
2af5a0e47c
it is props: { posts } (#23004)
changing `props: posts` to `props: { posts }`
2021-03-12 08:11:01 +00:00
Kenneth Lum
e7a22afe2f
When there is data already, the props is props: { data } (#23003)
When there is data already, the props is props: { data }
Would be better if the `props: { }` part is `props: { data }`
2021-03-12 08:03:10 +00:00
JJ Kasper
62967fc667
Add note for loading env files during testing (#22982)
This adds a note to the environment variables documentation to mention how the env files can be loaded using the `@next/env` package as this has been brought up a few times. 

x-ref: https://github.com/vercel/next.js/issues/22936#issuecomment-796665303
x-ref: https://github.com/vercel/next.js/issues/17903
2021-03-12 00:47:42 +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
Nabil Boussouf
371aa608b2
Install tailwindcss as a development dependency (#22964)
Set tailwindcss as a development dependency https://tailwindcss.com/docs/guides/nextjs#install-tailwind-via-npm
2021-03-11 14:16:36 +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
Lee Robinson
fa02b197f5
Fix typo in source maps documentation. (#22952) 2021-03-10 16:41:01 +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
e9a1d8fd42
Add documentation for new static 500 behavior (#22888)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-03-09 12:45:31 +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
Yuki Takemoto
635a98e2fd
Fix typo (#22891)
This PR fixed a typo in api reference.
2021-03-09 01:37:52 +00:00
DOUGES
40f4cf4866
chore: adds compiled css example (#22786)
Hiya! I was asked to add an example of how to use [Compiled](https://compiledcssinjs.com/) with Next.js, figured I might as well at it to the source 😄. Let me know if there's any changes needed.
2021-03-08 21:25:49 +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
Jason Emery
81b05256dd
Update router.md (#21899)
include scroll option documentation for router.push
2021-03-08 13:52:37 +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
Sebastian Andil
87ccebf5fd
Update module-path-aliases.md (#22739)
Add note about restarting dev server on changes to tsconfig / jsconfig
2021-03-08 14:19:31 +01:00
harshit bhalla
e235f7fa4e
Corrected the url to strapi documentation (#22870) 2021-03-08 13:06:13 +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