Commit graph

106 commits

Author SHA1 Message Date
JJ Kasper
90ddd0dc83
Replace node-sass test dependency with sass (#39053)
* Replace node-sass test dependency with sass

* breakup css/scss tests for more parallelism

* update compiled
2022-07-26 23:12:54 -05:00
JJ Kasper
8017d69a68
v12.2.4-canary.2 2022-07-26 15:24:27 -05:00
JJ Kasper
8c902b61d1
v12.2.4-canary.1 2022-07-25 15:50:59 -05:00
Tobias Koppers
8324cf5218
update webpack (#38988)
https://github.com/webpack/webpack/releases/tag/v5.74.0

There is a nice little performance fix for rebuild performance in this release.
It also fixes the edge case @Kikobeats did run into: https://vercel.slack.com/archives/CGU8HUTUH/p1656505879286119
2022-07-25 15:47:11 +00:00
JJ Kasper
6b915cc34e
v12.2.4-canary.0 2022-07-22 17:51:32 -05:00
JJ Kasper
0f99768f98
Update to latest version of @vercel/nft (#38878) 2022-07-21 21:43:51 -05:00
JJ Kasper
4b6cb447d1
v12.2.3 2022-07-21 19:53:45 -05:00
JJ Kasper
12b7c584f9
v12.2.3-canary.17 2022-07-21 16:30:46 -05:00
Javi Velasco
14463ddd10
Update Edge Runtime (#38862)
This PR updates the Edge Runtime to use a new version that loads dependencies differently. This addresses https://github.com/vercel/next.js/pull/38766 so `instanceof` works as expected.

It involved a few code changes, mostly regarding to types. The most important change is that the `Runner` function in the sandbox doesn't take a `ReadableStream` as `body` anymore since this implies creating the instance on "node land" and makes the runtime `fetch` function not to be able to compare with `ReadableStream` using `instanceof`.  Instead we introduce a "clonable body" abstraction that allows to create the `ReadableStream` from `Readable` by using the edge runtime primitive which would hold the correct prototype.

Also, this PR changes the way we pre-compile the Edge Runtime to adapt it to the new version.
2022-07-21 18:29:19 +00:00
Tim Neutkens
5dafe472bc v12.2.3-canary.16 2022-07-21 14:44:35 +02:00
Maia Teegarden
ea9f855253
v12.2.3-canary.15 2022-07-20 14:52:31 -07:00
JJ Kasper
a2554c09a4
v12.2.3-canary.14 2022-07-18 18:21:55 -05:00
Tim Neutkens
aa664868c1 v12.2.3-canary.13 2022-07-18 19:20:48 +02:00
Sukka
97df2bb095
refactor: rewrite etag (#38568)
x-ref: https://github.com/vercel/next.js/issues/38235#issuecomment-1182283358

Rewrite ETag generate function with `fnv1a` hash.

FNV hashes are designed to be fast while maintaining a low collision rate. The FNV speed allows one to quickly hash lots of data while maintaining a reasonable collision rate (https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed/145633).

[fastify-etag](https://github.com/fastify/fastify-etag) also uses `fnv1a` algorithm by default.

cc @shuding: Should `experimental-edge` also switch to `fnv1a` for ETag, for consistency?
2022-07-18 09:20:44 +00:00
Tim Neutkens
0610f9ac0d v12.2.3-canary.12 2022-07-18 10:32:26 +02:00
Tim Neutkens
3017b606e0 v12.2.3-canary.11 2022-07-15 17:09:39 +02:00
Tim Neutkens
e685214cec v12.2.3-canary.10 2022-07-15 14:21:49 +02:00
Tim Neutkens
3ebdf1988a v12.2.3-canary.9 2022-07-15 13:44:11 +02:00
Tim Neutkens
c1ce6bfe1b v12.2.3-canary.8 2022-07-14 17:06:56 +02:00
Tim Neutkens
f5af5bb0db v12.2.3-canary.7 2022-07-14 12:58:55 +02:00
JJ Kasper
ff148a0fb4
Update to latest version of turbo (#38629)
Updates to latest turbo which includes patches for cached files. 

x-ref: [slack thread](https://vercel.slack.com/archives/C02CDC2ALJH/p1657767763630359?thread_ts=1657757803.039099&cid=C02CDC2ALJH)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-14 09:03:35 +00:00
JJ Kasper
62f3f87891
Add next.config.js validation with ajv (#38498)
* Add next.config.js validation with ajv

* update manifest

* update lib type

* remove old tests

* update to pre-build validation code

* ensure validate output is ncced

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>

* Add example of typing next.config.js

Co-authored-by: Steven <steven@ceriously.com>
2022-07-13 13:31:55 -05:00
Jiachi Liu
5a15c5fb85 v12.2.3-canary.6 2022-07-13 19:33:11 +02:00
Tim Neutkens
1e09d9bd40 v12.2.3-canary.5 2022-07-13 14:45:36 +02:00
Tim Neutkens
722e64f06d v12.2.3-canary.4 2022-07-13 12:01:33 +02:00
Tim Neutkens
c1b2ee635f v12.2.3-canary.3 2022-07-13 09:30:15 +02:00
Gal Schlezinger
62eb16b603
Upgrade edge-runtime + make EdgeRuntime value overridable with an env var on compilation (#38331)
This PR introduces an environment variable that allows to modify the `EdgeRuntime` value on compilation time.
This is done to allow cloud providers like Vercel to have a different value, and enable user code and 3rd party libraries to have different code paths depending on the Edge Functions provider.

## Related

- Related to #30739

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-07-12 15:18:59 +00:00
Tim Neutkens
114e151c23 v12.2.3-canary.2 2022-07-12 14:46:07 +02:00
JJ Kasper
883a52ede9
v12.2.3-canary.1 2022-07-11 18:12:44 -05:00
Sanjaiyan Parthipan
8ee05b749b
Update some dependencies' versions :) (#38427)
Hi,

I have updated some version of packages. 

- @swc/helper
- json5
- terser
- postcss
- nanoid
- use-sync-external-store (ReactJs pollyfill)
- microbundle

Updated version of #38328 

_Extremely sorry if I made any mistakes :(_

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2022-07-11 20:32:49 +00:00
Tim Neutkens
0887d283e1 v12.2.3-canary.0 2022-07-11 14:35:12 +02:00
Tim Neutkens
689626c6a4 v12.2.2 2022-07-09 13:18:55 +02:00
Tim Neutkens
4e21a240a5 v12.2.2-canary.0 2022-07-09 11:44:49 +02:00
JJ Kasper
ef90539968
v12.2.1 2022-07-07 18:01:56 -05:00
JJ Kasper
e9ffd9bec4
v12.2.1-canary.5 2022-07-07 15:49:30 -05:00
JJ Kasper
3411794607
v12.2.1-canary.4 2022-07-06 16:33:16 -05:00
Tim Neutkens
f113141389
Implement new client-side router (#37551)
## Client-side router for `app` directory

This PR implements the new router that leverages React 18 concurrent features like Suspense and startTransition.
It also integrates with React Server Components and builds on top of it to allow server-centric routing that only renders the part of the page that has to change.

It's one of the pieces of the implementation of https://nextjs.org/blog/layouts-rfc.

## Details

I'm going to document the differences with the current router here (will be reworked for the upgrade guide)

### Client-side cache

In the current router we have an in-memory cache for getStaticProps data so that if you prefetch and then navigate to a route that has been prefetched it'll be near-instant. For getServerSideProps the behavior is different, any navigation to a page with getServerSideProps fetches the data again.

In the new model the cache is a fundamental piece, it's more granular than at the page level and is set up to ensure consistency across concurrent renders. It can also be invalidated at any level.

#### Push/Replace (also applies to next/link)

The new router still has a `router.push` / `router.replace` method.

There are a few differences in how it works though:

- It only takes `href` as an argument, historically you had to provide `href` (the page path) and `as` (the actual url path) to do dynamic routing. In later versions of Next.js this is no longer required and in the majority of cases `as` was no longer needed. In the new router there's no way to reason about `href` vs `as` because there is no notion of "pages" in the browser.
- Both methods now use `startTransition`, you can wrap these in your own `startTransition` to get `isPending`
- The push/replace support concurrent rendering. When a render is bailed by clicking a different link to navigate to a completely different page that still works and doesn't cause race conditions.
- Support for optimistic loading states when navigating

##### Hard/Soft push/replace

Because of the client-side cache being reworked this now allows us to cover two cases: hard push and soft push.

The main difference between the two is if the cache is reused while navigating. The default for `next/link` is a `hard` push which means that the part of the cache affected by the navigation will be invalidated, e.g. if you already navigated to `/dashboard` and you `router.push('/dashboard')` again it'll get the latest version. This is similar to the existing `getServerSideProps` handling.

In case of a soft push (API to be defined but for testing added `router.softPush('/')`) it'll reuse the existing cache and not invalidate parts that are already filled in. In practice this means it's more like the `getStaticProps` client-side navigation because it does not fetch on navigation except if a part of the page is missing.

#### Back/Forward navigation

Back and Forward navigation ([popstate](https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event)) are always handled as a soft navigation, meaning that the cache is reused, this ensures back/forward navigation is near-instant when it's in the client-side cache. This will also allow back/forward navigation to be a high priority update instead of a transition as it is based on user interaction. Note: in this PR it still uses `startTransition` as there's no way to handle the high priority update suspending which happens in case of missing data in the cache. We're working with the React team on a solution for this particular case.

### Layouts

Note: this section assumes you've read [The layouts RFC](https://nextjs.org/blog/layouts-rfc) and [React Server Components RFC](https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html)

React Server Components rendering leverages the Flight streaming mechanism in React 18, this allows sending a serializable representation of the rendered React tree on the server to the browser, the client-side React can use this serialized representation to render components client-side without the JavaScript being sent to the browser. This is one of the building blocks of Server Components. This allows a bunch of interesting features but for now I'll keep it to how it affects layouts.

When you have a `app/dashboard/layout.js` and `app/dashboard/page.js` the page will render as children of the layout, when you add another page like `app/dashboard/integrations/page.js` that page falls under the dashboard layout as well. When client-side navigating the new router automatically figures out if the page you're navigating to can be a smaller render than the whole page, in this case `app/dashboard/page.js` and `app/dashboard/integrations/page.js` share the `app/dashboard/layout.js` so instead of rendering the whole page we render below the layout component, this means the layout itself does not get re-rendered, the layout's `getServerSideProps` would not be called, and the Flight response would only hold the result of `app/dashboard/integrations/page.js`, effectively giving you the smallest patch for the UI.

---

Note: the commits in this PR were mostly work in progress to ensure it wasn't lost along the way. The implementation was reworked a bunch of times to where it is now.

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-06 21:16:47 +00:00
JJ Kasper
9573174196
Replace pre-commit with husky (#38350)
* Replace pre-commit with husky

* update lock

* actually update lock
2022-07-06 11:14:16 -05:00
JJ Kasper
764f7d42d4
v12.2.1-canary.3 2022-07-05 12:09:24 -05:00
JJ Kasper
274980f057
v12.2.1-canary.2 2022-07-01 19:49:58 -05:00
Jiachi Liu
bfaffbdd3f
Alias react and react-dom by default (#38245)
Previously we use custom webpack alias for specific react versions for non server side node runtime aliases. This PR alias the entire folders of `react/` and `react-dom/` so that no more alias in next.config is required but only the nodejs require hook.

* Alias `react` and `react-dom` by default
* Use `react@experimental` to run server components integration test
* Drop with-react-17 test util, add `__NEXT_REACT_CHANNEL` as an env var for testing and development to specify the react channel is 17 or new experimental version
2022-07-01 23:57:45 +00:00
Michael Novotny
edd395a7d3
Adds tests to ensure eslint-plugin-next's available rules are properly exported and recommended rules are correctly defined. (#38183)
* Adds tests to ensure `eslint-plugin-next`'s available rules are properly exported and recommended rules are defined correctly.

* Condenses imports.

* Sets default recommended value.

* replace Object.hasOwn for node 14

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-30 11:31:33 -05:00
Wyatt Johnson
23b8b982df
Fix missing trace script devDependencies (#38172)
Adds missing devDependencies required by the `trace-to-tree.mjs` script used here to the workspace root.

c64af8aa34/scripts/trace-to-tree.mjs (L2-L3)
2022-06-29 20:57:51 +00:00
JJ Kasper
c64af8aa34
v12.2.1-canary.1 2022-06-29 15:06:44 -05:00
JJ Kasper
70c0b20885
v12.2.1-canary.0 2022-06-29 13:57:24 -05:00
JJ Kasper
632feb6b73
v12.2.0 2022-06-28 09:21:07 -05:00
JJ Kasper
ed35138edc
v12.1.7-canary.52 2022-06-28 08:35:37 -05:00
Kiko Beats
9cc1c3c576
Upgrade Edge Runtime (#38105) 2022-06-28 07:48:23 -05:00
JJ Kasper
3eb9caeb6a
v12.1.7-canary.51 2022-06-27 23:35:41 -05:00
JJ Kasper
52763de94a
v12.1.7-canary.50 2022-06-27 18:52:05 -05:00