forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pull] canary from vercel:canary #2040
Open
pull
wants to merge
6,885
commits into
NOUIY:canary
Choose a base branch
from
vercel:canary
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,436,856
−936,350
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Apr 27, 2024
Allows us to remove some `any` casts and `@ts-expect-error`.
#75052) ### What? Chunk async loaders together with normal chunk items to avoid multiple chunkings and small chunks
### What? It **removes** needless allocations. ### Why? To avoid allocating memory needlessly.
### What? Reduce allocations for SWC plugins, by applying swc-project/plugins#393 ### Why? Those are actually noop so they should not allocate too much.
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Fixes all issues related to the current export statement validation for app router pages, as highlighted in #75277.
…75279) The `"use cache"` directive is not compatible with the Edge runtime. When the `experimental.useCache` flag is enabled, we now emit a build error for pages with `export const runtime = 'edge'`. This is analogous to using the `experimental.dynamicIO` flag. The other route segment configs that are forbidden when `dynamicIO` is enabled, are currently still allowed for `useCache`: - `dynamicParams` - `dynamic` - `fetchCache` - `revalidate`
### What? * change turbopack-cli to new backend * avoid transient tasks in turbopack-cli
### What? NextJS should not throw `The "use server" file can only export async functions.` for type exports. ### Why? Because type exports are just a compile time abstraction.
…low local-task-based argument resolution (#75214) Removes the (now default) feature flag for local task argument resolution. With local-task based argument resolution in place, we don't need to support argument resolution in the backend, which simplifies some code.
…is_call/native_this_call (#75253) The `_this` argument variants of these functions are 99% of the same, so this deduplicates them.
…outputs and cells (#75171) We only read data owned by the the currently-executing task when reading from a local Vc, so: - A separate "untracked" API doesn't make sense. There's never any tracking needed for reading local outputs or cells. (would we mark the current task as dependent on itself?) - Allowing a `consistency` argument isn't useful because you can't strongly consistently await your own task. - We don't need to call `notify_scheduled_tasks`, we're not adding any new task dependencies.
A function returning an `OperationVc` can call a transient function or have a transient argument. IMO, `TaskInput` should not have default method implementations to avoid potential footguns like this.
### What? This reduces the overallocated memory by InnerStorage instances in the DashMap capacity
### What? * move code from macro into generic struct * move dynamic storage access into separate struct * generate inline storage for common data
This improves the build script quite a bit and makes dev editing much faster. Also fixed excludes causing webpack/babel compiled packages to be bundled into the runtime un-necessarily reducing from `10MB` -> `1.2MB`. Before: `Finished next_bundle in 9.67s` After: `Finished next_bundle in 1.27s` Validated here https://github.com/vercel/vercel/actions/runs/12957911052/job/36147343396?pr=12914
….)]` (#75259) Allows tasks to be marked as local using `#[turbo_tasks::function(local)]`. Local tasks are cached only for the lifetime of the nearest non-Local parent caller. Local tasks do not have a unique task id, and are not shared with the backend. Instead they use the parent task's id and store data in the backend-agnostic manager. This is useful for functions that have a low cache hit rate. Those functions could be converted to non-task functions, but that would break their function signature. This provides a mechanism for skipping caching without changing the function signature. Local tasks are already used for argument resolution, this allows other arbitrary functions to be opted-in.
### What? * more memory efficient AggregationUpdateQueue by using SmallVec and boxing some job types * avoid allocation in CaptureFuture by avoiding the Arc and the Mutex and using a thread local reference
Just ensures we keep mangling behavior prior to #75294 --------- Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
Way less turbo tasks Less CPU time, 300mb less memory. ``` testing against 0293c96cf32 uncell AstPath 77d7015 (PR below in this stack) 13,65 GB TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD= 505.04s user 83.92s system 853% cpu 1:09.00 total TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD= 509.03s user 84.26s system 829% cpu 1:11.53 total snapshot in with_modules c2c661b 13,3 GB TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD= 491.50s user 79.78s system 856% cpu 1:06.69 total TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD= 495.62s user 78.61s system 852% cpu 1:07.36 total ```
Lifts the style fix from #75718 into a separate PR. Fixes the feedback bar clipping the content: ![410278234-8a7d9d9e-b483-4019-bc8a-524e755b3dd7](https://github.com/user-attachments/assets/3dd90148-6835-4954-9341-ae10c3c14679) Co-authored-by: Jude Gao <jude.gao@vercel.com>
…riginal stack frames (#75743) ### Why? When fetch fails to get the original stack frames, the process to get the Runtime Errors fails. The fetch will likely fail on Storybook stories. | Before | After | |--------|--------| | ![CleanShot 2025-02-06 at 21 21 19](https://github.com/user-attachments/assets/7e136a02-8b1f-4ec0-8430-e02d919610c3) | ![CleanShot 2025-02-06 at 21 21 33](https://github.com/user-attachments/assets/5ce9f95f-f5a2-4738-b8c5-5152733aeab7) | ### How? Correctly reject when request fails so that it may be caught at `_getOriginalStackFrame()` and return the stack frame.
Add and apply the merge multiple class names util. Closes NDX-664 --------- Co-authored-by: Jiachi Liu <inbox@huozhi.im>
These TODOs are very old. Clean them up!
No significant perf impact
- Fix the `npm` command - Make it clear where to place test files - Was reported here: #71773 - Relevant Next.js code: https://github.com/vercel/next.js/blob/ae5026a0fa8cd67f434cf63cc1db7d7ee696c047/packages/next/src/experimental/testmode/playwright/default-config.ts#L13 - Make it clear that `next.onFetch` only works for external requests. - Relevant Next.js code: https://github.com/vercel/next.js/blob/d2711d22fb719131d63cbce05a6306917f3626ea/packages/next/src/experimental/testmode/playwright/page-route.ts#L34-L40
This was dead code after we removed `swc_css`
This was wrong #75693
) ## Why? To track issues that are marked "not stale," we need to explicitly add a not stale label. https://github.com/actions/stale does not use this label by default.
## What? This addresses [#68217](#68217) where middleware, incorrectly, does not run for _next/image requests. We can confirm this is not correct behavior through the explanation of middleware matchers in [docs](https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher) > The matcher config allows full regex so matching like negative lookaheads or character matching is supported. An example of a negative lookahead to match all except specific paths can be seen here: > ```typescript > export const config = { > matcher: [ > /* > * Match all request paths except for the ones starting with: > * - api (API routes) > * - _next/static (static files) > * - _next/image (image optimization files) <- This means middleware **should** run for _next/image > * - favicon.ico, sitemap.xml, robots.txt (metadata files) > */ > '/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)', > ], > } > ``` ### When did this regress The regression happened here https://github.com/vercel/next.js/pull/57161/files#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL1245 > The diff since github isn't inlining the diff > ```diff > - let finished = await this.handleNextDataRequest(req, res, parsedUrl) > + finished = await this.handle(req, res, parsedUrl) > ``` > Note, `handle` groups calls to `handleNextDataRequest` **and** `handleImageRequest` https://github.com/vercel/next.js/pull/57161/files#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aR1316-R1328 ### Why was this a regression Inside of `handle`, there is a new call to `handleNextImageRequest` (this fn handles image optimization). This ends up causing image optimization to run before user middleware code runs. When the image optimization completes, the server behaves as if the entire middleware pipeline is complete, which is **before** user middleware code is ran https://github.com/vercel/next.js/blob/d2711d22fb719131d63cbce05a6306917f3626ea/packages/next/src/server/base-server.ts#L1528-L1540 Said plainly, image optimization now runs in middleware. And when image optimization completes, it blocks user middleware code from running. Im going to assume this was an incorrect refactor since there did not seem to be a motivation for the behavior change in #57375 ### Solution The solution proposed is to follow the same behavior as `handleNextDataRequest`, which early returns during middleware: https://github.com/vercel/next.js/blob/d2711d22fb719131d63cbce05a6306917f3626ea/packages/next/src/server/base-server.ts#L728-L745 > Note, `handleNextDataRequest` has an extra condition that it only skips middleware requests when its not on edge. I’m going to assume this is not what we want for image optimization, since there was never an edge check for image optimization- to hedge I don’t have any knowledge on what can run on edge in this context And for confirmation that the new ```handleNextImageRequest``` (added in the regression mentioned) is truly redundant, you can confirm the image optimization happens when `invokePath` is specified in the request meta or when `'x-matched-path'` header exists (as far as my understanding goes, and based on the behavior I observed from runtime checks, these 2 cases should be exhaustive) : https://github.com/vercel/next.js/blob/d2711d22fb719131d63cbce05a6306917f3626ea/packages/next/src/server/base-server.ts#L1470-L1526 https://github.com/vercel/next.js/blob/d2711d22fb719131d63cbce05a6306917f3626ea/packages/next/src/server/base-server.ts#L1078-L1378 > what's relevant in both above snippets > ```typescript > finished = await this.normalizeAndAttachMetadata(req, res, parsedUrl) > if (finished) return > ``` > Note: it's probably optimal to not call normalizeAndAttachMetadata in the if middleware branch at all since both handlers in the function now no-op if they are handling middleware (which is guaranteed in that branch). Im not applying that change here to avoid scope of the fix, but can make the refactor upon request https://github.com/vercel/next.js/blob/d2711d22fb719131d63cbce05a6306917f3626ea/packages/next/src/server/base-server.ts#L1633-L1646 ## TLDR The problem is that image optimization runs before user middleware code, and when it completes successfully, it skips running user middleware code- which means requests to _next/image will not have middleware run for them. The solution is to not run the image optimization in middleware that caused the skip Fixes #68217 --------- Co-authored-by: Joseph Chamochumbi <jchamoch@volvocars.com>
Errors thrown by the lint worker would only surface the error if `JEST_WORKER_ID` is present. This check was not reliably truthy in all cases (eg, when run with the vercel CLI, `JEST_WORKER_ID` wasn't present) which meant the build would fail with no helpful error message. Outside of that, it was a brittle check because if jest-worker ever changed or removed this env, or we replaced the underlying worker library, this would start failing. This updates the check to be a more explicit env variable that we control. Fixes NEXT-3994
This makes sure we properly copy the necessary files in standalone mode and node middleware is configured also adds regression test for this.
### Why? The focus outline was none, so it was unable to tell if it was focused. ### Before https://github.com/user-attachments/assets/5284fb54-cf84-4da5-a047-8d76b3f05eba ### After https://github.com/user-attachments/assets/d2f66880-cb2a-41ce-a620-67f6efed4684 Closes NDX-793
Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
Fix the link style to match the design #### After <img width="707" alt="image" src="https://github.com/user-attachments/assets/a9734833-8e28-4bfd-9155-b39a06fc275c" /> #### Before <img width="693" alt="image" src="https://github.com/user-attachments/assets/a089af37-e8b0-490c-842c-f4fa9bca9275" />
<!-- 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? Update swc_core, and enable `swc_core/ecma_ast_shrink`. ChangeLog: swc-project/swc@swc_core@v13.0.4...swc_core@v13.1.0 ### Why? - To add `AST.shrink_to_fit()`. - To apply memory usage optimizations.
…#75802) ## Why? Issues with the `Documentation` **Type**, which is issues opened via the `Documentation` issue template, should not be prematurely closed with **Invalid Link** from [nissuer](https://github.com/balazsorban44/nissuer).
### What? Use `shrink-to-fit` crate instead of inline trait in turbo-tasks. ### Why? It's a separate crate, so SWC AST implement the `ShrinkToFit` trait.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot]
Can you help keep this open source service alive? 💖 Please sponsor : )