Commit graph

1401 commits

Author SHA1 Message Date
Zach Bialecki
f412547248
Don't dedupe meta tags with the same name but unique keys (#17099)
Currently there is no way to add multiple meta tags with the same name attribute to the head of a page. This PR modifies the Head component to allow multiple meta tags with the same name if they have unique keys. 

This is important for integrating with certain services like Google Scholar and Swiftype.

Fixes #10183
2021-01-03 10:35:51 +00:00
Joe Haddad
2c75fa0d9e
fix(source map): correctly generate source maps (#20672)
Fixes #20500
2021-01-01 20:30:50 +00:00
JJ Kasper
8b803d79a9
Update error when internal href and external as are used (#20658)
* Update error when internal href and external as are used

* Update to handle error outside invariant

* Update err.sh components
2021-01-01 12:14:42 -06:00
JJ Kasper
9c8d04654e
Ensure all entries are cleared from cache on runtime change (#20652) 2021-01-01 12:39:39 -05:00
Joe Haddad
29b591b2bc
fix(next/image): do not pass-through srcSrc on lazy image (#20651)
This PR fixes a bug where we'd accidentally pass-through the user-provided `srcSet` if the image was lazy, just to then replace it when we hydrate.

---

Fixes #19041
2020-12-31 21:08:57 +00:00
JJ Kasper
3a9d18b549
Add isReady field on router (#20628)
Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server.

Closes: https://github.com/vercel/next.js/issues/8259
Closes: https://github.com/vercel/next.js/pull/9370
2020-12-31 16:54:32 +00:00
Joe Haddad
dbe1e626f8
fix(experimental scroll): use sessionStorage instead of history (#20633)
This pull request adjusts our experimental scroll restoration behavior to use `sessionStorage` as opposed to `History#replaceState` to track scroll position.

In addition, **it eliminates a scroll event listener** and only captures when a `pushState` event happens (thereby leaving state that needs snapshotted).

These merely adjusts implementation detail, and is covered by existing tests:
```
test/integration/scroll-back-restoration/
```

---

Fixes #16690
Fixes #17073
Fixes #20486
2020-12-31 16:08:12 +00:00
JJ Kasper
fd33c9f7e1
Ensure href is updated for locale domain (#20631)
This ensures we render the locale domain on the `href` when using `next/link` previously the provided `href` was stilling being rendered which differed from the resulting `href` that was navigated to. 

Fixes: https://github.com/vercel/next.js/issues/20612
2020-12-31 08:07:51 +00:00
Prateek Bhatnagar
16e9de3565
Fix: fallback font tag repetition (#20382)
partially fixes #20341

- Makes sure that font fallback does not get repeated for every request.
- Adds a test for the same.
2020-12-30 23:41:33 +00:00
JJ Kasper
5324e8b6ee
Ensure SSG data 404 handles correctly for non-notFound (#20622)
Follow-up to https://github.com/vercel/next.js/pull/20594 this ensures non-notFound SSG data 404s do cause a hard navigation as this signals a new deployment has occurred and a hard navigation will load the new deployment's version of the page. 

Closes: https://github.com/vercel/next.js/issues/20623
2020-12-30 22:35:02 +00:00
Alex Castle
74909ecfd4
Move CSS Preloads to top of head at document render (#18864)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-12-30 17:12:46 -05:00
Joe Haddad
45b87aa23a
feat(next/image): preload priority images (#20615)
The HTML Living Standard explicitly says `href` should be omitted to prevent the loading of an incorrectly sized image:
https://html.spec.whatwg.org/multipage/semantics.html#attr-link-imagesrcset

![image](https://user-images.githubusercontent.com/616428/103378205-8a013800-4aaf-11eb-9085-10f547263fed.png)

Since it's in the spec, I assume this is valid-enough HTML.

This also dedupes preloads which the old implementation did not.

---

Fixes #18756
x-ref #19118
Fixes #18720
2020-12-30 21:10:28 +00:00
Joe Haddad
d1c565901e
feat(next/image): reduce byte waste for 3x screens (#20610)
https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html

> This means that most OLED screens that say they are 3x resolution, are actually 3x in the green color, but only 1.5x in the red and blue colors. Showing a 3x resolution image in the app vs a 2x resolution image will be visually the same, though the 3x image takes significantly more data. Even true 3x resolution screens are wasteful as the human eye cannot see that level of detail without something like a magnifying glass.

> ![image](https://user-images.githubusercontent.com/616428/103366340-61b61100-4a90-11eb-9c16-8467f8930247.png)

Even the iPhone doesn't have true 3x DPI!

related: #18756
2020-12-30 18:17:46 +00:00
Joe Haddad
7646921911
fix(router): consistent scroll behavior for Link/Router#push (#20606)
This pull request makes `Router#push` and `Router#replace` function identically to `<Link />`, i.e. reset scroll when the new render is complete.

Users can opt out of this new behavior via:
```tsx
const path = '/my-page'
router.push(path, path, { scroll: false })
```

---

Fixes #3249
2020-12-30 16:10:59 +00:00
Joe Haddad
3246274dfd
fix(build): require test files be full name or extension (#20605)
Fixes #19935
2020-12-30 15:49:37 +00:00
JJ Kasper
75509164ab
Ensure domain locales are redirected client-side (#20562)
This ensures we detect domain specific locales and redirect them client-side. Tests have been added in the `i18n` suite to ensure the domain redirect is applied correctly during a client-side navigation

Fixes: https://github.com/vercel/next.js/issues/19174
2020-12-30 06:44:07 +00:00
JJ Kasper
97e9d54f2e
Ensure index basePath is detected correctly (#20596)
This ensures we detect the `basePath` correctly for the index `basePath` route when either a `hash` or a `query` are present in the provided path. This also adds this specific test to our basePath test suite. 

Fixes: https://github.com/vercel/next.js/issues/19294
Fixes: https://github.com/vercel/next.js/issues/19437
Closes: https://github.com/vercel/next.js/pull/19444
2020-12-30 05:37:26 +00:00
JJ Kasper
949657675e
Refactor GS(S)P notFound client-side handling (#20594)
This refactors to instead of throwing a specific error when a SSG data route 404s, we return it through props and render the 404 outside of the error handling flow. No additional tests have been added as existing tests should cover this. 

Closes: https://github.com/vercel/next.js/issues/19243
2020-12-30 05:17:10 +00:00
Joe Haddad
8bab640ef6
fix(next/link): reset scroll before lifecycles (#20595)
This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes.

This is necessary for components that read scroll state on mount.

---

Fixes #6462
2020-12-30 04:33:08 +00:00
JJ Kasper
962535752b
Ensure next/image loads correctly with basePath (#20592)
This ensures the default path used for the `next/image` component includes the `basePath` when configured. Additional tests have also been added to ensure the image component is working correctly with `basePath` configured.

Fixes: https://github.com/vercel/next.js/issues/19711
2020-12-30 01:57:08 +00:00
Joe Haddad
52270af307
Remove unnecessary unfetch polyfill for dev (#20589)
Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support.

Fixes #20588
2020-12-29 21:01:42 +00:00
Joe Haddad
e5b2bd1704
fix(next/image): ignore typography prose styles (#20580)
This fixes `next/image` to properly ignore inherited styles applied to the `img` tag by a parent element.

Image styling should **always** be done by a wrapper element—not to the image itself!

---

Fixes #19817
Fixes #19964
2020-12-29 17:34:11 +00:00
JJ Kasper
1de5d78fda
Update i18n test (#20548)
This tweaks the new i18n query history test to address intermittent failures in CI

x-ref: https://github.com/vercel/next.js/pull/19197#issuecomment-751845314
x-ref: https://github.com/vercel/next.js/pull/19135#issuecomment-751822153
x-ref: https://github.com/vercel/next.js/pull/20379#issuecomment-751821500
2020-12-28 20:41:08 +00:00
JJ Kasper
1203b9082b
Ensure path encoding is handled consistently for prerendered pages (#19135)
This ensures we handle encoding/decoding for SSG prerendered/fallback pages correctly. Since we only encode path delimiters when outputting to the disk we need to match this encoding when building the `ssgCacheKey` to look-up the prerendered pages. This also fixes non-ascii prerendered paths (e.g. 商業日語) not matching correctly. 

This does not resolve 👉  https://github.com/vercel/next.js/issues/10084 and further investigation will be needed before addressing non-ascii paths for non-SSG pages. 

The encoding output was tested against https://tst-encoding-l7amu5b9c.vercel.app/ to ensure the values will match correctly on Vercel. 

Closes: https://github.com/vercel/next.js/issues/17582
Closes: https://github.com/vercel/next.js/issues/17642
x-ref: https://github.com/vercel/next.js/pull/14717
2020-12-28 20:08:58 +00:00
Joe Haddad
f02bf210ce
fix(next/image): inherit parent visibility (#20542)
This PR is an alternative to #20247 which contains tests for the expected behavior.

---

Fixes #20198
Closes #20247
2020-12-28 18:55:44 +00:00
JJ Kasper
db329fe9b0
Ensure index rewrite is matched with i18n correctly (#20509)
This makes sure we don't generate the wrong locale source variant for the rewrite requiring a `/` on the end which won't ever be added causing the rewrite to never match. Additional tests have been added to ensure this specific rewrite is working correctly. 


Fixes: https://github.com/vercel/next.js/issues/20508
2020-12-28 18:21:28 +00:00
JJ Kasper
6189fe9693
Ensure query is present with i18n and history navigation (#20441)
This makes sure the query isn't dropped when doing a history navigation with i18n. Additional tests have been added to ensure this is working correctly as well. 

Fixes: https://github.com/vercel/next.js/issues/20212
2020-12-28 17:58:07 +00:00
JJ Kasper
690fc36ccc
Update revalidate checks (#19796)
This ensures we show an error for string values for `revalidate` since we currently don't handle these and instead it results in `revalidate: false` being used. This also adds tests for our `revalidate` checks to ensure they are triggered correctly and not triggered for valid values. 

x-ref: https://github.com/vercel/next.js/issues/20310
2020-12-22 20:15:26 +00:00
JJ Kasper
118588b027
Remove extra redirect for index with i18n (#20397)
This makes sure redirects to the index route properly end with a trailing slash or don't based on the `trailingSlash` config to ensure an additional redirect doesn't need to take place un-necessarily. 

Fixes: https://github.com/vercel/next.js/issues/19405
2020-12-22 17:12:53 +00:00
Juny
5cabe5e220
fix: set empty document files for amp first (#16934)
Fixes: https://github.com/vercel/next.js/issues/16926

I do not know this is the right way.
Please review it.
2020-12-22 03:18:01 +00:00
JJ Kasper
788183e8d3
Ensure only backslashes are in pages-manifest with i18n (#20376)
This ensures the pages-manifest only includes forward slashes and not backslashes when adding i18n page references, this also adds tests ensuring we don't regress on this in the i18n-support test suite. 

Fixes: https://github.com/vercel/next.js/issues/20330
2020-12-22 01:51:51 +00:00
Joe Haddad
260ab51974
temporary: re-flag font optimization (#20372)
There's currently two bugs with the font optimization, but we'd really like to ship a stable version.

To unblock the stable release, we're **temporarily** reflagging this. It'll be unflagged on canary again!
2020-12-21 19:26:00 +00:00
Matt Wood
7d48241949
Extend IncomingMessage type to include cookies from middleware (#19724)
When using `getServerSideProps` with Typescript, it looks like it's expecting `req` to be a plain `IncomingMessage` from `http`, but Next middleware (?) is adding `cookies`:

![image](https://user-images.githubusercontent.com/22530815/100816292-680e8a00-340b-11eb-8c40-19ec4f9ea356.png)

Here's a reproduction showing the example:

https://codesandbox.io/s/nextjs-server-side-props-cookies-vr547?file=/pages/index.tsx

In the terminal, you can see that there is a value for cookies, but `IncomingMessage` doesn't include it by default.

I still need to get more familiar with all the Next.js internals, but I imagine there are a few other places where this type could be used if cookies are being included. Any help would be appreciated.
2020-12-18 11:29:49 +00:00
Tim Neutkens
72fae8bed4
Move productionBrowserSourceMaps out of experimental (#20267)
Makes https://www.npmjs.com/package/@zeit/next-source-maps a built-in feature so that it can be deprecated.
2020-12-17 15:04:17 +00:00
Leo Toneff
25cb43a73b
Added flag to identify shallow router events (#19802)
This PR is an implementation of RFC #13276 (more specifically @banerjeesouvik's [suggestion](https://github.com/vercel/next.js/discussions/13276#discussioncomment-17874)) which solves #3322 by adding an extra parameter to the router events that'll allow you to see whether or not the route is shallow.

This is a recreation of PR #13243.
2020-12-17 09:14:50 +00:00
JJ Kasper
e819e00d0c
Add required server files manifest (#20035)
This keeps track of required server files in a manifest file
2020-12-16 20:46:55 +00:00
bram-l
929f17e183
Fix prefetching for URLs including trailing slash (#19474)
Fixes  #17813
2020-12-12 22:09:09 +00:00
JJ Kasper
5b89b1b6df
Ensure href resolvedAs is correct with locale (#20080)
This makes sure the `locale` doesn't cause the wrong `href` to be resolved, this also ensures route specificity is correct when loading dynamic routes in production mode. 

Fixes: https://github.com/vercel/next.js/issues/19747
2020-12-12 14:06:46 +00:00
Bruno Antunes
8340e6d345
[Image Component] image sizes property becomes 100vw by default (#20067)
Currently if sizes is not defined, Next.js is setting sizes as:
```
(max-width: 640px) 640px, (max-width: 750px) 750px, (max-width: 828px) 828px, (max-width: 1080px) 1080px, (max-width: 1200px) 1200px, (max-width: 1920px) 1920px, (max-width: 2048px) 2048px, 3840px'
```

This pull request will make sizes be `100vw` by default, which will allow us to download "smaller" images than what's currently happening. 

In a demo app I have, the difference is between downloading 488KB vs 1.4MB (in images)
2020-12-10 21:29:37 +00:00
Tim Neutkens
c792317295
Clear up production build missing message for next start and next export (#19777)
Adds an err.sh link to the production build missing message. Also clears up `valid` as `production`.

Also fixes an edge case where an unhelpful error would be thrown because we checked for `.next` instead of `.next/BUILD_ID`

Added the out directory location as the list line during export to make sure people know where the files are output. 

Fixes #19778
Fixes #19788
2020-12-08 15:16:56 +00:00
JJ Kasper
358861d315
Ensure trailingSlash redirect applies correctly for i18n (#19859)
This ensures locales aren't applied for the trailing slash redirect un-necessarily

Fixes: https://github.com/vercel/next.js/issues/19784
2020-12-07 17:36:46 +00:00
Daniel Kempner
90e97b535b
Custom Server with bodyParser, don't parse body again in API Route (#16169)
## Why

Some users prefer to use a custom server implementation that handles body parsing. If they do this, they have no way to opt out of all body parsing in API Routes. Requests with bodies die if next's `bodyParser` is not disabled. Requests just hang forever.

Instead of adding [this config](https://nextjs.org/docs/api-routes/api-middlewares#custom-config) to every API Route, we do a simple check to avoid parsing the body twice.

Fixes #8315
Fixes #7960
2020-12-07 13:30:38 +00:00
JJ Kasper
42385f48db
Ensure i18n custom routes resolves correctly (#19766)
This ensures i81n custom routes are resolving correctly, it also corrects redirects for default locales when `locale: false` is not used, and this also simplifies the resolving for custom routes with i18n in `next-server` adding types for the i18n config. This also adds additional tests to prevent regression and starts leveraging a shared `NextConfig` type to allow us to share types for config values. 

Fixes: https://github.com/vercel/next.js/issues/19521
Fixes: https://github.com/vercel/next.js/issues/19403
Fixes: https://github.com/vercel/next.js/issues/19302
Fixes: https://github.com/vercel/next.js/issues/19227
2020-12-04 10:14:55 +00:00
Prateek Bhatnagar
57e156bc49
Making font optimization as default (#19758)
- Making font optimizations as default
- Re-enabling tests
- Fixes #19159
2020-12-04 09:52:54 +00:00
Jeff Escalante
b86a1731e1
Error Message Clarity (#16052)
* make the error message more clear if webpack config comes back undefined

* Update check and add test

* bump

* Update build-output test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-12-01 15:58:52 -06:00
Janicklas Ralph
c8cd77a856
Script loader component (#18281) 2020-12-01 19:10:16 +01:00
Jamie
397a375b37
Ensure next commands respect termination signals (#19433)
Fixes #16173

## What

Restores handling of termination signals, `SIGTERM` and `SIGINT`, to allow graceful termination of next commands. Seems to have been removed during a child process refactor #6450, was this intentional?

## Why 

Currently the command processes have to be forcefully killed. This would help those using Next.js with custom servers and tools like Docker and Kubernetes that rely on termination signals to shutdown instances.

---

Where would be a good location to add some tests? [test/integration/cli/test/index.test.js](fc98c13a2e/test/integration/cli/test/index.test.js)?
2020-11-25 13:30:06 +00:00
James George
21e4c3f00e
tests(create-next-app): leverage execa (#19008)
Leverage [execa](https://github.com/sindresorhus/execa) for writing to `stdin`.
2020-11-24 14:51:41 +00:00
Joe Haddad
2832e753ad
Update vitals URL (#19454)
Update for rebranding purposes
2020-11-23 20:08:04 +00:00
Joe Haddad
c96c13a71b
Use render after hydrate (#19442)
Fixes #19399
2020-11-23 15:04:12 +00:00