Commit graph

106 commits

Author SHA1 Message Date
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
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
8193df5309
Fix serverless with next start error case (#19288)
This fixes the case where we were returning page data when rendering `/_error` in `serverless` mode with `next start`

Closes: https://github.com/vercel/next.js/issues/19068
2020-11-19 16:25:54 +00:00
Joe Haddad
80468ad4c2
Ensure we prefetch on hover (#18859)
* Ensure we prefetch on hover

* double because of hovering prefetch

* rerun workflow

* disable flaky test
2020-11-05 20:12:22 -06:00
Joe Haddad
bc2282fa38
Speed up SSG prefetching (#18813)
This pull request speeds up Next.js' rendering pipeline by fetching data, parsing it, and loading it into memory instead of only doing the network request.

This will mainly result in improved Firefox/Safari performance since they handled prefetch incorrectly—only Chrome did it right. This also gets us closer to being able to use `no-store` in our caching headers!

---

Fixes #18639
x-ref #18802
2020-11-05 09:51:24 +00:00
JJ Kasper
5a8398e34d
Remove unstable_ prefix from unstable_blocking (#18276)
This removes the `unstable_` prefix to prepare for stabilizing the feature
2020-10-27 04:01:37 +00:00
Stig Kleppe-Jørgensen
a4be780781
Remove duplicate should in test name (#17303) 2020-09-23 17:36:46 +00:00
JJ Kasper
62cbbf525c
Fix API page check during SSG page collecting (#17092)
Fixes SSG pages that start with `/api` not being detected as SSG pages. This also adds tests to ensure this is working correctly in the `prerender` suite.

x-ref: https://github.com/vercel/next.js/issues/17091
2020-09-15 01:03:43 +00:00
Joe Haddad
ec7009620a
Ensure unknown static paths 404 for data request (#16401)
We were accidentally allowing data requests to be rendered unconditionally. Instead, we should also check them against the staticPaths result and 404 when appropriate.

---

Fixes #15383
2020-08-20 17:59:03 +00:00
JJ Kasper
1b4d463cc8
Update rewrite params query appending (#16189)
This updates to not automatically append params to the query for rewrites if one or more of the params are already used in the destination's path. No other behavior is being changed and if the user still wants the params in the query after using them in the destination's path they can manually add them like with redirects.

Closes: https://github.com/vercel/next.js/issues/15626
2020-08-14 18:51:58 +00:00
JJ Kasper
8a489e24bc
Add initial handling for dynamic route href resolving and rewrites on the client (#15231)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-08-13 14:39:36 +02:00
Joe Haddad
e818389999
Add support for fallback: 'blocking' (#15672)
By popular request, this pull request adds support for returning `fallback: 'blocking'` from `getStaticPaths`.

This new mode will cause unknown paths to be rendered on-demand ("SSR") without the static (placeholder) fallback.

This feature is **currently experimental and should not be used in production yet**. It's currently flagged behind `unstable_`:

```
fallback: 'unstable_blocking'
```

TODO:

- [x] Next.js tests
- [ ] Add Vercel support
- [ ] Vercel tests

---

Fixes #15637
2020-08-04 15:10:31 +00:00
Tim Neutkens
c40f407d82
Stabilize revalidate (#15338) 2020-07-20 14:23:51 -04:00
Necmettin Karakaya
c2f38f2af0
[Fix] common misspelling errors (#15288)
For reference: https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-07-19 04:38:20 +00:00
Jan Potoms
c9492a8cc9
Relax encoding on dynamic prerendered routes (#14717)
It should be enough to encode the characters that `path-to-regexp` uses as path delimiters (`/#?`).

Fixes https://github.com/vercel/next.js/issues/14691
2020-07-13 14:42:27 +00:00
Joe Haddad
1d0e7a8a9a
Enable Optional Catch-All by Default (#14687)
Closes #14682
2020-06-29 18:50:32 +00:00
JJ Kasper
89ca0d10d4
Update to use getDataHref in fetchNextData (#14667)
This updates `fetchNextData` to re-use the `getDataHref` function from `page-loader` which has more verbose handling to ensure the correct `/_next/data` URL is built. Re-using this logic ensures the `/_next/data` URL can still be built even when a mismatching `href` and `as` value is provided to `next/link`.

This also fixes a case in `getDataHref` where optional values that weren't provided would fail to build the data href since the check requiring the param be present while interpolating the route values hasn't been updated to allow missing params for optional values.

An additional test case has been added to the prerender suite to ensure the `/_next/data` URL is built correctly when mismatching `href` and `as` values are provided

x-ref: https://github.com/vercel/next.js/discussions/14536
x-ref: https://github.com/vercel/next.js/discussions/9081#discussioncomment-31160
Closes: https://github.com/vercel/next.js/issues/14668
2020-06-29 15:14:45 +00:00
Tim Neutkens
83de34239c
Convert incremental generation cache to a class (#14660)
We've been meaning to change this code for a while 👍

- Changed the name from spr to incremental
- Changed the code to be a class instead of using module scope variables
2020-06-28 20:58:43 +00:00
JJ Kasper
61b68730f8
De-experimentalize custom-routes (#14602)
This moves the custom-routes configs outside of the experimental section to prepare them for being made stable

Fixes: https://github.com/vercel/next.js/issues/14184
2020-06-27 09:18:18 +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
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
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
08d7755e68
Update routeKeys to handle non-word characters (#12801)
This updates the named regexes output in the `routes-manifest` and the associated `routeKeys` to not use any non-word characters as this breaks the named regexes e.g. `"Invalid regular expression: "^/(?<data\-provider\-id>[^/]+?)(?:/)?$"`

x-ref: https://github.com/zeit/now/pull/4355
2020-06-16 13:49:13 +00:00
JJ Kasper
b1025995b2
Update to reject when test command fails (#13722)
As noticed in https://github.com/vercel/next.js/pull/13506 when a build or export command fails the tests can just stall. This attempts to address that by rejecting when the command doesn't exit correctly and `stdout` and `stderr` aren't being looked at
2020-06-09 18:28:15 +00:00
JJ Kasper
4e6eb5b3a7
Update rewrite dynamic SSG error (#13724)
This error isn't specific to just fallback SSG pages since any dynamic SSG page that is rewritten to can cause the `/_next/data` request to fail also since it currently derived from the the URL. 

This can also fail for `getServerSideProps` since it derives the `/_next/data` URL the same way so might need to be updated to show in that case also
2020-06-04 17:49:53 +00:00
Joe Haddad
15cdb4f408
Propagate Serverless Errors to Platform (#12841)
In serverless mode, it's best practice to propagate an unhandled error so that the function is disposed instead of recycled. This helps fix the "bad state" problem.
2020-06-01 23:12:45 +00:00
JJ Kasper
c0368e1b09
Handle encoding for data requests and fix fallback response (#13622)
This addresses some errors for `/_next/data` requests where encoded `/` values in dynamic route param would cause invalid behavior, a headers already sent error would be shown when sending the fallback page in development, and when rendering the `_error` page for a data request the error response would still be treated as a data request. 

This also adds test cases for these errors to prevent regression
2020-06-01 13:25:00 +00:00
JJ Kasper
ae3c388039
Add support for rewriting non-fallback SSG pages (#11010)
Since non-fallback pages don't rely on the URL for hydration we can allow them to be rewritten to but pages with fallback still can't be rewritten to because we won't be able to parse the correct `/_next/data` path to request the page's data from. I added a test for this behavior and ensured it works correctly on Now.

Example on with fallback false rewrite on Now:
https://tst-rewrite-cp9vge4bg.now.sh/about
2020-05-29 16:33:09 +00:00
Joe Haddad
30fbd9adc9
Speedup tests (#13461)
This PR checks if our tests can be ran faster by disabling source maps unless they're used for the purpose of testing.
2020-05-29 07:57:51 +00:00
JJ Kasper
ef422467dc
Add error when exporting pages with fallback: true (#13063) 2020-05-19 09:29:34 -04:00
Joe Haddad
86160a5190
Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
Jan Potoms
714747957a
Add eslint-plugin-jest (#13003) 2020-05-18 13:16:07 -04:00
Joe Haddad
f5c8b428ab
Stabilize test for Windows (#13050) 2020-05-18 12:05:18 -04:00
Jan Potoms
32057c849d
Use the jest-circus test runner (#12974) 2020-05-16 16:56:06 -04:00
Joe Haddad
ae1daea355
Enable Fast Refresh by Default (#12640) 2020-05-10 19:25:57 -04:00
JJ Kasper
52686690a9
Add namedRegex and routeKeys to routes manifest (#12250) 2020-04-28 09:59:47 +02:00
JJ Kasper
97a6b64f83
Rename unstable GSP field (#11602)
* Rename unstable GSP revalidate field

* Update error message

* Tweak error message some more

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-02 14:29:41 -04:00
JJ Kasper
2ba6db65e2
Update to prevent re-using workers for getStaticPaths in dev mode (#11347) 2020-03-25 14:57:14 -04:00
Joe Haddad
8443a809f3
Verify GS(S)P Serializability (#10857)
* Verify GS(S)P Serializability

* Add support for cyclic refs

* Add unit tests

* Test for error in development mode

* Fix prerender preview tests

* Fix gssp preview tests

* fix 2x test cases

* Add desired test

* fix some more tests

* Fix route manifest expect

* Fix test expects

* Test that `getServerSideProps` does not error in production

* Test that getStaticProps is not checked in production

* Test serialization check during build

* Fix export detection for serverless

* Update test/unit/is-serializable-props.test.js

Co-Authored-By: JJ Kasper <jj@jjsweb.site>

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-03-09 13:30:44 -04:00
Joe Haddad
1a9b49bf47
Fix Prerender Test Cases (#10861)
* Fix Prerender Test Cases

* fix test
2020-03-06 01:35:15 -05:00
Joe Haddad
5dfc7da2f9
Fix getStaticPaths modules being cached in dev mode (#10852) 2020-03-05 13:48:09 -05:00
JJ Kasper
4ef1cd4ebe
Add identifier to NEXT_DATA for gs(s)p (#10812)
* Add identifier to NEXT_DATA for gs(s)p

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

* fix lint

* apply lint fix

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-03-03 13:39:08 -05:00
JJ Kasper
b2624012ea
Remove old eslint-ignores from unstable_ prefix (#10740) 2020-02-28 12:40:27 -05:00
JJ Kasper
c9d9f1131c
Remove unstable_ prefix from new methods (#10723)
* Rename getServerProps to getServerSideProps

* Remove unstable_ prefix from new methods

* Add error when legacy methods are detected

* Add legacy methods for babel transform

* Add unstable_getServerSideProps also

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

* Update types import

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-27 11:57:39 -06:00
Joe Haddad
47ff1eb95a
Ability to Disable SSG Fallback (#10701)
* Ability to Disable SSG Fallback

* Throw error when value is missing

* Fix existing tests

* Adjust error message

* Do not render fallback at build time for `fallback: false` page

* Fix existing fallback behavior

* fix build

* fix version

* fix some tests

* Fix last test

* Add docs for get static paths

* Add explicit mode tests

* test for fallback error message
2020-02-27 13:23:28 +01:00
JJ Kasper
6dea45bdc9
Add dataRoutes field to routes-manifest for SSG and serverProps routes (#10622)
* Add dataRoutes field to routes-manifest for SSG and serverProps routes

* Update routes-manifest test
2020-02-26 14:35:02 -05:00
JJ Kasper
395714a475
Update url prop handling for pages with new data methods (#10653)
* Make sure to show error when url prop is returned for a page

* Update test and handle undefined pageProps

* Handle empty props

* Apply suggestions from code review

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>

* Update tests

* Update to not add url prop for SSG/SSP pages

* Update errsh for reserved prop

* Update errsh wording some more

* Update tests and to warn instead of error

* Update reserved prop warning

* Include page in url prop warning

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-26 13:26:55 -05:00
JJ Kasper
f17e170c3d
Add calling getStaticPaths in development before showing fallback (#10611)
* Add calling getStaticPaths in development before showing fallback

* Move staticPathsWorker to next-dev-server

* Make sure to clear require cache in worker process

* bump

* Remove staticPathsCache member

* Update numWorkers for staticPathsWorker
2020-02-24 16:36:59 -05:00
Joe Haddad
c3f11c20ca
Improve Nested Catch-All Coverage (#10659)
* Improve Nested Catch-All Coverage

* use check
2020-02-24 12:19:58 -05:00