Commit graph

6040 commits

Author SHA1 Message Date
TodorTotev
5a5e6004d7
Refactor with redux persist example (#13338)
Related to [11014](https://github.com/zeit/next.js/issues/11014)

First and most important, removed the getInitialProps and used getStaticProps.

Then, I refactored Counter, DataList and Examples components.
I have refactored them from class-based components to functional. Also in each component the redux implementation was refactored using the new hooks API, which resulted in ~40% less code.

If you want me to change anything or you are not satisfied with any given change, I'm open to suggestions.
2020-05-25 17:28:39 +00:00
Giuseppe
73c8b8ca92
Update with-style-sheet example (#13323) 2020-05-25 17:11:50 +00:00
TodorTotev
f3ea363df7
Refactor with redux thunk example (#13336)
Related to [11014](https://github.com/zeit/next.js/issues/11014)

1. I have changed the component from class to functional.
2. I have removed the getInitialProps and used getStaticProps instead.
3. I have removed the redundant connect to redux @ the index page, due to the fact that now we can dispatch the action with the required hook.

If you want me to change anything or you are not satisfied with any given change, I'm open to suggestions.
2020-05-25 16:55:33 +00:00
TodorTotev
cc4b0c7b40
Refactor with redux saga (#13342)
Related to [11014](https://github.com/zeit/next.js/issues/11014)

Upgraded all the packages from package.json, removed the saga-wrapper package since it is totally outdated to today's use.

I have refactored the whole example using the new API of the next-redux-wrapper package, using their new support of "getStaticProps".

All of the class components were converted to functional, using the new redux hooks API.

If you want me to change anything or you are not satisfied with any given change, I'm open to suggestions.
2020-05-25 16:21:35 +00:00
Ayhan
0dd818b79a
Update Amp dependencies (#13354) 2020-05-25 16:05:08 +00:00
Ty Mick
f6374e6649
Fix "Commitment to Open Source" link in contributing.md (#13352)
https://vercel.com/blog/oss redirects to https://vercel.com. Is https://vercel.com/oss the right URL?
2020-05-25 15:35:44 +00:00
Jan Potoms
8079fa27c1
skip node internals (#13345) 2020-05-25 16:21:06 +02:00
Takumasa Sakao
43a54fb338
Fix wrong README of blog-starter-typescript example (#13330)
* Replace blog-starter to blog-starter-typescript

* Fix unnecessary replacement
2020-05-25 08:57:17 +02:00
Maxi Gimenez
f17d78f888
chore(next): export/lib/next-server missing types (#13320) 2020-05-24 22:44:05 +00:00
Joe Haddad
82dfe157c6
Fix method return shape (#13299)
* Fix method return shape

* adjust type

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-05-24 14:38:27 +02:00
Joe Haddad
89bc74909b
v9.4.3-canary.0 2020-05-23 21:52:57 -04:00
Joe Haddad
2ecb7c6e37
Fix retry for Windows tests (#13296)
Noticed these tests failed for Windows on `canary`, then traced down the cause.
2020-05-24 01:34:06 +00:00
Maël Nison
52fd6b1832
Allows multiple lines for Module not found errors (#10797)
Next is currently removing useful information from the PnP error messages.

Before:

```
Module not found: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies
```

After:

```
Module not found: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies

Required package: foo (via "foo/components/Avatar")
Required by: /home/arcanis/foo/bar.tsx
```
2020-05-23 23:11:46 +00:00
James Mosier
846ec74013
Special case default template in CNA (#12109)
This addresses #11910 in which `-e default` was not working because there was no example with the name `default`. This PR checks if a user inputted `default` as the example argument for `create-next-app` and if so it will use the local `default` template in the create-next-app directory.

Closes #11910
2020-05-23 22:50:31 +00:00
Mohsen Azimi
9fb2432b14
Add ThemedStyleSheet.registerInterface to react-with-styles example (#13284)
My [draft PR was merged](https://github.com/zeit/next.js/pull/13193) so let's at least keep the code in canary in a working state.
2020-05-23 22:12:24 +00:00
Joe Haddad
3ee0a1f41a
Wait for flush before firing routing event (#13287)
This waits for the render to be committed to DOM before we render the route change complete event (no longer sync in new React).

We have tests that ensure this resolves.

---

Closes #12938
2020-05-23 21:54:11 +00:00
Joe Haddad
d6ad201f80
[Fast Refresh] Upgrade react-refresh (#13285)
Closes #13254
2020-05-23 21:37:56 +00:00
Joe Haddad
12e0db040c
Fix linting 2020-05-23 17:17:26 -04:00
Shu Uesugi
de2363bd91
Update debugging docs (#13270)
* Update debugging docs

* typo

* Update docs/debugging.md

Co-authored-by: Luis Alvarez D. <luis@vercel.com>

* Update docs/debugging.md

Co-authored-by: Luis Alvarez D. <luis@vercel.com>

* Clarify

* Move to advanced features

Co-authored-by: Luis Alvarez D. <luis@vercel.com>
2020-05-23 15:58:33 -05:00
Gerald Monaco
ddeadc1dc9
Defer Page Registration (#11054) 2020-05-23 16:38:48 -04:00
JJ Kasper
72e5b8db7c
Consolidate non-SSG branch in renderToHTMLWithComponents Cont. (#13274)
This continues https://github.com/zeit/next.js/pull/12501 and resolves the merge conflicts since we aren't able to update that branch and would like to land this change

Closes: https://github.com/zeit/next.js/pull/12501
2020-05-23 20:30:32 +00:00
Koji Sugimoto
dc1658f107
[Examples] Added blog-starter-typescript (#12981)
* feature: add blog-starter-typescript

* chore: edit tailwind.config

* Fix linting

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-05-23 20:34:35 +02:00
Joseph Knowles
83827f76d3
Uncomment private key (#13277) 2020-05-23 11:19:28 -05:00
Jairo Tylera
e66bcfa838
Add support for sass-loader prependData option (#12277)
This PR adds support for prepending sass code before the actual entry file.

It's common for developers to import their sass mixins and variables once on their project config so they don't need to import them on every file that requires it. Frameworks like gatsby and nuxt.js already support that handy feature.

The way it works is:

```
/// next.config.js
module.exports = {
  experimental: {
    sassOptions: {
      prependData: `
        /// Scss code that you want to be
        /// prepended to every single scss file.
      `,
    },
  },
}
```

Fixes #11617 and duplicates
2020-05-23 13:37:48 +00:00
Vincent Voyer
aa51f2fcef
docs(debugging): explain how to debug in Chrome DevTools/VS Code (#10807)
This new documentation page explains how to debug your backend and frontend code in Chrome DevTools/VS Code. This works perfectly with full source map support for both Node.js and React code.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-05-23 14:47:28 +02:00
Sam Bokai
6ca26bd960
Rename import to solve conflicting usage of Error constructor (#13256) 2020-05-22 17:54:32 -05:00
Shu Uesugi
94e20be204
With mux video readme updates (#13253)
* Add demo and note to with-mux-video

* Update README.md
2020-05-22 16:47:39 -05:00
Dylan Jhaveri
32dece149e
Add example: with-mux-video (#13120)
* yarn create next-app

* create an upload show page

* create upload page to handle in-progress upload and asset when it is ready

* move things to a layout component

* add some button styling

* poll for updates intelligently by dynamically setting refreshInterval on SWR hook

* better title

* edit gitignore, add MIT license use next 'latest'

based on feedback from https://github.com/zeit/next.js/pull/12723

* add some messages and spinner to make this a little nicer

* update README with environment variables info and Mux account info

* add .now to gitignore

* cleaner uploading state - redirect to /v/:playback_id when complete

* hardset image width in footer

* remove unused styles

* adjust title font size on mobile and adjust footer height on mobile

* use upchunk 1.0.8 so we don't have to dynamically load it

* cleaner error message handling

* fix brief error from returning Router on the render

* yarn lint-fix

* update README with note about .env.local

* add min height so the layout doesn't shift after selecting a file

* set poster attribute at video element

* use getStaticProps and fallback:true to render meta tags for social sharing

* create a pages/asset/:id route that we can be on while in the preparing state

* add copy about Mux, add twitter share widget

* add flash message about video ready for playback

* call it pre-rendered instead of server-side rendered

* pre-rendering, not server-side rendering

* Next.js not NextJS

* handle asset creation errors in the UI

* call hls.destroy() when the component is unmounted

* Updated readme and renamed .env.local

* Updated description

* add suggested patch with links to source code https://github.com/zeit/next.js/pull/13120#issuecomment-632858572

* Added vercel.json

* Updated some links

* Removed Prerequisites

Co-authored-by: Luis Alvarez <luis@vercel.com>
2020-05-22 16:13:12 -05:00
TodorTotev
cb1d744151
with-monaco-editor-example-fix (#13186)
* Modified nextjs config so that it works with all types of fonts and images.

* Update next.config.js

* Fix code

Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-05-22 20:11:01 +02:00
Mohsen Azimi
c67908c9a5
Upgrade react-with-styles to version 4 (#13193)
Currently failing because `withStyles` can't read the interface from context:


```
Unhandled Runtime Error
TypeError: Cannot read property 'createLTR' of undefined
webpack-internal:///./node_modules/react-with-styles/lib/withStyles.js (150:33)
```

Manually registering the interface resolves the issue:

```diff
diff --git a/examples/with-react-with-styles/pages/_app.js b/examples/with-react-with-styles/pages/_app.js
index 91d09a2a9..a393572b8 100644
--- a/examples/with-react-with-styles/pages/_app.js
+++ b/examples/with-react-with-styles/pages/_app.js
@@ -2,11 +2,16 @@ import App from 'next/app'
 import React from 'react'
 import WithStylesContext from 'react-with-styles/lib/WithStylesContext'
 import AphroditeInterface from 'react-with-styles-interface-aphrodite'
+import ThemedStyleSheet from 'react-with-styles/lib/ThemedStyleSheet'
 
 import defaultTheme from '../defaultTheme'
 
 class MyApp extends App {
+    constructor(props) {
+        super(props);
+        ThemedStyleSheet.registerInterface(AphroditeInterface)
+    }
   render() {
     const { Component, pageProps } = this.props
```

But that's not how it is documented. I'm following up with react-with-styles to see if this is a bug.
2020-05-22 17:54:36 +00:00
Jan Potoms
e50620b981
Use memoizedPagechecker (#13191)
It seems like this was supposed to use the memoized version of `pageChecker`. I also updated the function to memoize promises instead of promise results. Just in case this function ever gets called concurrently.
2020-05-22 17:37:54 +00:00
Jack Moore
ed2ca820b0
Created Expo TypeScript example project (#13182) 2020-05-22 19:21:46 +02:00
Ian Sutherland
1a53f4500a
Update custom server docs (#13172) 2020-05-22 19:19:36 +02:00
Joe Haddad
1577ae5ce0
Fix dotenv file loading order (#13161)
This matches the `dotenv` spec:
https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use

---

Closes #13015
2020-05-22 17:13:16 +00:00
Alejandro Ñáñez Ortiz
71d899f128
Add urql to the examples list (#13006)
* Install UrQL dependencies

- Created the examples folder `with-urql`
- Installed the dependencies
- Got a simple index.js page setup

* Basic UrQL example

- Connects to Pokemon GraphQL API

* Loading Pokemon list + Pokemon page

- Using `isomorphic-unfetch` because `urql` uses `window.fetch` to get data because we need to query the GraphQL API using Node (in `getStaticProps`)
- Deleted `_app.js` since we're not using UrQL to query data on the clientside
- Put all GraphQL related code in `/graphql`

* Update README for UrQL example

* Update urql casing

* Update examples/with-urql/graphql/client.js

Co-authored-by: Joe Haddad <timer150@gmail.com>

* Update examples/with-urql/pages/index.js

Co-authored-by: Joe Haddad <timer150@gmail.com>

* Update examples/with-urql/pages/pokemon/[name].js

Co-authored-by: Joe Haddad <timer150@gmail.com>

* Fix linting

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-05-22 18:56:34 +02:00
Luis Alvarez D
589f44ef94
Ignore nullish user configs (#10250) 2020-05-22 16:46:36 +00:00
xliusstk
6c5efd7b09
Fix ssr-caching example (#12180)
cacheable-response.get expects a get(req, res) method signature:
https://www.npmjs.com/package/cacheable-response#get

Before the change:
```
curl -s  -v http://localhost:3000/blog/first 2>&1 | grep HTTP/1.1
> GET /blog/first HTTP/1.1
< HTTP/1.1 404 Not Found
```
After the change:
```
curl -s  -v http://localhost:3000/blog/first 2>&1 | grep HTTP/1.1
> GET /blog/first HTTP/1.1
< HTTP/1.1 200 OK
```

This is a partial fix of https://github.com/zeit/next.js/issues/12019 to make the example work. However it doesn't fix the error 
```
(node:62360) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
``` , which will need a change at server/next-server.ts

See related issue:
https://github.com/zeit/next.js/discussions/11525 
https://github.com/zeit/next.js/issues/11665
2020-05-22 16:29:37 +00:00
Marcus Silva
0b9475624f
chore: remove-redundant-example-import (#13175)
This issue is related to #12964 

**I changed the following examples:**
`with-zeit-fetch` 
`with-why-did-you-render`
`with-styletron`
`custom-server-fastify`
`custom-server-express`
`with-why-did-you-render`
`custom-server-hapi`
`custom-server-koa`
`custom-server-polka`
`custom-server-typescript`
`progressive-render`
`ssr-caching`
`svg-components`
`using-preact`
`with-ant-design`
2020-05-22 16:13:37 +00:00
Joe Haddad
3f11daa9c0
Use correct chalk import (#13235)
This PR imports our bundled dependency instead of re-adding it to install-time.

---

Closes #13166
2020-05-22 15:56:32 +00:00
Willian Justen
44d74e399f
chore: Remove react redundant imports on examples (#13169)
* Remove React redundant import on `analyze-bundles` example

 Co-authored-by: Marcus Silva <mvfsillva@gmail.com>

* Remove React redundant import on `api-routes-apollo-server-and-client-auth` example

Co-authored-by: Marcus Silva <mvfsillva@gmail.com>

* Remove React redundant import on `custom-server` example

    Co-authored-by: Marcus Silva <mvfsillva@gmail.com>

* Remove React redundant import on `custom-server-actionhero` example

Co-authored-by: Marcus Silva <mvfsillva@gmail.com>

Co-authored-by: Marcus Silva <mvfsillva@gmail.com>
2020-05-22 17:37:09 +02:00
TodorTotev
8618ab85ad
More redundant imports @ examples (#13190)
Again, related to [12964](https://github.com/zeit/next.js/issues/12964)

After checking all the other examples and the ongoing pull requests, I believe that with this PR being merged, all the examples should be free of redundant react imports.
Let me know if you want me to edit anything that you don't like.

Regards

with-typescript
with-atstroturf
with-atlaskit
with-styletron
with-styled-components-rtl
with-stylesheet
with-stomp
with-stitches-styled
with-stitches
with-slate
with-sentry-simple
with-sentry
with-segment-analytics
with-rematch
with-relay-modern
with-reflux
with-redux-wrapper
with-react-relay-network
with-react-native
with-react-multi-carousel
with-react-jss
with-react-helmet
with-react-ga
with-quill-js
with-prefetching
with-google-analytics-amp
with-google-analytics
with-framer-motion
with-flow
with-firebase-hosting
with-firebase-cloud-messaging
with-firebase-authentication
with-expo
with-dynamic-app-layout
with-draft-js
with-cxs
with-cerebral
with-ant-design-mobile
with-algolia-react-instantsearch
using-preact
progressive-render
2020-05-22 15:33:04 +00:00
Balázs Orbán
4cd8dce3f2
make .env clickable in terminal (#12210)
A minor chage, that makes `.env` clickable in terminals. When Next.js starts, I am showing some variables in the terminal. To jump to the .env file, adding `./` in front of it makes it clickable.

Example:
![image](https://user-images.githubusercontent.com/18369201/80307289-5fe0d300-87c8-11ea-9ba1-781cf82bc500.png)

One disadvantage is that I am unsure how well this is supported in terminals in general (I am using VSCode's built-in one here)

Any other disadvantages?
2020-05-22 15:16:30 +00:00
Tim Neutkens
e4d22cec63 Fix formatting of older PR that passed tests 2020-05-22 14:36:01 +02:00
Arnar Kári Ágústsson
6ac2f4b74d
With reason relay example (#12080)
* Add with-reason-relay example

* update gitignore

* Add missing components

* Add _app.js wrapper

* Move records to wait for results

* Update readme

* Upload schema

* Add call to query hook to get viewerData with getFragmentRefs

* Move relay env setup to seperate module

* remove unused code

* lint fixes

* prettier fix
2020-05-22 12:13:44 +02:00
Tim Neutkens
b91e570a33
Move csp examples (#13221)
Fixes #12042
2020-05-22 11:35:27 +02:00
Luis Alvarez D
fca88d1cfe
Updated docs (#13205)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-05-22 10:36:45 +02:00
Joe Haddad
3d852d895f
Better formatted Sass errors (#13211)
https://twitter.com/timer150/status/1263689549898829829
2020-05-22 05:25:02 +00:00
Luis Alvarez D
195e3e0ac3
[Docs] Replace hot reloading with fast refresh (#13207)
- Mention React Fast Refresh instead of hot reloading in docs
- Added a mention of our deployment docs in the main documentation page
- replaced `npm init` with `npx`
2020-05-22 02:40:06 +00:00
Prateek Bhatnagar
75b0bfff9c
bug fixes for Lint routing (#13111)
- bug fixes in `@next/eslint-plugin-next`.
- adds rules to `recommended` config.
2020-05-21 23:42:20 +00:00
Maxi Gimenez
57535b5afc
chore(next/build/babel): missing types (#13189) 2020-05-21 12:57:04 +00:00