Commit graph

6332 commits

Author SHA1 Message Date
James Bowes
166834e578
Update the passHref link (#14584)
Keeping up with section headers in markdown is fun :)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-06-26 11:08:48 -05:00
matamatanot
87bb11c98c
Remove next-cookies and prop-types (#14579) 2020-06-26 14:55:32 +02:00
Tim Neutkens
8393869912 v9.4.5-canary.20 2020-06-26 12:05:38 +02:00
Tim Neutkens
ae542b8525
Use entry option instead of custom make hook (#14527)
Simplifies on-demand-entries a bit.
2020-06-26 04:26:09 +00:00
Luis Alvarez D
c6dc34e4d7
[Docs] Focus on useRouter (#14515)
[ch4109]

Closes https://github.com/vercel/next.js/issues/14500

Our current docs for `next/router` use examples from both `useRouter` and `import Router from 'next/router'`, with this PR I'm unifying the API into `useRouter` (`withRouter` is still going to be mentioned multiple times as it is the HOC alternative) and no longer mentioning that you can import a global `Router` object from `next/router`, not sure if I should mention it at least once but that didn't seem to be required.

I also did some structural changes to the docs for `next/router`, now every method starts with a description, then the implementation and explanation of the parameters of the method, and then the usage example, because every method uses the same `Usage` title the hash for them would be something like `#usage`, `#usage-1`, `#usage-2`, e.t.c, so I'm not very happy with this but it looks good.

Feedback wanted 🙏
2020-06-25 23:35:28 +00:00
JJ Kasper
3b12dbf488
v9.4.5-canary.19 2020-06-25 15:13:12 -05:00
Jan Potoms
fdcc24be6d
Fix native-url path parsing bug (#14442)
Test case for https://github.com/GoogleChromeLabs/native-url/pull/28

Fix https://github.com/vercel/next.js/issues/14419
2020-06-25 17:19:12 +00:00
Jan Potoms
1a838f45aa
Fix windows tests: snapshot backslash needs to be escaped (#14559)
Noticed while trying to get https://github.com/vercel/next.js/pull/14442 tests to pass. The backslash needs to be double escaped in snapshots. Forward slashes aren't escaped, maybe that was the assumption when this test was written?
2020-06-25 17:00:48 +00:00
Hyeungshik Jung
c8dbc7e572
Add [with-storybook-typescript] example (#14398)
Basically this PR adds Next.js 's default TypeScript setting and integrates [@storybook/preset-typescript](https://github.com/storybookjs/presets/tree/master/packages/preset-typescript) into original [with-storybook](https://github.com/vercel/next.js/tree/canary/examples/with-storybook) example. 

However, I thought it may save time for someone who are planning to use storybook with next.js and TypeScript :)
2020-06-25 15:26:47 +00:00
Anthony Short
61c4cdb501
Avoid adding basePath when it's not needed (#14535)
* Avoid adding basePath when it's not needed

When using the `basePath` setting, on pages with params it will fire a router change. This will pass the url pathname in the `as` param using the `getUrl()` function. This means the `as` path will be sent through already including the `basePath`, leading to `/basePath/basePath/path` which will cause the router to throw an error.

* lint

* Add test case and ensure removal

* Make sure to re-add before changeState

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-06-24 21:36:22 -05:00
Nico Domino
fe529c49bf
Add 'with-next-auth' example (#14530)
I accidentally deleted the repo the original PR was based upon haha. 

Anyway, the code was still on my computer so here's a new PR with the same content. 

I addressed the latest comments from @lfades in the old PR (https://github.com/vercel/next.js/pull/14180)

I also updated `next-auth` to `2.1.0` and updated the `<Provider />` component in `_app.js` that needed updating since the latest release.

Let me know if I missed anything else, otherwise I think this should be good to go 👍
2020-06-24 22:24:02 +00:00
Oğuzcan Köse
c690a68b3c
Update index.js (#14528)
* Update index.js

* Update index.js

* Update examples/with-firebase-authentication/pages/index.js

Co-authored-by: Luis Alvarez D <luis@vercel.com>
2020-06-24 16:53:04 -05:00
James Mosier
435bf65784
Warn/revert custom devtool in development mode (#14285)
Warn users and revert their `devtool` when they manually change the `devtool` in development mode. For this addition, I check to ensure the `devtool` is custom (i.e. different than what is set by Next) and has a value (`false` is fine as a custom `devtool`!).

As described in [this issue (13963)](https://github.com/vercel/next.js/issues/13963), changing the `devtool` in development mode can cause issues with performance.

Fixes #13963
2020-06-24 04:15:57 +00:00
Vinci Rufus
afa9bab11a
fixing the docker multi-stage build failures (#14513)
It looks like the docker multi-stage file wasn't building, so fixed that and also cleaned up some of the steps
2020-06-24 03:56:41 +00:00
Steven Bell
a9bfe13ae5
Remove unused package in with-apollo-and-redux example (#14507)
Usage of `apollo/react-ssr` was removed when the example moved to SSG.
2020-06-24 01:33:09 +00:00
JJ Kasper
15367829de
v9.4.5-canary.18 2020-06-23 16:04:34 -05:00
JJ Kasper
5bb081f13f
Handle rendering next/head outside of Next.js (#14511)
This ensures `next/head` doesn't fail to render when being rendered during tests or outside of Next.js' tree

Closes: https://github.com/vercel/next.js/issues/14425
2020-06-23 20:46:40 +00:00
Jan Potoms
574e9d285a
Remove deprecated plugin in favor of the option (#14503)
Not sure if it's still there for a reason, but from  the types for `NoEmitOnErrorsPlugin`
```js
/* @deprecated use config.optimization.noEmitOnErrors */
```
2020-06-23 17:44:51 +00:00
Tim Neutkens
be2a63238a
Webpack 5 build compat (#14498)
Initial PR to make `next build` work with webpack 5, still needs more work to make sure runtimeChunk and such are shared between pages.

- No longer needs the custom ChunkNamesPlugin as the default behavior was changed
- Dropping AMP First client page bundles is now compatible
2020-06-23 15:47:50 +00:00
JJ Kasper
2136c46b89
Ensure dev overlay uses basePath for requests (#14475)
This fixes the `basePath` not being used when making requests for the `react-dev-overlay`. We might want to pass down the `basePath` to the overlay instead of relying on the `process.env` injection although may be fine this way, will defer to @Timer for preferred way to pass this value to the dev-overlay

Closes: https://github.com/vercel/next.js/issues/14470
2020-06-23 15:11:12 +00:00
Tim Neutkens
23db226ea5 v9.4.5-canary.17 2020-06-23 13:39:18 +02:00
Jan Potoms
2142b76e6b
Normalize trailing slashes (#13333)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-06-23 13:38:49 +02:00
Luis Alvarez D
b90fa0a3e1
[Examples] Use the vercel CLI for with-zones (#14480)
[ch3480]

Fixes https://github.com/vercel/next.js/issues/14242
Closes https://github.com/vercel/next.js/pull/14264

Updated the readme of the `with-zones` example to use `vercel dev` instead, starting the app independently has some routing issues that don't happen on production (due to `vercel.json`), with `vercel dev` the app will match the production deployment on localhost.
2020-06-23 09:04:34 +00:00
Jan Potoms
bc2cb2210f
Fix prerendered nested index handling (#14383)
Noticed this while reviewing https://github.com/vercel/next.js/pull/14376. After having done https://github.com/vercel/next.js/pull/13699, this code didn't feel right to me:
```js
function prepareRoute(path: string) {
  path = delBasePath(path || '')
  // this /index rewrite is problematic, it makes pages/index.js 
  // and pages/index/index.js point to the same thing:
  return toRoute(!path || path === '/' ? '/index' : path)
}
```
Added a nested index page to the prerender tests and found it was rendering the `/` route on navigation. This uncovered 2 more places around the dataroute where the index path was not translated correctly.

**edit:**

Just to note that there was nothing wrong with https://github.com/vercel/next.js/pull/14376, the issue was already there, I just noticed it while reading that PR
2020-06-23 05:49:48 +00:00
JJ Kasper
fca768d3d2
Update to rely on dynamic param values from proxy (#12608)
This updates to rely on query values from the proxy when capable to ensure the correct values are provided. This does not remove the `x-now-route-matches` as this is still needed until the values are provided in the query instead for iSSG

x-ref: https://github.com/zeit/now/pull/4196
x-ref: https://github.com/zeit/next.js/pull/12250
x-ref:

Tested against the following updated fixtures from https://github.com/vercel/vercel/pull/4682 with https://github.com/ijjk/next-update-loader

- 08-custom-routes-catchall
- 10-export-cache-headers
- 16-base-path
- 22-ssg-v2
- 23-custom-routes-verbose
2020-06-23 05:31:32 +00:00
Tim Neutkens
1f125f8a7e v9.4.5-canary.16 2020-06-22 23:20:11 +02:00
Tim Neutkens
6c2ce70608
Remove buildId from server-side files (#14413)
Gets rid of the custom function for naming files by removing buildId from the file paths.
2020-06-22 21:12:36 +00:00
Jan Potoms
a7af013350
Update route regex for optional catch-all parameters in named regexes (#14456)
Noticed while working on https://github.com/vercel/next.js/pull/14400 that the optional catch-all handling was missing in `namedRegex`.

This whole file also seemed quite regex heavy so I took a look at the overall logic and changed a few things. It worked by regex escaping the whole route then unescape the dynamic parts. I changed it to only regex escape the static parts, this eliminates unnecessary back and forth escaping. It also makes the dynamic parts handling more readable. The whole logic is less reliant on regexes and just uses simple string manipulation to translate the route into a regex, I didn't measure anything but as an effect this should make it more performant.
2020-06-22 18:16:21 +00:00
Jan Potoms
7078318543
Shave a few bytes off the bootstrap code (#14457)
Saw in the client bootstrap script that the error message was printed alongside the stacktrace. This is unnecessary since the stacktrace already includes the error message. In fact, it seems like browsers already do a good job of printing an error with its stacktrace when you just print them using `console.error`. It's a bit minor, but this should shave off a few bytes of the bundle.
2020-06-22 17:50:17 +00:00
Joe Haddad
6ab0724916
v9.4.5-canary.15 2020-06-22 10:14:07 -04:00
Joe Haddad
67ff62507d
Do not remove no-FOUC styles too early (#14448)
We previously used to remove our FOUC helper inside of the style injection to ensure content was shown as fast as possible.

This behavior, however, was problematic for a few reasons:

1. Large JavaScript chunks would take longer than an animation frame to parse, causing FOUC
1. Rendering would sometimes complete before an animation frame, causing improper effects

To fix the latter, we started removing the no FOUC helper **before** rendering, however, we never fixed the former by removing the dead code.

There's not a great way to test this because the FOUC is so fast and flaky, however, this code really shouldn't exist and isn't likely to be re-added (regress).

Also, we already have FOUC tests that occasionally flake, probably due to this.


Fixes #12448
Fixes #13058
Fixes #11195
Fixes #10404
2020-06-22 14:10:19 +00:00
matamatanot
b560ac4312
Prettier trailingComma default value to es5 since 2.0 (#14391)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-06-22 13:25:24 +02:00
Darsh Patel
19f3306aaa
open click-to-open editor in foreground for windows (#14307)
spent a lot of hours trying to figure out why did the editor window not open in the foreground on windows.

The fix was super simple  : /
Needed to add `detached: true` option in child_process.spawn call

Fixes: https://github.com/vercel/next.js/issues/14016
2020-06-22 05:13:55 +00:00
Jan Potoms
eead55cbaf
Fix prefetch and some other issues with optional catch all (#14400)
Fix https://github.com/vercel/next.js/issues/14290 and a couple other issues around optional catch-all that popped up after writing these tests

Closes https://github.com/vercel/next.js/pull/14344
2020-06-22 03:00:30 +00:00
JJ Kasper
051481c55c
Add example for proxying upstream with custom routes (#14374)
As discussed this adds an example to demonstrate how you can achieve proxying upstream requests that didn't match any pages/assets in Next.js which can be helpful in achieving incremental migration
2020-06-22 00:44:04 +00:00
Andres Alvarez
6424e1f1d9
Add A/B Tests and Feature Flags example (#13629)
## Summary
This PR adds a basic example of how [Tesfy](https://tesfy.io/) could be integrated with Next.js. Tesfy is a project that I've working on during quarantine weekends, mainly to learn new stuff and provide **free** and **unlimited** A/B Tests and Feature Flags while keeping a good performance and the library [size](https://bundlephobia.com/result?p=react-tesfy@1.2.1) as small as possible.

The configuration file could be set up using a [web application](https://app.tesfy.io/) (hosted in Vercel 🎉 ) or by your self.

## Implementation
- Created `with-tesfy` folder
- Added two pages `index.js` and `features.js` to show how experiments and features could be used
- The only thing that must be persisted is the `userId`. Used a cookie to save it.
- Uses `getServerSideProps` to fetch the configuration file and get/create the `userId`.

## Screenshots

There are some screenshots from the web application. Where you can easily configure experiments and audiences per project. Teams and features will soon be added.

![Screenshot 2020-06-01 at 15 40 49](https://user-images.githubusercontent.com/6877967/83414811-60e7ce80-a41e-11ea-9e5c-887c66e80c65.png)
![Screenshot 2020-06-01 at 15 41 02](https://user-images.githubusercontent.com/6877967/83414823-66451900-a41e-11ea-885b-b58e78b042bb.png)
![Screenshot 2020-06-01 at 15 41 11](https://user-images.githubusercontent.com/6877967/83414828-6a713680-a41e-11ea-90a8-8d39a17f19a1.png)

This is my first PR! sorry if I made something wrong 😞 . Any feedback is more than welcome. Also I want to thank you all for the awesome work with Next.js ❤️
2020-06-21 23:59:53 +00:00
Tim Neutkens
ee1cf6f8c4 v9.4.5-canary.14 2020-06-21 11:20:23 +02:00
Tim Neutkens
bef9b56109
Update filename generation for client-side compilation (#14279)
Updates the way filenames are generated for browser compilation.
Notably:
- All entry bundles now have hashes in production, this includes pages (previously pages used a buildId in the path)
- The AmpFiles no longer depends on hardcoded bundle names, it uses the buildManifest instead (internals)
- All cases where we match the page name from the chunk/entrypoint name now use the same function `getRouteFromEntrypoint` (internals)
- In development we no longer include the "faked" `buildId` set to `development` for page files, instead we just use the `/_next/static/pages` path (was `/_next/static/development/pages`). This was changed as it caused unneeded complexity and makes generating the bundles easier (internals)
- Updated tons of tests to be more resilient to these changes by relying on the buildManifest instead of hardcoded paths (internals)

Follow up of these PRs:
https://github.com/vercel/next.js/pull/13759
https://github.com/vercel/next.js/pull/13870
https://github.com/vercel/next.js/pull/13937
https://github.com/vercel/next.js/pull/14130
https://github.com/vercel/next.js/pull/14176
https://github.com/vercel/next.js/pull/14268


Fixes #6303
Fixes #12087 
Fixes #1948
Fixes #4368
Fixes #4255
Fixes #2548
2020-06-20 19:59:47 +00:00
Sebastian Sycz
76673fd880
Update graphql-hooks with memcache (#14364)
Today the cd4178b53e of graphl-hooks and graphl-hooks-memcache has been released, which fixes the problem with Safari.
2020-06-20 19:40:15 +00:00
Todor Totev
5bed435176
[Examples] Remove getInitialProps from with-cookie-auth-fauna (#13887)
* Remove getInitialProps

* added swr

* Update examples/with-cookie-auth-fauna/pages/profile.js

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

* Update examples/with-cookie-auth-fauna/pages/profile.js

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

* no longer needed

* new .env support

* redirect if not found

* always use latest next version

* no longer needed

* Updated readme

* Updated profile page

* Fixed readme and added deploy button

Co-authored-by: Luis Alvarez D. <luis@vercel.com>
2020-06-20 10:59:53 -05:00
JJ Kasper
546c6512bd
Correct /_next/data link for GS(S)P with basePath (#14376)
This corrects the `/_next/data` path generated when using `basePath` with `getStaticProps` in a `pages/index.js` file which was previously stripping the `basePath` without checking if `/index` needed to be appended after stripping. This also adds additional checks to the `basePath` test suite to prevent regressing   

x-ref: https://github.com/vercel/next.js/pull/9872#issuecomment-646841260
2020-06-19 21:53:15 +00:00
Ty Mick
4e5e3b9072
Fix typo in test names: "treversing" → "traversing" (#14347)
Just a quick typo fix for some test names.
2020-06-19 01:05:09 +00:00
Bing Quan
ca49c547d0
Update Algolia's Instant Search Example (#14233)
* Update Algolio's Instant Search Example
- Moved from `getInitialProps` to `getServerSideProps`
- Update Algolio libraries

Co-authored-by: Arsalan Khattak <akkhattak65@gmail.com>

* Shift from SSR to CSR

Co-authored-by: Arsalan Khattak <akkhattak65@gmail.com>
2020-06-18 19:23:02 -05:00
Thor 雷神
0d6b7e95ed
Thor/stripe/add use shopping cart example (#14239)
r? @lfades 
cc @timothyis @dayhaysoos @ChrisBrownie55

* Add [use-shopping-cart](https://github.com/dayhaysoos/use-shopping-cart) example to stripe sample
* Refactor how we instantiate Stripe across the different pages with a `getStripe` singleton pattern.
2020-06-18 22:49:31 +00:00
JJ Kasper
f92571d502
De-experimentalize basePath config (#14283)
This moves the experimental `basePath` config out of the `experimental` section to prepare it for being stable
2020-06-18 10:10:20 +00:00
stefanprobst
279ae19c7e
docs: update links to docs site (#14305)
this updates some links to the docs site to their new location
2020-06-18 09:54:07 +00:00
Darsh Patel
42c309ad37
fix csp errors in with-strict-csp-app example (#14262)
Added proper content security policies in the dev environment 
fixes: #14221
2020-06-18 04:25:15 +00:00
Balázs Orbán
e87b739f33
fix typo in fast refresh documentation (#14296) 2020-06-18 01:11:07 +00:00
Shu Uesugi
a841d10954
Add c=1 to deploy buttons on CMS Examples (#14293)
Fixes #14291
2020-06-17 23:25:11 +00:00
Joe Haddad
0426694ce0
Add Fast Refresh Documentation (#14273)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-06-17 14:57:57 -04:00