Commit graph

6059 commits

Author SHA1 Message Date
Jesse Jafa
2e5a7c8cc8
Removed redundant react imports from with-overmind (#13422)
Per https://github.com/zeit/next.js/issues/12964

Removed redundant react imports from next.js/examples/with-overmind
2020-05-27 04:12:07 +00:00
Joe Haddad
202be4ceb8
v9.4.3-canary.1 2020-05-26 23:25:53 -04:00
Joe Haddad
8b72b9e2de
[Experimental] Do not type check twice (#13419)
The experimental modern mode runs the type checking plugin twice, which **occasionally** suffers from a race condition that hangs the build.

This PR fixes type checking to only be run once.

While this test cannot 100% reproduce/capture the race condition, I don't feel strongly about the test case:

- We're planning on eliminating this type checking plugin ASAP (for a faster alternative)
- Modern mode implementation as-is will probably go away with webpack 5
2020-05-27 02:58:16 +00:00
Christian Stuff
d94e8db531
Add failing paths to export error summary (#10026)
Closes #9990 by collecting all paths with errors during `next export` and reporting them sorted in the error summary at the end.

It will produce an output similar to:

```
    Error: Export encountered errors on following paths:
        /nested/page
        /page
        /page-1
        /page-10
        /page-11
        /page-12
        /page-13
        /page-2
        /page-3
        /page-4
        /page-5
        /page-6
        /page-7
        /page-8
        /page-9
        at _default (/app/next.js/packages/next/dist/export/index.js:19:788)
        at process._tickCallback (internal/process/next_tick.js:68:7)
```

I tested the output with the `handle-export-errors` integration test suite, but I'm not sure how to gracefully test this added output.
I thought of collecting all page source files with [recursiveReaddirSync](2ba352da39/packages/next/next-server/server/lib/recursive-readdir-sync.ts) but it seems I can't import it in js test files:

```
SyntaxError: /app/next.js/packages/next/next-server/server/lib/recursive-readdir-sync.ts: Unexpected token, expected "," (11:5)

       9 |  */
      10 | export function recursiveReadDirSync(
    > 11 |   dir: string,
         |      ^
      12 |   arr: string[] = [],
      13 |   rootDir = dir
      14 | ): string[] {
```

The test itself could look like:
```js
  it('Reports failing paths', async () => {
    const { stderr } = await nextBuild(appDir, [], {
      stdout: true,
      stderr: true,
    })
    const pages = []
    // collect pages to be ['/page', '/page-1', ... etc.]
    pages.forEach(page => {
      expect(stderr).toContain(page)
    })
  })
```
2020-05-26 19:50:25 +00:00
JJ Kasper
fafa16f350
Bundle env configs in serverless mode (#13406)
As discussed this adds bundling of `.env` files in `serverless` mode so that the environment values are also available when deploying with this target

closes: https://github.com/zeit/next.js/issues/13332
2020-05-26 19:01:57 +00:00
Fabio Benedetti
235b3befcc
fix(client-routing): page render (#13305)
Fixes https://github.com/zeit/next.js/issues/12935
2020-05-26 17:50:06 +00:00
Joe Haddad
7bd52b8dee
docs(static-html-export): note getServerSideProps (#13401)
x-ref: #12313
2020-05-26 17:16:04 +00:00
Joe Haddad
dcfa35faa6
Fix with-sentry-simple example (#13404)
Previous referencing the incorrect `Error` global.
2020-05-26 16:58:03 +00:00
Marco Moretti
b3e45fab5e
feat(cli): use default template when GH is offline (#12194)
fix #12136 

I add a prompt if there is an error when trying to download example files.
Maybe could be better to add an error class and in create-app.ts on every "console.error" trow a new Exception and manage it in catch. What you think ? 👯
2020-05-26 16:39:18 +00:00
Jesse Jafa
2828b01950
Fixing Redundant React imports on next.js/examples (#13384)
Per https://github.com/zeit/next.js/issues/12964

* with-ant-design
* with-dynamic-import
* with-iron-session
* with-monaco-editor
* with-next-page-transitions
* with-react-with-styles
* with-style-sheet
* with-why-did-you-render

Tested each example, working as intended, no additional issues presented
2020-05-26 15:03:58 +00:00
JJ Kasper
d56d5e6855
Update PR stats action branch check (#13394) 2020-05-26 09:44:17 -05:00
Jan Potoms
cefbcadf45
Make page path case sensitive in dev (#8848)
URL paths are case sensitive, MacOS file system is case insensitive. This PR makes sure development mode doesn't find pages that don't have the casing as specified in the URL.

Will clean up and write a test when agreed on this approach.

Fixes https://github.com/zeit/next.js/issues/8825
Fixes https://github.com/zeit/next.js/issues/8847
Fixes https://github.com/zeit/next.js/issues/9080
2020-05-26 12:50:28 +00:00
TodorTotev
7ec57c6c93
Refactor with rematch example (#13392) 2020-05-26 08:24:36 -04:00
Jesse Jafa
658e0f8d34
with-overmind server error because of incorrect getStaticProps return statement (#13385)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-05-26 11:06:46 +02:00
Jesse Jafa
5eac7cc042
Fixed with-iron-session to work on Windows systems (#13386)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-05-26 10:57:56 +02:00
Jan Potoms
67df497092
Convert export worker to typescript (#13381)
This is purely adding types except for the line:

```js
params = getRouteMatcher(getRouteRegex(page))(path) || undefined
```

Also added a couple of `@ts-ignore` as to avoid having to make any more functional changes
2020-05-26 08:50:51 +00:00
Daniel Paz
599d6f71bb
Update Monaco Editor Example (#13369)
Changed the URLs inside the Monaco Editor Example: https://github.com/zeit/next.js/tree/canary/examples/with-monaco-editor

Converted the worker URL to start with the base URL.

The reason is if you use the Monaco example anywhere but in the main `pages` folder, it won't work since it uses a relative URL instead.

For example if we'll move the code to `pages/room/index.js` it won't work since it will try to search for the files inside `room/_next/_static/` instead of `_next/_static/`.

The base URL I added fixes the problem.
2020-05-25 22:22:28 +00:00
Jan Potoms
2e1a322d6f
Add a few extra types (#13363)
Added a few extra types here and there while I was digging through the code
2020-05-25 21:15:56 +00:00
Erik
268d3572bc
[examples] with-ts-eslint-jest example app (#12025)
* set up with-ts-eslint-jest example app

* eslint ignore new app bc it has a conflicting eslintrc

* make eslint + husky setup manual

* clarify app README setup notes

* move page tests out of pages/ dir

* Simplifying configs

* extend "prettier"

* format fix

* Updated rules

* Added husky configs and removed debug option

* Removed notes and configuration

* Updated pages

* Added links to readme

* Added example to .prettierignore

* Updated snap

* Make the lint work

Co-authored-by: Luis Alvarez D <luis@vercel.com>
2020-05-25 13:16:06 -05:00
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