Commit graph

1629 commits

Author SHA1 Message Date
Joe Haddad
5f41abda9a
fix(link): cancel idle callback on unmount (#22072)
Co-authored-by: mAAdhaTTah <jamesorodig@gmail.com>
2021-02-11 13:51:41 -05:00
JJ Kasper
55e4a3d1ad
Only create locale domain links if on locale domain (#22032)
This updates to only create locale domain links if the current hostname is a locale domain to prevent making links unvisitable in development and preview environments where the configured locale domains don't point to the current build. 

Closes: https://github.com/vercel/next.js/issues/21211
Closes: https://github.com/vercel/next.js/issues/22011
2021-02-11 10:18:24 +00:00
JJ Kasper
5febe218a6
Add nccing AMP optimizer (#21980)
This adds ncc'ing the AMP optimizer package to speed up install times and cache the runtime. 

Closes: https://github.com/vercel/next.js/issues/20404
2021-02-11 09:55:56 +00:00
JJ Kasper
3f94f33ba2
Ensure error is passed up in minimal mode (#22030)
This ensures we pass the error up to the top-level when in minimal mode
2021-02-11 09:31:49 +00:00
Guy Bedford
234e1c9601
feat: Implement webpack require hook (#21802)
This implements the compatibility require hook as per https://github.com/vercel/next.js/issues/21789.

The hook is applied at the point of webpack initialization. In addition the separate packages are exposed for the various webpack subrequires.

The test then ensures instance equality for the basic require hook from the next.js config file.

I suspect this might have bad interactions with Yarn Pnp support, but maybe we will be lucky.
2021-02-04 08:49:42 +00:00
JJ Kasper
6d80e6e5f3
Add version for stats (#21823)
Adds versioning for the stats output
2021-02-03 20:46:35 +00:00
JJ Kasper
523537178c
Add stats config option (#21761)
This adds a config to output webpack's stats
2021-02-02 15:39:39 +00:00
JJ Kasper
b6c3d9bff3
Fix getting latest stable tag for stats (#21753)
This ensures we get the latest tag not relying on the order of the tags in the output
2021-02-01 21:07:17 +00:00
JJ Kasper
bd0b650de7
Update script loader tests (#21730)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-02-01 10:00:10 +01:00
Rafael Bonalume Lebre
60e699555d
Fix #top anchor link scroll (#16638)
According to [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href) the page must scroll to the top with both "#" and "#top" anchors.

<img width="675" alt="Screen Shot 2020-08-27 at 7 20 19 PM" src="https://user-images.githubusercontent.com/13899924/91500693-582a5b80-e89a-11ea-803f-4592d458baba.png">
2021-01-30 04:32:00 +00:00
Janicklas Ralph
8f21c283b2
Experimental feature changes (#21646)
Adding test for experimental-serverless-trace + fix for the same
2021-01-29 13:53:07 +00:00
JJ Kasper
87ed37d51c
Ensure prerender-manifest contains all i18n revalidate values (#21404)
This insures we add entries for each locale version of a non-dynamic SSG page since they can have unique revalidate values. This requires a version bump in the `prerender-manifest` since the static routes now contain additional values which need to be handled separately. 

Fixes: https://github.com/vercel/next.js/issues/21568
2021-01-27 11:24:00 +00:00
Jaon
e1fe28c849
Fix and add test filterModuleRules for next-plugin-storybook (#17306)
I tried the preset provided at `packages/next-plugin-storybook` but it was raising error due to an [unsafe negation](https://eslint.org/docs/rules/no-unsafe-negation) in the `preset.js` file.

I added a test to show the error:
```
● next-plugin-storybook filterModuleRules › should filter module rules correctly

    TypeError: rule.test.test is not a function

      48 |       if (!rule.test instanceof RegExp) return true
      49 |       // use Next.js' built-in CSS
    > 50 |       if (rule.test.test('hello.css')) {
         |                     ^
      51 |         return false
      52 |       }
      53 |       // use next-babel-loader instead of storybook's babel-loader

      at filter (../packages/next-plugin-storybook/preset.js:50:21)
          at Array.filter (<anonymous>)
      at Object.filterModuleRules (../packages/next-plugin-storybook/preset.js:46:28)
      at Object.<anonymous> (unit/webpack-config-overrides.test.js:12:36)
```
2021-01-26 19:28:41 +00:00
Janicklas Ralph
dc2de37014
Font optimization - Pass nonce to inlined font definition (#21346) 2021-01-26 18:32:39 +00:00
Roko Bekavac
004ad62d6b
Allow undefined body sent to sendData() (#20981)
Co-authored-by: rokobekavac0 <roko.beakavac2003@gmail.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2021-01-26 10:24:48 -05:00
kaykdm
47cb4cf850
Fix aspath for getInitialProps (#20572)
Fixes: https://github.com/vercel/next.js/issues/20370

> AsPath is incorrect on Server if you use rewrites and getInitialProps. On the server, asPath is the rewritten asPath while on the client asPath ist as given in the request URL.

The same issue was used to happen on `getServersideProps`, but it was fixed in this PR (https://github.com/vercel/next.js/pull/17121).
`getInitialProps` needs same fix except when the target is serverless, which has correct `asPath` value.

Additional tests have been added in the `getInitialProps` suite to ensure correct asPath with rewrites.
2021-01-25 18:26:32 +00:00
Janicklas Ralph
cf95146a51
Critical css fix (#21462)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2021-01-25 12:43:05 -05:00
Joe Haddad
75c504708b
fix: upgrade pinned deps for tests (#21515) 2021-01-25 12:08:08 -05:00
Chulki Lee
fc34f89a80
Fix hostname message in dev/start (#20409) 2021-01-25 16:13:12 +01:00
Calmon Ribeiro
783b9d86ff
fix(next): respect extends in tsconfig with exclude and include (#16619) 2021-01-24 14:24:36 +01:00
Darsh Patel
d68d21c329
Test: serverless target should set correct revalidation (cache-control) header (#15512) 2021-01-23 16:15:13 +01:00
kaykdm
a5b0094677
Fix shallow routing scroll (#21437)
This ensures that Next.js will not scroll to the top of the page in shallow routing.

Fixes: https://github.com/vercel/next.js/issues/21386
Fixes: https://github.com/vercel/next.js/issues/21366
2021-01-22 18:03:29 +00:00
JJ Kasper
5b70802f61
Preserve asPath while resolving rewrites (#21410)
* Preserve asPath while resolving rewrites

* remove un-needed alias

* Add new alias

* Add return type for resolve rewrites
2021-01-21 17:40:23 -06:00
JJ Kasper
f6304cde92
Add additional dynamic route hash tests (#21363)
This adds tests for https://github.com/vercel/next.js/issues/18601 to ensure we don't regress on this feature working correctly. 

Closes: https://github.com/vercel/next.js/issues/18601
2021-01-20 09:45:58 +00:00
Tim Neutkens
56b149f7be
Add experimental per-page option to disable JS preloads (#21329)
As discussed with @csswizardry. This is a temporary option in case you know the preloads are not needed. It will likely be a default once the ScriptLoader work from @janicklas-ralph has been proven in partner apps and landed.

```js
// pages/index.js
export const config = {
  unstable_JsPreload: false
}
```
2021-01-19 19:38:15 +00:00
Tobias Koppers
11900431fa
upgrade webpack 5 for empty entrypoint fix (#21353)
fixes a problem where entrypoints are nearly empty.
2021-01-19 19:15:45 +00:00
Bernd Artmüller
72ce099106
Fix splitting page path by buildId (#19901)
Running next.js in `development` causes issues when having pages named "development" or "developments",... as `this.buildId` = `development`

Fixes: https://github.com/vercel/next.js/issues/19520
2021-01-19 18:27:28 +00:00
Joe Haddad
02aa7b28da
ci: stabilize Window CI (#21344)
This skips a test suite that always flakes on Windows due to `http-proxy` <> Windows interop issues.
2021-01-19 16:04:27 +00:00
kaykdm
699a7aeaaa
Move hydration mis-match test suite (#21264)
In this [PR](https://github.com/vercel/next.js/pull/21065), it was suggested to move the test suite, but it was merged before fixing.
This is the fix for that, moving link-with-hash test suite to client-navigation suite

detail: https://github.com/vercel/next.js/pull/21065/files#r558425551
2021-01-18 04:05:41 +00:00
Tobias Koppers
b02df3f487
improve splitChunks config for webpack 5 (#21208) 2021-01-17 20:05:47 +01:00
JJ Kasper
cfa9326c63
Minimal mode normalizing (#21083)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-01-16 16:46:21 +01:00
kaykdm
cdab7bf831
fix hydration mismatch on href for url with anchor refs (#21065)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-01-15 17:53:10 +01:00
Gerald Monaco
cd5ea7db1f
Bump minimum suggested React version (#21046)
* Upgrade React version warning

* Fix font/stylesheet plugin

* Fix size-limit tests

* Fix build-output test

* Add tests for React 16

* Fix react-dom version
2021-01-14 22:29:57 -05:00
Ramiro Silveyra d'Avila
d72b2d6e36
fix: webpack 5 and worker-loader support (#21050)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2021-01-14 01:48:49 -05:00
Guy Bedford
bddb02286f
feat: webpack inlining with configuration for v4 / v5 (#20598) 2021-01-13 20:59:08 -05:00
kaykdm
e1184fb060
Fix image cache for vector and animated images (#20480)
Fixes: https://github.com/vercel/next.js/issues/19100
> According to https://nextjs.org/docs/basic-features/image-optimization#caching Next.js populates a cache dir when using the new <Image /> component. This is not the case when using SVG files. This results in a performance penalty.

I created a function for writing images to cache directory (`wrirteToCacheDir`) and it is called for all images.
However, vector and animated images are not optimized before writing them to cache dir

Related to #18179
2021-01-13 18:06:04 +00:00
Ari Freyr Asgeirsson
69ff95f50e
Wrong index path revalidation timer (#20818)
Hello friends

Ran into this bug on our production site, prerenderManifest stores revalidation info for the index as `"/": { .. }`, but the code tries to access this information as `"/index"`.

This leads to our index page always having s-max-age: 1
2021-01-13 16:15:11 +00:00
JJ Kasper
417a712066
Update next/image test (#20986)
This ensures the page has transitioned fully before testing which should resolve the random failure seen in a couple of runs. 
 
x-ref: https://github.com/vercel/next.js/pull/20918#issuecomment-758155230
2021-01-13 15:05:08 +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
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
Spencer Elliott
16ff4390a0
Add pnpm integration test (#17882) 2021-01-11 17:50:12 +01:00
Tim Neutkens
4dc077956d
Error when exporting to static directory (#20969)
Fixes #20408
Fixes #20925
2021-01-11 13:34:58 +00:00
JJ Kasper
8bdff57b15
Update redbox tests (#20866)
This adds retrying for getting redbox content and ensures the `next.config.js` file is cleaned up for the dynamic-routing test suite.

x-ref: https://github.com/vercel/next.js/pull/20786#issuecomment-755929891
2021-01-07 18:06:40 +00:00
Joe Haddad
b580bea250
tests: add isReady field test for TS (#20821) 2021-01-06 13:14:52 -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
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
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
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