Commit graph

2988 commits

Author SHA1 Message Date
Janicklas Ralph
e6e402e486
Font optimization - remove warning message (#20874) 2021-01-13 15:54:31 +00:00
JJ Kasper
9caca2784c
Add proper error when conflicting paths are detected (#20918)
This helps catch conflicting paths returned from `getStaticPaths` with a friendly error

<details>

<summary>
Preview of error
</summary>


<img width="962" alt="Screen Shot 2021-01-08 at 5 03 04 PM" src="https://user-images.githubusercontent.com/22380829/104074719-6e481100-51d6-11eb-9397-938aee3ae30b.png">
<img width="962" alt="Screen Shot 2021-01-08 at 5 03 41 PM" src="https://user-images.githubusercontent.com/22380829/104074722-6f793e00-51d6-11eb-90f6-7cdf9882bf00.png">

</details>




Closes: https://github.com/vercel/next.js/issues/19527
2021-01-11 20:50:17 +00:00
Joe Haddad
1a1c7c980f
v10.0.6-canary.0 2021-01-11 12:32:53 -05:00
Joe Haddad
d0e28549af
feat(css): add strictPostcssConfiguration flag (#20914)
This pull request adds `future.strictPostcssConfiguration`, allowing users to opt-into the more strict PostCSS configuration loading.

This stricter PostCSS configuration loading ensures that CSS can be cached across builds.
2021-01-11 17:19:56 +00:00
Kristoffer K
1c75bf789b
perf(next): use require.resolve instead of resolve (#19518)
**What's the problem this PR addresses?**

- ~~https://github.com/vercel/next.js/pull/18768 started to ncc babel and thus it's version of resolve which breaks PnP support~~
Babel replaced `resolve` with the builtin `require.resolve` and a polyfill for older node versions in https://github.com/babel/babel/pull/12439 which was upgraded in https://github.com/vercel/next.js/pull/20586
- `next` unnecessarily bundles the `resolve` package when `require.resolve` is builtin and can do the same job

**How did you fix it?**

- ~~Avoid running `resolve` through ncc~~
Added a test for https://github.com/vercel/next.js/issues/19334 (closes https://github.com/vercel/next.js/issues/19334)
- Replace `resolve` with `require.resolve`
2021-01-11 14:43:08 +00:00
Kristoffer K
4e3eb733c8
fix(next): always enable absoluteRuntime when running under webpack (#19538)
**What's the problem this PR addresses?**

In https://github.com/vercel/next.js/pull/18921 I enabled `absoluteRuntime` for everyone (it was only enabled for PnP users) but didn't consider that people used the babel preset outside of the webpack build.

Fixes https://github.com/vercel/next.js/issues/19448 - ~~Since it doesn't contain a repro I can't be certain but based on feedback from @koshea in https://github.com/vercel/next.js/pull/18921#issuecomment-733744645 I'll assume @RossMcMillan92 is doing the same thing, because when next is building it doesn't leave absolute paths as external.~~
Confirmed in https://github.com/vercel/next.js/pull/18921#issuecomment-734224014

**How did you fix it?**

Only enable `absoluteRuntime` when the preset is running under `babel-loader`
2021-01-11 14:21:58 +00:00
Tim Neutkens
4dc077956d
Error when exporting to static directory (#20969)
Fixes #20408
Fixes #20925
2021-01-11 13:34:58 +00:00
Vlad Frolov
7bb5f1a2fc
fix: Replace all backslashes when normalizing path in getFormattedDiagnostic (#17915)
I have not bumped into any bug, I was just playing around https://lgtm.com/projects/g/vercel/next.js/, and this looked like a legit suggestion to fix
2021-01-11 13:13:48 +00:00
Hyeon Kim (김지현)
552aa9df1a
Prevent unpredictable dependency hosting by explicitly resolve module path on webpack.ProvidePlugin (#20971)
ProvidePlugin replaces certain identifiers with another modules. As a result, 'buffer' and 'process' modules are added as implicit dependencies to all Next.js plugins. This can be problematic. With "Plug'n'Play" strategy, it don't work at all since they fail-fast with implicit dependencies. With "node_modules" strategy, it might seem OK but actually it can be result into unpredictable behavior since in uses dependency [hoisting](https://yarnpkg.com/advanced/lexicon#hoisting).

For example, currently users cannot use next-auth plugin with Plug'n'Play strategy:

![image](https://user-images.githubusercontent.com/4435445/103481517-d5547700-4e1e-11eb-9f23-bc2c9939418e.png)

This patch let Next.js properly handles such cases with `require.resolve`.

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

###### References:
- https://github.com/nextauthjs/next-auth/pull/1034
2021-01-11 12:31:31 +00:00
Tim Neutkens
5e701daab9 Update license year for all packages
Fixes #20887
2021-01-11 11:12:19 +01:00
Tim Neutkens
90ad2cbc44
Update profiling approach to cover webpack runs (#20900) 2021-01-09 20:12:13 -05:00
tarunama
629a7e8085
refactor(next): client/index.tsx (#20806)
## summary
- add return types
- move `locale` variable const from let
- ~use [strict equality](https://github.com/vercel/next.js/pull/20806/files#diff-2433946f9a058f1b070138d12c20f10a9128e46408033629181f9f7fc3b9b9b2R275)~
2021-01-07 15:02:10 +00:00
Joe Haddad
ef32e16fb1
v10.0.5 2021-01-06 18:30:00 -05:00
Joe Haddad
b2c6115bf2
v10.0.5-canary.12 2021-01-06 15:13:19 -05:00
David ALLIX
79e5615d2b
Add missing isReady declaration to NextRouter type (#20819)
Follow https://github.com/vercel/next.js/pull/20628
2021-01-06 17:44:35 +00:00
Joe Haddad
35a02d97b7
v10.0.5-canary.11 2021-01-06 11:28:41 -05:00
Damien Varron
55afe80c31
Only prefetch Link if router is in context (#19857)
Fixes #16864 

The `router` can be missing in a test environment when trying to render a `Link` component. This PR bails out of `router.prefetch()` when `router` is missing.

The alternative is for users to mock `next/link` or to mock the `router` and wrap their test components.

Please let me know any feedback.
2021-01-06 16:19:57 +00:00
JJ Kasper
991ad9225a
Update error for mis-matching path in getStaticPaths (#20767)
This updates the error shown when a path doesn't match the dynamic route in `getStaticPaths` to not include the `locale` since this isn't considered when matching against the dynamic route.
2021-01-06 10:27:32 +00:00
JJ Kasper
b9ba264bd6
Ensure i18n + API rewrite is handled correctly (#20751)
This ensures rewrites to API routes with i18n enabled handles as an API route correctly. This also adds tests for API routes in the i18n test suite

Fixes: https://github.com/vercel/next.js/issues/20725
2021-01-06 09:54:45 +00:00
Joe Haddad
9f6bcd47b6
v10.0.5-canary.10 2021-01-05 20:20:36 -05:00
JJ Kasper
47b7660aec
Ensure path starts with / when deleting index basePath with query (#20766)
This is a follow-up to https://github.com/vercel/next.js/pull/20596 and https://github.com/vercel/next.js/pull/20658 ensuring the `as` value is prefixed with the `basePath` correctly with a query. This updates the test to also ensure no errors are shown when a query is present on the index `basePath` route. 

Fixes: https://github.com/vercel/next.js/pull/20757#issuecomment-754338510
2021-01-06 01:20:04 +00:00
Alex Castle
c8bc17f330
Support for custom image loaders via image component prop (#20216)
This is a #19325 reconfigured to support a loader passed in via a `loader` prop on the Image component, rather than using a config-based approach.

The idea is that applications wanting to use a custom loader will create a wrapper element for the  image component that incorporates that loader. See a simple example of this pattern in the integration tests. 

This solution is similar to the one prototyped by @ricokahler in #20213 and described at https://github.com/vercel/next.js/issues/18606#issuecomment-720149156

---

Closes #19325
Fixes #18606
2021-01-05 20:51:34 +00:00
tarunama
575fcf3fcf
refactor(client): add return types (#20728)
## summary
- Explicitly define return types
- Add type of  [Observer](https://github.com/vercel/next.js/pull/20728/files#diff-5de64b97b2f26e4e41d197a8295e8750825c75b8ca557a4b947a4c3569345974R7)
2021-01-05 15:11:37 +00:00
Jan Varho
b944b06f30
Fix notFound false pages returning 404 (#19861)
Currently pages with `notFound: false` from `getServerSideProps` behave the same as `notFound: true`, i.e. just having the key is enough to result in a 404. This fixes the check in render.tsx and adds tests for it.
2021-01-04 22:43:53 +00:00
Joe Haddad
cb50b040ea
fix(next/head): assign bool attrs to match server (#20748)
This pull request correctly assigns boolean attributes for `<script />` to match the element as it is created by a server-side render.

Prior to this pull request, we'd double-execute `<script>` tags with the `async`, `defer`, or `nomodule` property.

---

Fixes #9070
2021-01-04 19:57:52 +00:00
matamatanot
fc75baeb3c
Move sizes var declaration just before used (#18402)
As with `const width`, it should be declared just before it is used.
2021-01-04 18:09:07 +00:00
Joe Haddad
246c265fca
v10.0.5-canary.9 2021-01-04 10:31:56 -05:00
Kristoffer K
e848a9e504
fix(next): add missing peer dependencies for sass support (#17606) 2021-01-04 10:30:46 -05:00
Alexander Kachkaev
7076758c8d
Call res.write('') inside apiRes.redirect() helper to prevent an edge case (#20461)
This PR is a small follow-up to #14705. It saves Next.js users from falling into a [pretty nasty trap](https://github.com/nodejs/node/issues/36620) in which I ended up last Friday. It took more than two days to investigate what was going on, so I hope I'm the last person who’s doing it 😅

Next.js-specific MWE: https://github.com/kachkaev/hanging-response-in-next-via-redirect-plus-compression (needs to be ran locally using Node 14.0.0+).

> <img width="521" alt="Screenshot 2020-12-24 at 20 50 00" src="https://user-images.githubusercontent.com/608862/103105989-a9b8dc00-4629-11eb-9be3-5108755604bf.png">

To reproduce the bug I’m fixing:

1. Pick a large http body size (64 or 128 KB)
1. Check _Call res.end() after res.redirect() in /api/redirect_
1. Navigate to a heavy page or an api handler via redirect
1. Observe that the http response is never finished.

If you set `compress` to `false` in `next.config.js` or pick a small payload size (< `zlib.Z_DEFAULT_CHUNK` after compression), the bug will not be observed. This is explained by the use of `res.on("drain", ...)` [by the `compression` package](3fea81d0ea/index.js (L193-L218)). The package itself is not the reason for an issue though, it seems to be in the Node’s built-in `http` package.

I’m happy to provide more info or GitHub CI to the MWE if needed. I was also thinking of adding some Next.js-specific testing, but could not come up with a compact and clear test plan. Happy to do this if there are any ideas.

cc @botv (author of #14705)
2021-01-04 10:14:15 +00:00
JJ Kasper
88b6c47244
Ensure isReady is set correctly for auto static dynamic route (#20729)
Follow-up to https://github.com/vercel/next.js/pull/20628 this ensures `isReady` is not initially true when the query isn't present but the page is an automatically statically optimized dynamic route
2021-01-04 08:58:52 +00:00
tarunama
8795369a2d
chore(client-image): add return types (#20686) 2021-01-03 15:59:17 +00:00
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
85bd4a9ccb
v10.0.5-canary.8 2021-01-01 21:40:09 -05:00
Joe Haddad
58ea3bb479
fix(next/babel): read env from caller, not process (#20679)
This PR fixes a bug where `next/babel` would accidentally enable development transforms for a production build (`next build`).

This is tested by the two updated unit tests (which removed a workaround for this bug, and one now properly enables dev transforms).

---

Fixes #18929
Fixes #19001
x-ref #19046
x-ref #17032
2021-01-02 00:36:16 +00:00
Joe Haddad
984ac96dc6
chore: remove old traces of next/data experiment (#20678)
This PR removes some left over traces of the `next/data` experiment, as it has been superseded by RSC.
2021-01-01 22:23:42 +00:00
JJ Kasper
dffb47133b v10.0.5-canary.7 2021-01-01 14:34:29 -06: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
JJ Kasper
9fc9a6e1e4 v10.0.5-canary.6 2020-12-30 23:30:30 -06:00
Guy Bedford
b7272995b5
feat: upgrade to ncc@0.26.1 (#20627)
This upgrades to the version of ncc with subbundling support.
2020-12-31 00:50:45 +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
cc0dcf96d5
v10.0.5-canary.5 2020-12-30 16:38:28 -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