Commit graph

6129 commits

Author SHA1 Message Date
Tim Neutkens
b124ed2e14
Added no-shadow rule to eslint (#13645)
Was going through _document and noticed some variable shadowing going on. Added a rule for it to our eslint configuration and went through all warnings with @Timer.
2020-06-01 21:00:22 +00:00
Rafael Almeida
2bf8153c27
[with-typescript] Remove React.FC (#13643)
The motivation for this PR is well explained here: https://github.com/facebook/create-react-app/pull/8177
I can expand it to the other examples too if you agree with the change
2020-06-01 20:41:56 +00:00
Tim Neutkens
6f8ef70cb0
Remove middleware function that is never called (#13642)
Follow-up to #12218, missed this bit of code.
2020-06-01 20:12:58 +00:00
Shu Uesugi
1f49400a32
Remove unnecessary catch (#13639)
This undoes https://github.com/vercel/next.js/pull/13138 as the rename is done.
2020-06-01 19:27:05 +00:00
Todor Totev
795d9319a6
Fix with antd ssg (#13611)
Closes #12664 
Closes #13604 

The culprit was not only changing the library directory, but also having the icons version past 4.0.6. Also, the components which used the library had to be adjusted according to the new changes.

Confirmed that it works both in production and development. Confirmed that it builds on dev and production.

![Alt Text](https://media.giphy.com/media/dZ46aA1Rs7Oi1wSQKU/giphy.gif)
2020-06-01 19:08:59 +00:00
Joe Haddad
7d038dfef1
Suggest npx over npm init (#13637)
This updates old examples to the more universal `npx` command.

Fixes https://github.com/vercel/next.js/discussions/12103
2020-06-01 17:36:57 +00:00
Akhila Ariyachandra
032ca0364d
Updated with-magic example with new Environment Variables Support in Next.js 9.4+ (#13623) 2020-06-01 19:19:48 +02:00
Jan Potoms
8bac412845
make getStaticPaths work with optional catch-all routes (#13559)
Fixes https://github.com/vercel/next.js/issues/13524

To do:
- [x] fix dev mode
- [x] there's a ~route ordering or~ trailing slash issue with top level catch-all (current tests reflect that)
- [x] in this test `/get-static-paths/whatever` should fall back to `/[[...optionalName]].js` since `fallback` is `false` in its `getStaticPaths` method. ~Currently seems to 500~ must have been a glitch
- [x] add tests for `null`, `undefined` ~and `false`~ behavior as well (if decided these are valid)
- [x] ~add tests for string params as well~ this is not allowed for catch-all routes
- [x] test behavior when fallback is enabled and a top level catch-all exists
2020-06-01 17:08:34 +00:00
Joe Haddad
9dede1011a
v9.4.5-canary.4 2020-06-01 10:08:35 -04:00
JJ Kasper
c0368e1b09
Handle encoding for data requests and fix fallback response (#13622)
This addresses some errors for `/_next/data` requests where encoded `/` values in dynamic route param would cause invalid behavior, a headers already sent error would be shown when sending the fallback page in development, and when rendering the `_error` page for a data request the error response would still be treated as a data request. 

This also adds test cases for these errors to prevent regression
2020-06-01 13:25:00 +00:00
Luis Alvarez D
ee87e5d811
Update links in environment variables documentation (#13621)
- The first links were updated to match the new titles
- Removed the `# .env.local` comment as it's redundant
- Added links to the sections related to data fetching
2020-05-31 23:24:14 +00:00
Tim Neutkens
c384ca3710
Update environment variables documentation (#13618)
Based on feedback from @mcsdevv's team. Solves many of the issues users run into with the current docs.
2020-05-31 21:43:49 +00:00
Tim Neutkens
3dc24bbd79
Update waitUntilValid parameters (#13612)
Since the reload function was removed this parameter is no longer needed 💯
2020-05-31 21:28:23 +00:00
Luis Alvarez D
7a1724f326
[Examples] Remove unused file from with-redux (#13570)
Leftover from a past PR
2020-05-31 21:11:35 +00:00
Luis Alvarez D
48c8440016
Add .vercel to gitignore (#13595)
Also added `.now`, this should make sure that if the Vercel CLI is used inside the examples to deploy a project, the project folder is not added to the list of changes.
2020-05-31 20:53:08 +00:00
Martin Bavio
f8f308d6dd
Fix examples using __NEXT_DATA__ (#13567)
This PR fixes https://github.com/vercel/next.js/issues/4883.

It introduces a new global variable (`window.__REHYDRATE_IDS`) only when necessary.

In the case of the `with-react-with-styles` example, rehydration isn't happening, so I removed the creation of the variable. 

In the case of the `with-react-intl` example, the information doesn't seem to be set anymore on `__NEXT_DATA__`, so I just removed the default reference to it.
2020-05-31 20:20:01 +00:00
Jan Potoms
f69757408e
Update browserslist/caniuse-lite (#13605)
Looks like `caniuse-lite` is out of date and causing test failures. 
- I upgraded both `browserslist` and `caniuse-lite` to latest semver compatible version.
- This seemed to cause changes in ncc compiled files, so recompiled.
- `lint-staged` failed on these files even though they should be ignored. As a fix, I applied the advice from https://github.com/okonet/lint-staged#how-can-i-ignore-files-from-eslintignore-
- Updated some test snapshots. 🤔 not sure this is the way to go
2020-05-31 19:37:01 +00:00
Todor Totev
11597655d9
Enhance with redux thunk example (#13576)
* Refactored the store so that it doesnt use getInitialProps

* Applied the changes in the _app file

* Refactored the wrapper so that it uses the new store flow

* Removed the old redux syntax

Instead of passing the state from the parent component, I have used the new redux hooks to retrieve the current state.

* The clock no longer requires state to be passed too

* Updated the variable names

* forgot to bring back hot reloading

* Applied requested change.
2020-05-31 11:53:01 -05:00
Simon Knott
a32fa4243a
Add ETag Support (#12802)
Closes #12045 

This PR adds support for [etags](https://tools.ietf.org/html/rfc7232#section-3.2) to Next.js' API routes, which will improve user experience and decrease network traffic by enabling usage of etag-based caching.
2020-05-30 19:23:24 +00:00
Todor Totev
bb23d37b28
Enhance with redux persist (#13577)
* Moved the state to the clock component

* Refactored the store according to the new requirements

* Refactored _app so it uses the new store

* This file is no longer needed

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-05-30 13:00:37 -05:00
Thor 雷神
ca816df4de
Stripe example updates (#13581)
- Update to latest stripe-node version and pin the exact version so the Types won't go out of sync
- Add the env var changes for next 9.4.4 (https://nextjs.org/blog/next-9-4#new-environment-variables-support)
  - Remove `next.config.js` as no longer needed.
- Add the Deploy to Vercel button
2020-05-30 17:32:36 +00:00
MichelleLucero
3dbddfa02a
[ EXAMPLES ] Added with-mongodb example (#13028)
* created with-mongodb, Next.js + MongoDB

Co-authored-by: Shania Dhani <31454777+sdhani@users.noreply.github.com>
Co-authored-by: Michelle Lucero <31500626+MichelleLucero@users.noreply.github.com>
Co-authored-by: Chi Shing Lee <60354073+chislee0708@users.noreply.github.com>

* Update examples/with-mongodb/README.md

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>

* modified for dotenv and environment var setup

* removed extra instructions on readme, linked it to the MongoDB guides

* changes to environment var

* replaced document with react logic

* removed Pet header

* removed isomorphic-unfetch

* replaced getInitialProps with getStaticProps (SSG)

* removed console log

* deleted next.config.js file

* fixed prettier styling

* fixed link 404 server rendering issue

* modified server path for delete/edit

* fixed prettier styling

* fixed a typo

* change .env to .env.local

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

* fixed typo, change .env to .env.local

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

* change .env to .env.local

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

* Update examples/with-mongodb/package.json

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

* removed dotenv dev dependency

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

* cleaned up code and instructions

* Update examples/with-mongodb/.gitignore

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

* minor changes to code style and logic

* Updated index page and .env.local.example

* Updated new page

* Don't use SSG for the edit page

* Fixed revalidation issue

* Use es6 for the model

* Updated edit page

* Removed VERCEL_URL

* Updated readme and renamed env

* Added temporal vercel.json

* Removed seed until added with a script

* Updated package.json

* Renamed example in readme

* Renamed example

* Lint fix

Co-authored-by: liulanz <zhengliulan@gmail.com>
Co-authored-by: Shania Dhani <31454777+sdhani@users.noreply.github.com>
Co-authored-by: Chi Shing Lee <60354073+chislee0708@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: sdhani <shania.dhani46@myhunter.cuny.edu>
Co-authored-by: liulanz <37808313+liulanz@users.noreply.github.com>
Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
2020-05-30 12:15:00 -05:00
Martin Bavio
2a473ab42c
Make Linaria great again (#13568)
This PR fixes https://github.com/vercel/next.js/issues/7769.

However, I would like for @jayu to confirm that it's ok to use the latest Linaria 2.0 alpha release. I can confirm from my local testing that it's working as expected.
2020-05-30 00:05:49 +00:00
Pavel Korotenko
ff2a03f30a
Update AMP validation docs (#13525)
Updates docs for AMP validation with usage examples for custom validators added in #9191 and `skipValidation` mode added in #10705
2020-05-29 18:05:51 +00:00
JJ Kasper
ae3c388039
Add support for rewriting non-fallback SSG pages (#11010)
Since non-fallback pages don't rely on the URL for hydration we can allow them to be rewritten to but pages with fallback still can't be rewritten to because we won't be able to parse the correct `/_next/data` path to request the page's data from. I added a test for this behavior and ensured it works correctly on Now.

Example on with fallback false rewrite on Now:
https://tst-rewrite-cp9vge4bg.now.sh/about
2020-05-29 16:33:09 +00:00
Tim Neutkens
6a993d5972 v9.4.5-canary.3 2020-05-29 17:58:45 +02:00
Tim Neutkens
4199de6376
Remove old reloading code (#13554)
This code existed mostly to work around webpack 2 (yes 2.x) limitations where it crashed in certain cases where files didn't exist anymore. We have tests for that behavior and latest webpack has fixed these. Hence why this can be removed 👍
2020-05-29 15:55:36 +00:00
Tim Neutkens
fef3b8c2ce
Update babel config found log to new logging output (#13550)
Updates the message to be in line with .env loading.
2020-05-29 15:08:28 +00:00
Kristoffer K
0199d00671
fix: update ampproject/toolbox-optimizer (#13547) 2020-05-29 15:33:16 +02:00
Tim Neutkens
619493a9be v9.4.5-canary.2 2020-05-29 10:20:37 +02:00
Joe Haddad
92a12a2e20
Replace fork-ts-checker-webpack-plugin with faster alternative (#13529)
This removes `fork-ts-checker-webpack-plugin` and instead directly calls the TypeScript API.

This is approximately 10x faster.

Base build: 7s (no TypeScript features enabled)

- `fork-ts-checker-webpack-plugin@3.1.1`: 90s, computer sounds like an airplane
- `fork-ts-checker-webpack-plugin@4.1.6`: 84s, computer did **not** sound like an airplane
- `fork-ts-checker-webpack-plugin@5.0.0-alpha.14`: 90s, regressed
- `npx tsc -p tsconfig.json --noEmit`: 12s (time: `18.57s user 0.97s system 169% cpu 11.525 total`)
- **This PR**: 22s, expected to get better when we run this as a side-car

All of these tests were run 3 times and repeat-accurate within +/- 0.5s.
2020-05-29 08:16:22 +00:00
Joe Haddad
30fbd9adc9
Speedup tests (#13461)
This PR checks if our tests can be ran faster by disabling source maps unless they're used for the purpose of testing.
2020-05-29 07:57:51 +00:00
Joe Haddad
a62aadddab
v9.4.5-canary.1 2020-05-29 00:47:33 -04:00
Joe Haddad
a7ae54d7cc
refactor(typescript): extract preflight functions (#13510)
This pull request refactors our TypeScript preflight check in preparation for dropping the `fork-ts-checker-webpack-plugin` plugin.

This will make reviewing the subsequent PR much easier.

---

There is no behavior change, so the existing test should cover this adequately.
2020-05-28 23:39:46 +00:00
Jan Potoms
44a65a5e91
Update firebase to fix install errors on node 14 (#13493)
Running
```
yarn
```
in the project while on node.js 14 results into errors with the `grpc` dependency of `firebase`. Updating `firebase` fixes that.
2020-05-28 23:23:35 +00:00
Michael Albertz
44fbc24ccd
[Example] Add with-web-worker example (#13444)
Resolves: https://github.com/zeit/next.js/issues/12545

This PR adds an example which show how to bundle and use WebWorkers in a next.js app.

The issue mentions Typescript, but adding typescript to the example should be fairly simple by following the documentation and seems out of scope for a web-worker example.
2020-05-28 23:07:23 +00:00
Joe Haddad
c64cb60a8e
Fail production build quickly (#13496)
By default, webpack will proceed to run loaders and plugins on all files, even after an error has been encountered during the build process.

This means you might need to wait minutes to see a syntax error encountered in one of your source files. This PR fixes that.
2020-05-28 22:51:30 +00:00
Aral Roca Gomez
6b65efb624
Fix typo (#13523)
Fix a typo.
2020-05-28 22:29:54 +00:00
Prateek Bhatnagar
ac9194ad2c
[experimental] filtering unwanted jsx type in eslint plugin (#13520) 2020-05-28 18:11:29 -04:00
Rubén Sospedra
8d97353d38
Add example with next-translate (#13511)
Motivated by the need to deploy static sites while having a good i18n support¹ ² @vinissimus developed [next-translate](https://github.com/vinissimus/next-translate).

Here's the example ;)

References:
1. https://github.com/vercel/next.js/discussions/10651
2. https://github.com/vercel/next.js/pull/12535#issuecomment-624317275
2020-05-28 21:31:05 +00:00
Mathis Chenuet
16d2235882
Update proxy example to http-proxy-middleware ^1 (#13507)
The current example doesn't work if one try to reproduce it with a recent version of http-proxy-middleware.
2020-05-28 21:00:58 +00:00
Tim Neutkens
ad145d347f v9.4.5-canary.0 2020-05-28 13:56:34 +02:00
Joe Haddad
db5b5a76a8
Update some examples to Vercel (#13477)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-05-28 13:32:29 +02:00
Joe Haddad
aab1fff861
Better NODE_ENV explanation (#13476)
After #12361, I've seen a few users ask "but why".

This PR updates the err.sh link to better explain the restriction.

It also provides an alternative!
2020-05-28 09:10:22 +00:00
Joe Haddad
bee8c31b87
Lint for invalid imports (#13482)
This adds a lint rule to ensure we don't import dev dependencies by accident.
2020-05-28 08:23:10 +00:00
Chandu
5eafc1e92a
refactor(with-redux): update example to use getStaticProps (#13378)
@lfades hope this works. I have updated the example to show differences between client/ssr/ssg initial state in redux. Let me know if something needs to be changed.
2020-05-28 05:12:27 +00:00
Joe Haddad
e6eb32f676
v9.4.4 2020-05-28 00:07:27 -04:00
Joe Haddad
b37d2f1267
v9.4.4-canary.0 2020-05-27 23:44:36 -04:00
Joe Haddad
096d50386e
Do not import from fs-extra (#13481) 2020-05-27 23:43:48 -04:00
Joe Haddad
f0ff77ed88
Add note about GS(S)P imports (#13475)
As reported here:
https://twitter.com/vvoyer/status/1246913957899763712?s=21
2020-05-28 03:22:15 +00:00