- 09 Aug, 2024 7 commits
-
-
vercel-release-bot authored
-
Matvey authored
Fixes #68533 A link to docs in `next-dev.d.ts` linked to the pages router docs in app router templates. This was confusing, because some sections on this page only work with pages router. This PR fixes that --------- Co-authored-by:Sam Ko <sam@vercel.com>
-
Mehmet Ozgul authored
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> ### What? [Memory Usage](https://nextjs.org/docs/app/building-your-application/optimizing/memory-usage) page has a broken link, leading to: [Package Bundling](https://nextjs.org/docs/app/building-your-application/optimizing/package-bundling#analyzing-javascript-bundles) (Page not found) ### Why? ### How? I replaced the link on the markdown file with the correct page and the correct section: [Bundle Analyzer - Analyzing your bundles](https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer#analyzing-your-bundles) Fixes #68651 --------- Co-authored-by:
Sam Ko <sam@vercel.com> Co-authored-by:
Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
-
Hendrik Liebau authored
When our patched `fetch` function comes to the conclusion that it should cache a response, it currently buffers the full response body before returning a pseudo-cloned `Response` instance. This is especially a problem in chat applications, where LLM responses need to be streamed to the client immediately, without being buffered. Since those chat requests are usually POSTs though, the buffering in `createPatchedFetcher` did not create a problem because this was only applied to GET requests. Although use cases where GET requests are streamed do also exist, most prominently RSC requests. Those would have been already affected by the buffering. With the introduction of the Server Components HMR cache in #67527 (enabled per default in #67800), the patched `fetch` function was also buffering POST response bodies, so that they can be stored in the HMR cache. This made the buffering behaviour obvious because now Next.js applications using the AI SDK to stream responses were affected, see https://github.com/vercel/ai/issues/2480 for example. With this PR, we are now returning the original response immediately, thus allowing streaming again, and cache a cloned response in the background. As an alternative, I considered to not cache POST requests in the Server Components HMR cache. But I dismissed this solution, because I still think that caching those requests is useful when editing server components. In addition, this solution would not have addressed the buffering issue for GET requests. Apart from the unit test, I also tested this end-to-end with https://github.com/lgrammel/rsc-streaming-regression.
-
Jiwon Choi authored
### Why? There was a duplicate storeHydrationError call. ### How? Removed it and destructured the required value.
-
Delba de Oliveira authored
Closes: https://linear.app/vercel/issue/DOC-3156/resolve-open-comments-in-rc-branch Responded and closed all RC docs comments in preparation for [merging the docs](https://linear.app/vercel/issue/DOC-3155/close-rc-docs-pr-and-add-new-feature-tags). With `experimental/canary` tags, we won't need to keep separate docs. Changes: - Fix code example - Remove duplicate CRA upgrade guide
-
Sebastian Silbermann authored
-
- 08 Aug, 2024 23 commits
-
-
Josh Story authored
In preparation for a number of new features and rendering modes this PR dramatically refactors app-render and related files to make future contributions easier to land. Historically we have used AsyncLocalStorage to scope state that is contextual for an entire page export (RSC > SSR > error handling etc...) however it can be useful and is generally a good practice to push the ALS scoping deeper into the render when possible. One case is for tracking dynamic access. in this PR we introduce prerenderAsyncStorage which is wrapped around individual render calls into React. If there is a store during a render then we can infer we are in an App Router prerender. Longer term we should consider combinging the requestStorage and staticGenerationStorage since these are scoped at the same level and the name of staticGenerationStorage is misleading because it is in scope even when there is no static generation happening. In addition to storage changes the code paths for app-render are reorganized to use fewer closures and to consolidate argument passing. Additionally we now treat render (dynamic request handling) and prerender (build and revalidate handling) in separate code paths. This allows for clearer login within each pathway and fewer repeated conditionals. There are still a number of things to further clean up like how we track metadata. One idea is to have the render/prerender functions simply return a RenderResult. Another area is error handling. There is currently a bug where ssr only errors won't fail a build the same way an RSC error would. To keep this PR clean I've reproduced this behavior even if it is buggy so we can land a fix stacked on top
-
vercel-release-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates font data with latest available --------- Co-authored-by:samcx <sam@vercel.com>
-
Hendrik Liebau authored
Setting the terser option `mangle` to `false` for dev server runtime bundles as done in #68641 seems to be incompatible with `'eval-source-map'`, i.e. when running `pnpm dev`. The combination yields strange runtime errors when running an app with the node runtime. E.g.: ``` ⨯ TypeError: isValidElementType is not a function at renderToHTMLImpl (webpack://next/dist/src/server/render.tsx?e2d9:568:10) at render (webpack://next/dist/src/server/route-modules/pages/module.ts?84fd:125:12) ``` or ``` TypeError: Cannot read properties of undefined (reading 'contexts') at Object.<anonymous> (<snip>/packages/next/src/server/route-modules/pages/vendored/contexts/html-context.ts:1:59) ``` or ``` ⨯ Error: Cannot find module 'next/dist/server/lib/trace/tracer' Require stack: - <snip>/packages/next/dist/compiled/next-server/app-page.runtime.dev.js - <snip>/test/e2e/app-dir/app/.next/server/app/dashboard/page.js ``` Since using `'eval-source-map'` already fixes showing the original names, we don't need to disable mangling in this case. **How to reproduce on `canary`:** - start `pnpm dev` - start `pnpm next dev test/e2e/app-dir/app` - open http://localhost:3000/client-component-route - observe errors -
Sebastian Silbermann authored
-
Hemanshu Upadhyay authored
Hey There
👋 This PR Includes the following changes -> Migration of with-absolute-imports example to App Router -> Updated all packages -> Added the Layout page as per App router Convention. cc - @samcx Co-authored-by:Sam Ko <sam@vercel.com>
-
vercel-release-bot authored
-
Jiwon Choi authored
### Why? In https://github.com/vercel/next.js/pull/68622 we fixed a bug that HMR breaks when `assetPrefix` is set to full URL. The fix was targeted to the edge case where the user may set `localhost` to the `assetPrefix`, and technically, when the request is valid the HMR should work. However, we do not recommend this pattern as the `assetPrefix` is intended to be used for setting a CDN URL. ### How? Therefore we modify the docs to gently imply that the `assetPrefix` is for CDN URL. Also, removed the warning log that could be confusing whether we support it or not. Setting localhost will still work, but we do not mention about it within the app.
-
JJ Kasper authored
These files can be present if server source maps flag is enabled so need copying as well. Also removes incorrect `_not-found` special case which will need revisiting and updating define-env check to not apply in dev. x-ref: [slack thread](https://vercel.slack.com/archives/C056QDZARTM/p1723119830912809)
-
JJ Kasper authored
Currently we only log warnings when we fail to parse config values and then fall back to their defaults, this is very dangerous as this can cause unexpected behavior and the warning log can be easy to miss. To prevent this unexpected behavior this updates to treat these as errors instead and fails the build if any invalid config exports are provided. x-ref: NDX-190
-
Josh Story authored
The server runtimes are currently all bundled in production mode with full optimizaitons. This can make certain things hard in dev mode because while most of your app will be unmangled anything that runs from the server runtime will be runnign without useful debug information like original function names. This PR updates the runtime configs to no longer mangle the output.
-
Jiachi Liu authored
### What Improve the test matcher for string matching while searching in array case, those flaky tests were giving unclear failing messages without enough context to help investigate the flakeness. ### Why Example of existing unclear flaky failure ``` pnpm test test/integration/link-ref/test/index.test.js • Invalid hrefs > production mode > should preload with child ref with React.createRef Expand output ● Invalid hrefs › production mode › should preload with child ref with React.createRef expect(received).toBe(expected) // [Object.is](http://object.is/) equality Expected: true Received: false ``` While looking at the test, assertions like `expect(found).toBe(true)` could fail without telling us what are the context, what is the original input before narrowing down as a boolean value. After changing to a composed testing matcher, we're able to see what href links are giving us the unexpected result ```ts expect(hrefs).toEqual( expect.arrayContaining([expect.stringContaining('index')]) ) ``` For example, if we're looking for a string pattern `first-1` in the link hrefs, but it only got `first`, the failure message would look like this. This will help us identify the root cause easier with more context. ``` ● Prefetching Links in viewport › production mode › should prefetch with link in viewport onload expect(received).toEqual(expected) // deep equality Expected: ArrayContaining [StringContaining "first1"] Received: ["/_next/static/chunks/pages/first-c9300691290bda9a.js"] 109 | links.map(async (link) => await link.getAttribute('href')) 110 | ) > 111 | expect(hrefs).toEqual( | ^ 112 | expect.arrayContaining([expect.stringContaining('first1')]) ```
-
Delba de Oliveira authored
Add helper notes for those struggling to upgrade to React 19 RC when using Next.js RC. [NDX-118](https://linear.app/vercel/issue/NDX-118/update-note-on-react-rc-versions-when-upgrading-to-nextjs-15-rc) --------- Co-authored-by:
Amy Burns <amy.burns@vercel.com>
-
Hendrik Liebau authored
Now that `react-dom/static` is also available outside of the experimental channel, we don't need to hard-code the react release channel in the bundle aliases anymore. Without this fix, `react-dom` would end up twice in our non-experimental server runtime bundles with the changes in #68637. <img width="1479" alt="react-dom twice in bundle" src="https://github.com/user-attachments/assets/ed50e9ec-b984-496b-92e1-69515f2afbc8">
-
Delba de Oliveira authored
Adds static indicator diagrams to the `devIndicators` docs. [DOC-3152](https://linear.app/vercel/issue/DOC-3152/add-static-indicator-diagrams).
-
Sebastian Silbermann authored
-
Jiachi Liu authored
### What Follow up on #67465, add more cases that should be rejected by image optimizer when the url is tend to contain the generated next image with `/_next/image` in url. These should also get should get rejected: * with encoded: `%2F_next%2Fimage%3` * with asset prefix: `/assets/_next/image` * with host: `https://<domain>/_next/image` Closes NDX-101 x-ref: [slack](https://vercel.slack.com/archives/C07AYREDX45/p1720111367743119)
-
Donny/강동윤 authored
### What? Type-only imports of `usePathaname` from server components are fine. ### How? Closes PACK-3186
-
Jiwon Choi authored
-
vercel-release-bot authored
-
JJ Kasper authored
As discussed we can tolerate sharing cache between source maps enabled and not e.g. sharing cache from main -> preview so this drops those related configs from the cache manifest.
-
Will Binns-Smith authored
It’s possible to the following scenario to occur: - Browser loads a page and establishes HMR connection - User quits the server, makes changes, and restarts the server - The browser reloads, the user makes more changes, and the two reach an inconsistent state To avoid this, reload the browser when the server changes. This already happened with webpack, so implement it for Turbopack. Test Plan: `TURBOPACK=1 pnpm test-dev test/development/basic/hmr.test.ts` --------- Co-authored-by:Tobias Koppers <tobias.koppers@googlemail.com>
-
Zack Tanner authored
The `Link` component has built in prefetch deduping behavior that was added for pages router, since pages only supports a single kind of prefetch. Both pages & app routers share the `Link` component, meaning the deduping behavior was enabled for both. However, app router supports different [prefetch types](https://nextjs.org/docs/app/api-reference/components/link#prefetch). This means that if a page contains a link to a URL with auto prefetching, followed by a URL with `prefetch={true}`, the full prefetch would not be applied because it was short-circuited by `Link`. Closes NDX-124
-
- 07 Aug, 2024 10 commits
-
-
vercel-release-bot authored
-
Jiachi Liu authored
-
JJ Kasper authored
If there's a bug in a previous cache or it mis-matches we need to ensure we prune it so it's not left around and merged at all when it shouldn't be. x-ref: [slack thread](https://vercel.slack.com/archives/C056QDZARTM/p1723065176374699?thread_ts=1723056506.642999&cid=C056QDZARTM)
-
Zack Tanner authored
### What During SSG, the fetch cache isn't shared between renders of different pages within a single export worker. This means that if **Page A** fetches `/foo` and **Page B** also fetches `/foo`, they will not be deduped and instead will be fetched from origin within each worker. Additionally, we currently only prerender 1 path per worker, which doesn't allow us to take advantage of concurrency or smarter groupings. ### Why Currently the export worker is set up to handle indivdual pages. We fire off an exportPage request to all of the known paths and jest-worker handles concurrency & parallelization. ### How This refactors the export worker to accept an array of paths. For this iteration, it doesn't attempt to do any smart grouping of paths (ie ones that share a layout, etc), it just tries to create reasonably sized groups. It will chunk a minimum of 25 pages per worker, and each worker will process `experimental.staticGenerationMaxConcurrency` (defaults to 2, tbd on final numbers here) exports at a time. This lets us set up the `IncrementalCache` inside of the worker before we process pages. As we process pages, the incremental cache will be populated with entries, and subsequent requests will leverage the cache rules therein. This also disables the auto no-cache behavior that we introduced with Next 15 during SSG. Unless a fetch is explicitly opting out of caching, we'll attempt to cache it during SSG so another worker can re-use it. Closes NDX-78 Closes NDX-19
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Turbopack.
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Turbopack.
-
hrmny authored
### What? Ports a few more useful scripts from nextpack, namely: - `patch-next` - `sweep` - `build-native` (to clean up incremental artifacts on compiler panics) - the macOS compression agent
-
Niklas Mischkulnig authored
I've simplified @timneutkens's tests from #66486 The resolver fix is in https://github.com/vercel/turbo/pull/8820 Closes https://github.com/vercel/next.js/pull/66486 Related issue: https://github.com/vercel/next.js/issues/66487 --------- Co-authored-by:
Tim Neutkens <tim@timneutkens.nl>
-
Jiachi Liu authored
### What Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. ### Why `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by:hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
-
Benjamin Woodruff authored
## Why? - These three task locals were pretty much always entered/exited at the same time. - Syntactically, this lead to some awkwardness, as each scope introduces another level of indentation. - Each task local adds more entries to the stack traces. - While entering/exiting each task local's scope is very cheap, it's not free, and it must happen on every task's await points. One task local instead of three reduces the work that needs to happen. ## Benchmarking Any change in performance is too small to benchmark. ``` cargo bench -p turbopack-bench -p turbopack-cli -- "hmr_to_eval/Turbopack CSR" ``` Manually increased the number of samples and execution time: ``` diff --git a/turbopack/crates/turbopack-bench/src/lib.rs b/turbopack/crates/turbopack-bench/src/lib.rs index 4e3df12db0..e2f16fb0d6 100644 --- a/turbopack/crates/turbopack-bench/src/lib.rs +++ b/turbopack/crates/turbopack-bench/src/lib.rs @@ -127,8 +127,8 @@ enum CodeLocation { pub fn bench_hmr_to_eval(c: &mut Criterion, bundlers: &[Box<dyn Bundler>]) { let mut g = c.benchmark_group("bench_hmr_to_eval"); - g.sample_size(10); - g.measurement_time(Duration::from_secs(60)); + g.sample_size(50); + g.measurement_time(Duration::from_secs(300)); bench_hmr_internal(g, CodeLocation::Evaluation, bundlers); } ``` Using a machine configured for low-noise: https://github.com/bgw/benchmark-scripts **Before:** ``` bench_hmr_to_eval/Turbopack CSR/1000 modules time: [14.713 ms 14.779 ms 14.862 ms] Found 1 outliers among 50 measurements (2.00%) 1 (2.00%) high mild ``` **After:** ``` bench_hmr_to_eval/Turbopack CSR/1000 modules time: [14.732 ms 14.800 ms 14.886 ms] change: [-1.1606% +0.1132% +1.5420%] (p = 0.86 > 0.05) No change in performance detected. Found 1 outliers among 50 measurements (2.00%) 1 (2.00%) high mild ```
-