Commit graph

7305 commits

Author SHA1 Message Date
JJ Kasper
d1036539d6
Ensure params and locale are parsed correctly in fallback mode (#19063)
This fixes a few things related to optional catch-all routes and i18n. The first thing is it ensures the correct data route is generated on the client so that the locale isn't duplicated for an optional catch-all route, the next is it ensures the browser history is updated correctly when only a locale change is occurring, and then it also ensures we handle the locales and normalizing for fallback optional catch-all pages correctly.

Tests have been added to ensure these cases are covered properly and we don't regress on them, these changes were also tested on Vercel [here](https://next-js-bug-i18n-root-params-nybg44l0b.vercel.app/)

Fixes: https://github.com/vercel/next.js/issues/18633 
Fixes: https://github.com/vercel/next.js/issues/19059
2020-11-11 20:33:44 +00:00
Daniel Stocks
44932612f8
Fixed missing SSR styles in with-fela example (#17647)
Added `<Html>` and `<Head>` components in the custom `_document.js` for the with-fela example package

This fixes an issue where fela `<style>` tags were not added and sent as part of the server-side rendered HTML payload, causing a FOUC.
2020-11-11 20:12:51 +00:00
Joe Haddad
0d1d3178a9
v10.0.2-canary.10 2020-11-11 13:16:41 -05:00
Joe Haddad
0d5bf65feb
Replace page loader with new route loader (#19006)
This pull request completely replaces our old page loader with a brand new route loader.

Our existing comprehensive test suite means I did not need to add a bunch of tests. I did add them where behavior was added or fixed.

Summary of the changes:

- Eagerly evaluates prefetched pages in browser idle time (speeds up transitions)
- Router is **no longer frozen** indefinitely if the Build Manifest never arrives
- Router is **no longer frozen** indefinitely if a page fails to bootstrap
- New `withFuture` utility instead of ad-hoc deduping per resource
- Prefetching is now delayed until browser idle time to not impact TTI
- Browsers without `prefetch` now fall back to eager evaluation instead of using `preload`
- We're now ready to serve non-static assets **with `no-store` without breaking prefetching**
- **Application can now hydrate without fetching CSS assets—this is a huge performance win that was previously blocking hydration**

---

The minor size increase here is unfortunate, but we have to incur it for correctness.

---

Fixes #18389
Fixes #18642
2020-11-11 18:13:16 +00:00
JJ Kasper
9cda047f0e
v10.0.2-canary.9 2020-11-11 11:10:21 -06:00
Steven
917d594ca8
Print error during next export with default image loader (#19032)
Fixes #18356
2020-11-11 15:46:48 +00:00
Kristoffer K
d40d7d6562
fix(next): resolve absolute path to @babel/runtime (#18921)
**What's the problem this PR addresses?**

https://github.com/vercel/next.js/pull/18768 started to ncc `@babel/plugin-transform-runtime` which broke its Yarn PnP support since the version of `resolve` it uses can't be patched by Yarn.

Fixes https://github.com/yarnpkg/berry/runs/1359235077?check_suite_focus=true#step:5:79

cc @guybedford

**How did you fix it?**

Resolve the absolute path to `@babel/runtime` so it doesn't have to go through `resolve`

---

Fixes https://github.com/vercel/next.js/issues/19026
2020-11-11 15:18:33 +00:00
Daniel K
a03fcbf7eb
[bundle-analyzer] Fix incorrect example (#18952)
This confused me a lot, because in the case of `withBundleAnalyzer({})` it will ignore any previous config and basically override everything.

Furthermore, it makes more sense to move the call with `enabled` option inside so it's aligned with other plugins approach.
2020-11-11 08:02:43 +00:00
JJ Kasper
ae75c6a640
Update chokidar to latest (#18995)
Updates to the latest version of `chokidar`

x-ref: https://github.com/vercel/next.js/issues/17416
2020-11-11 07:35:31 +00:00
JJ Kasper
48acc479f3
Ensure basePath behavior with GS(S)P redirect (#18988)
This ensures we match the `basePath` handling for redirects in `next.config.js` with redirects from `getStaticProps` and `getServerSideProps` and also adds a separate test suite to ensure GS(S)P redirects with `basePath` work correctly

Fixes: https://github.com/vercel/next.js/issues/18984
Closes: https://github.com/vercel/next.js/pull/18892
2020-11-11 07:13:18 +00:00
JJ Kasper
a429a47fe0
Ensure correct defaultLocale is provided for locale domain (#19040)
This ensures we use the `defaultLocale` for a locale domain when rendering non-static pages. Static pages will initially contain the global `defaultLocale` and then be updated on the client since we don't currently prerender a version of the pages for each locale domain. 

Closes: https://github.com/vercel/next.js/issues/18970
2020-11-11 02:09:45 +00:00
Kanitkorn Sujautra
6de34e7557
Add missing dependency to with-typescript-eslint-jest (#17864)
In `with-typescript-eslint-jest` example, `identity-obj-proxy` is being used here, but it's not in `package.json` yet.
5b1be2bb98/examples/with-typescript-eslint-jest/jest.config.js (L14)

This PR adds `identity-obj-proxy` to `package.json`.
2020-11-11 00:14:03 +00:00
Lyderic Dutillieux
50400f7eeb
Fixed wrong function name in error message (#19034)
Changed function name from "getStaticProps" to "getStaticPaths" in Exception message thrown when 'paths' is invalid.
2020-11-10 23:53:08 +00:00
Ante Sepic
e404b9962b
[Examples] Prevent getStaticProps from returning "undefined" (#19012)
If the example is cloned and ran with no further setup (no environment variables set up), it will error out because `extractPostEntries` will return `undefined` which can not be serialized by `getStaticProps `.

This PR basically ensures that we return an empty array instead of the `undefined` for a collection of posts, and a `null` instead of the `undefined` for a single post.
2020-11-10 23:33:51 +00:00
Callum Booth
f300ecaa94
Feat(example): Add with-zustand example (#17835)
Helps with https://github.com/pmndrs/zustand/issues/182 

I have seen the comments from this PR https://github.com/vercel/next.js/pull/11222#pullrequestreview-406998918 and this PR matches the with-redux example.
2020-11-10 23:06:49 +00:00
Ash Connell
b8c49ae97a
Add with-knex example (#17904)
* Add with-knex example

* Fix with-knex README typo

Co-authored-by: Ash Connell <hello@ashconnell.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-11-10 17:45:21 -05:00
Joe Haddad
5927796bdf
v10.0.2-canary.8 2020-11-10 17:06:14 -05:00
Gerald Monaco
80671273ca
Revert "Remove next-head-count (#16758)" (#18713)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-11-10 16:35:47 -05:00
WeichienHung
a2bea9b492
Add mutation example to with-typescript-graphql (#16742)
Fixes  https://github.com/vercel/next.js/issues/16550

Add a graphql mutation operation in this example.
The changes are:
1. Define mutation in schema `type-defs.graphqls`
2. Add mutation to `viewer.graphql ` that compiled to typescript code.
3. Add mutation resolver in `resolvers.ts`
4. [UI] add a input box and button to submit mutation request to change name. 

screenshot of change
![mutation_example](https://user-images.githubusercontent.com/1462027/91797123-5ffc4e00-ec54-11ea-910b-3ddb399b42f0.gif)
2020-11-10 21:10:54 +00:00
Steven
530b14616f
Add test for .ico image bypass (#19025)
We fixed this in a previous PR but there were no tests for `.ico` so this PR adds a test for it to ensure we don't regress.

Similar to SVG, we bypass ICO because it typically contains multiple sizes in a single file.

Closes #18600
2020-11-10 17:49:37 +00:00
JJ Kasper
18494fe3fb
Break-up unit tests to separate step (#18992) 2020-11-10 12:25:50 -05:00
Steven
70d8d8c9f2
Fix ViewSource component in the docs (#19022)
This PR moves the `<a>` element inside the `<svg>` element.
2020-11-10 17:02:39 +00:00
Joe Haddad
497cac4b93
v10.0.2-canary.7 2020-11-10 01:55:03 -05:00
Steven
9573426599
Add etag header to optimized image response (#18986)
Fixes #18563 by adding the etag header to the optimized image response.

This does _not_ change the expireAt (TTL) for cached files on the server, which still uses the max-age of the upstream response.

The new file format on disk for cached image files is the following:

```
.next/cache/images/<HASHED_QUERYSTRING>/<EXPIREAT>.<ETAG>.<EXT>
```
2020-11-10 04:40:26 +00:00
David Golden
d5daa06654
Upgrade with-mobx example (#17921)
upgrade mobx dependencies for with-mobx example and make all necessary code changes as per https://mobx.js.org/migrating-from-4-or-5.html

addresses #17809
2020-11-09 22:50:47 +00:00
Galanggg
435d4586df
Add with-gsap example (#17195)
This PR adds an example Next.js project with GSAP
![example-next-gsap](https://user-images.githubusercontent.com/21099312/93552465-170dfe80-f9a3-11ea-978c-4e1dc01731e8.gif)
2020-11-09 20:38:07 +00:00
Joe Haddad
8f07aed3e8
v10.0.2-canary.6 2020-11-09 13:37:02 -05:00
Weston Thayer
6aef4b8445
Update with-sentry example to show how to track API routes + bug fixes (#16484)
## New features

- Example of how to use `Sentry.captureException()` in API routes 5a35982717

## Bug fixes

- Server-side source maps now work in Sentry when deployed to Vercel 629a9ed504
- If uploading source maps, `Sentry.init()` now sets the `release`, so that exceptions are correctly associated with the source maps in that release

## Open issues

### `_error.js` is unused for `getServerSideProps` errors when deployed to Vercel

Instead of rendering this example's overridden `_error.js` (like it does when testing locally with `NODE_ENV='production'`), when deployed to Vercel and an Error is thrown from `getServerSideProps`, this page is shown:

![Screenshot of Vercel Application Error page](https://user-images.githubusercontent.com/709153/90968889-aa3c3d00-e4a6-11ea-9eff-fafee3d1ff33.png)

This confuses me because the Error is still successfully sent to Sentry, but I would've expected it to be sent by the call to `Sentry.captureException()` in `_error.js`. I'm not sure why it works.

### API test 2 & 3 don't work in the "server" build config

They don't work when deployed to Vercel in the "serverless" config either, but that's expected because there aren't any handlers to flush the Sentry queue. I can't figure out why they don't work in the long-lived "server" config.
2020-11-09 18:36:36 +00:00
iczero
5aa7606ae3
Upgrade sass-loader to 10.0.5 (#18972)
`node-sass` v5 introduced support for Node.js v15, which is not supported by v4. However, Next.js currently errors with
```
Error: Node Sass version 5.0.0 is incompatible with ^4.0.0.
```
when attempting to build with `node-sass` 5.0.0. This error comes from `sass-loader`. They have recently released version 10.0.5 which supports `node-sass` 5.0.0 (PR <https://github.com/webpack-contrib/sass-loader/pull/899>, release <https://github.com/webpack-contrib/sass-loader/releases/tag/v10.0.5>).
2020-11-09 15:14:47 +00:00
tolfino
bbde18f120
Fix false positive in isSerializable with shared references in arrays (#18232)
This replaces the seen set with a newly instantiated map of refs per
value in the array. This corrects the behavior that the refs map passed
into isSerializable contains only values along the path to the current
value: previously, because the refs map was shared among all values in
the array, this would trigger on instances such as:

```js
    const x = [];
    isSerializableProps('/', 'test', { arr: [x, [x]] });
```

... where the reference is shared but there is no cycle formed, as the
presence of elements is disjoint.

Fixes #18228.
2020-11-09 14:25:41 +00:00
James George
91d4aa5450
tests(create-next-app): prevent catch assertions (#18939)
Prevent `catch` assertions in tests.
2020-11-09 13:59:44 +00:00
Davidson Nascimento
019bbb284a
chore: fix some with-electron-typescript example setup (#18976)
- Changed script `start` to `dev` and improved it #18934 adding commando to transpile electron code;
- Added some folders into `.gitignore`;
- Updated react to avoid issues as #18916

Fixes #18934
2020-11-09 13:34:16 +00:00
JJ Kasper
c571f3143a
Update Azure cache key (#18964)
This updates to use the `Build.SourceVersion` value from the [predefined variables](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml) for the cache key instead of the pull request value since it isn't available after merging to canary. 

x-ref: https://github.com/vercel/next.js/pull/18931
2020-11-09 06:43:24 +00:00
Tadao Iseki
d196e72a7f
Export ImageProps from Image component (#18576)
This allows to import the type `ImageProps` from `next/image` like `next/link`.

a6660729ea/packages/next/client/link.tsx (L21)

## Usage

```tsx
import Image, { ImageProps } from 'next/image'

const CustomImage: React.FC<ImageProps> = (props) => (
  <Image {...props} unsized />
)
```
2020-11-09 06:20:54 +00:00
JJ Kasper
3cece4d2ad
Update Azure config (#18931) 2020-11-09 00:56:39 -05:00
Michael McQuade
9e59a6b57a
Add type keyword to API Routes examples (#18234)
The other examples are using the typescript `import type` style, which gets stripped during the build, so I added it to the API Routes example too.
2020-11-09 03:24:02 +00:00
Jesse Jafa
50a416a53c
Fixes with-chakra-ui example error (#18954)
Resolves https://github.com/vercel/next.js/issues/18941
2020-11-09 03:03:26 +00:00
Luis Alvarez D
38a24a9b91
Add docs for fallback: 'blocking' (#18568)
Notes:

- I use "blank page" to refer to that state where a new tab is waiting for the initial HTML. Lmk if there are better words to describe that.
- I did not add an usage example because it's the same thing of `fallback: true` and `fallback: false`, but with a config change. It's also explained below them and mentions the similarity with `fallback: true`

---

Fixes #18468
2020-11-09 02:38:04 +00:00
JJ Kasper
d10a6eca46
v10.0.2-canary.5 2020-11-08 18:13:02 -06:00
JJ Kasper
90a86e6723
Ensure auto-export dynamic routes work with i18n next start (#18930)
This ensures dynamic routes are correctly generated for `next start` with i18n and adds tests to the i18n suite to ensure they are working correctly. 

Closes: https://github.com/vercel/next.js/issues/18397
2020-11-08 02:18:13 +00:00
Davidson Nascimento
7820468401
chore: updated react to v17 on with-webassembly example (#18916) 2020-11-07 13:13:24 -05:00
Joe Haddad
f1a6a36b3e
v10.0.2-canary.4 2020-11-07 12:39:58 -05:00
Steven
b2a8a2f99e
Fix html validation for Image component (#18903)
This PR fixes two bugs causing HTML validators to complain.

- Error: Bad value data:image/svg+xml;charset=utf-8, for attribute src on element img: Illegal character in scheme data: < is not allowed.
  - Fixed by using base64 for svg during `layout=intrinsic` to avoid angle brackets
- Error: Element img is missing required attribute src.
  - Fixed by using base64 transparent gif for `loading=lazy` placeholder

Fixes #18850
2020-11-07 17:39:14 +00:00
Dinesh Balaji
19febb10c0
feat: update create-next-app to init with main as initial branch (#17745)
When `create-next-app` is initialized a git repo, it now uses 'main' as the initial branch.

The branch master does not actually exist initially. The branches don't get created only when they have at least one commit. Until the branch gets created, the branch only exists in .git/HEAD. So there is no master branch initialized in the repo.

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

<img width="639" alt="Screenshot 2020-10-09 at 17 26 30" src="https://user-images.githubusercontent.com/4656109/95580229-9f3c6c80-0a54-11eb-967f-180eb9601c1a.png">
2020-11-07 14:46:17 +00:00
Joe Haddad
266c7ed74c
Add additional tests (#18597)
This PR adds additional security tests.
2020-11-07 12:49:18 +00:00
JJ Kasper
2effca8e03
Fix redirect query handling for param like values (#17448)
This makes sure to compile query values for rewrites/redirects as non-path items to prevent param like values e.g. `https://` from causing the destination to fail to compile. 

Fixes: https://github.com/vercel/next.js/issues/17440 
x-ref: https://github.com/vercel/next.js/issues/18670
2020-11-07 04:30:14 +00:00
Ante Sepic
3f4872aa67
[Examples] Switch contentful example to graphql (#15223)
Now that all Contentful spaces support GraphQL, we are looking into switching the example from using a JS library to a simple fetch with GraphQL.

@stefanjudis ☝️
2020-11-07 00:51:59 +00:00
Joe Haddad
c8fa284854
Control <Image /> prefetching with React (#18904)
This pull request fixes `<Image />` not updating when new props are passed by removing external DOM mutations and relying on React to do it instead.

As an added bonus, I've extracted the intersection observer from both the `<Image />` and `<Link />` component, as their instance can be shared!

The increase in size is minor (+3B), and actually a decrease for apps using both `<Image />` and `<Link />`.

---

Fixes #18698
Fixes #18369
2020-11-06 23:03:15 +00:00
Steven
37fb0ad220
Update image example with link back to source code (#18909)
Fixes #18908
2020-11-06 17:13:01 -05:00
JJ Kasper
39453bba69
v10.0.2-canary.3 2020-11-06 15:24:16 -06:00