- 27 Aug, 2024 1 commit
-
-
vercel-release-bot authored
-
- 26 Aug, 2024 16 commits
-
-
Filip Kudła 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: - 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 - 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 - 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 - 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 - 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 Closes NEXT- Fixes # --> fixes #63820 fixes #55320 fixes #52931 In one of the issues, there was a suggestion to delete `assetPrefix` from `next.config`. It helps if you have `assetPrefix: '/'`. Otherwise, you probably won't face this problem. **Explanation:** The problem lies where the browser tries to connect and where websocket is available on the server. Adjust the condition for `prefix` in `get-socket-url` as it can return `''` which will lead to `//` in the url. The browser wants to connect to `ws://localhost:3000/_next/webpack-hmr` While internally next exposes the web socket under `ws://localhost:3000//_next/webpack-hmr` - you can connect to it via wscat, postman or whatever. As the path is different it does not handle HMR requests in the browser. In addition to that - Reuse logic and extract separate files as a helper in shared/lib. | Before | After | | ------ | ------- | |  before - latest canary branch - we can't establish a connection to HMR ws |  same example with local changes - connected to ws | --------- Co-authored-by:
Jiwon Choi <devjiwonchoi@gmail.com> Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Jiachi Liu authored
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)
-
Jiachi Liu authored
### What While going through the logic of flight manifest, found the `modRequest` sometimes accidentally become `"undefined"` string due to composing with another potential undefined value. This caused extra traversal, fixing this will improve a bit on the performance.
-
Zack Tanner authored
-
Zack Tanner authored
`x-middleware-cache: "no-store"` in Pages router is a way to signal to the client that it should not store the response in the cache. However in certain circumstances, namely when `unstable_skipClientCache` is true, the data request would be awaited and then stored in the `inflightCache` regardless of the header. The original implementation of this in the router has logic to delete the response from the inflight cache after the request has fulfilled because `inflightCache` stores the unresolved promise. But in this optimistic prefetch case, when we're only storing it in the cache once the request is fulfilled, we can prevent a race condition where the ignored prefetch is erroneously re-added to the cache by ensuring it's never added to the cache to begin with if the response says not to. Fixes #66881 Closes NEXT-3550
-
Janka Uryga authored
partial cherry-pick from #64604, needed for #67734
-
Zack Tanner authored
### What When using middleware + i18n in pages router, and upon navigation to a dynamic route, the wrong locale would be served in `getServerSideProps`. ### Why The route resolver code handles detecting the initial locale by splitting the path and looking at the first non-empty index to determine which locale was set. However, it does this assuming it has a regular path name, and not a `/_next/data` URL. When middleware is present, the route resolver code hits the `middleware_next_data` branch, which doesn't have any logic to properly set the locale. This means that resolveRoutes will return the default locale rather than the locale from the path. In the non-middleware case, this would normally flow through `handleNextDataRequest` in base-server which has handling to infer i18n via `i18nProvider`. This branch is functionally very similar to what we're doing in `resolveRoutes` but it does so in a different way: it reconstructs the URL without the `/_next/data` information and then attaches locale information. However because `middleware_next_data` rewrites the pathname to the actual route (ie `/_next/data/development/foo.json` -> `/foo`), `handleNextDataRequest` won't handle that request since it's no longer a data request. It's strange to me that `handleNextDataRequest` and `middleware_next_data` are doing similar path normalization in completely different ways, but that was a deeper rabbit hole and simply removing the normalization logic in `resolveRoutes` causes other problems. ### How Since data requests that flow through this middleware matcher logic aren't going to be handled by `handleNextDataRequest`, I've updated `middleware_next_data` to perform the logic of attaching the locale information to the query. Initially I was going to do this for anything that calls `normalizeLocalePath` but it seems like other branches of `resolveRoutes` do it in the matcher function directly. Fixes #54217 Closes NDX-116
-
Vercel Release Bot authored
This auto-generated PR updates font data with latest available --------- Co-authored-by:samcx <sam@vercel.com>
-
Jiachi Liu authored
Add deployment id for skew protection into RSC payload --------- Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Sukka authored
A proper fix to #66448. The root cause of the issue is that Next.js gets SWC bindings list from `package.json`'s `optionalDependencies` when patching the lockfile. Recently Next.js added `sharp` to the `optionalDependencies`, which causes `sharp` to be wrongly treated as Next.js SWC bindings when matching versions (hence the `undefined`). The PR adds a filter after reading `optionalDependencies`. cc @huozhi @eps1lon Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Ian Marlier 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 # --> fixes #64364 As noted in the bug, the `dataLayer` parameter to the GoogleTagManager third-party component should be an object (which gets passed to `JSON.stringify()` at https://github.com/vercel/next.js/blob/canary/packages/third-parties/src/google/gtm.tsx#L43), and not an array of strings. (I'm speculating a bit, but assuming that the original intent was that an object could be serialized and passed to the component, but then the call to stringify was added to the component as well.) I'm not thrilled about duplicating the JSONValue type, which also exists in `packages/next/src/server/config-shared.ts`, but wasn't sure whether it would be preferred to export from there -- this doesn't feel like it's likely to be an issue, but I'm perfectly happy to change --------- Co-authored-by:
Sam Ko <sam@vercel.com>
-
Kiko Beats authored
The only change in this new version is that the project is now licensed under the MIT license. --------- Co-authored-by:Janka Uryga <lolzatu2@gmail.com>
-
Sung Ye In authored
Co-authored-by:Jiwon Choi <devjiwonchoi@gmail.com>
-
Joseph authored
Co-authored-by:Jiwon Choi <devjiwonchoi@gmail.com>
-
JJ Kasper authored
This refactors our handling of passing routing information to the render logic via headers which is legacy from when we had separate routing and render workers. Now this will just attach this meta in our normal request meta handling which is more consistent and type safe.
-
Sam Ko authored
`undici` should be able to compile and bundle now. - x-ref: https://github.com/vercel/next.js/pull/65243 --------- Co-authored-by:
Jiachi Liu <inbox@huozhi.im>
-
- 23 Aug, 2024 1 commit
-
-
Tobias Koppers authored
It's annoying that all people are requested as reviewer on every PR. Instead we want to manually request specific people.
-
- 22 Aug, 2024 1 commit
-
-
Janka Uryga authored
-
- 21 Aug, 2024 2 commits
-
-
vercel-release-bot authored
-
JJ Kasper authored
To reduce the number of set requests we were sending upstream we added an optimization to skip sending the set request if the cached data didn't change after a revalidation. The problem with this optimization is the upstream service relies on this set request to know to update the cache entries TTL and consider it up to date. This causes unexpected revalidations while the cache value hasn't changed and the TTL is kept stale. x-ref: NEXT-3693 # Conflicts: # packages/next/src/server/lib/incremental-cache/fetch-cache.ts # test/turbopack-build-tests-manifest.json
-
- 05 Aug, 2024 2 commits
- 02 Aug, 2024 1 commit
-
-
Mark Knichel authored
This makes the Multi-Zones docs available in the live nextjs.org site.
-
- 10 Jul, 2024 1 commit
-
-
vercel-release-bot authored
-
- 09 Jul, 2024 13 commits
-
-
Jiachi Liu authored
-
JJ Kasper authored
Gives us more context when this fails as it is here https://github.com/vercel/next.js/actions/runs/9469195858/job/26087290365#step:15:23
-
JJ Kasper authored
This ensures we always set up turbo to the version we expect even if we're building in docker since the cache is pulled outside of docker. x-ref: https://github.com/vercel/next.js/actions/runs/9484631800/job/26134568488
-
Jiachi Liu authored
backport #65715 into 14.2
-
Tobias Koppers authored
### What? This disallows merging of global css with styles that appear on other pages/chunk groups. ### Why? Before we made the assumption that all CSS is written in a way that it only affects the elements it should really affect. In general writing CSS in that way is recommended. In App Router styles are only added and never removed. This means when a user uses client-side navigations to navigate the application, styles from all previous pages are still active on the current page. To avoid visual artefacts one need to write CSS in a way that it only affects certain elements. Usually this can be archived by using class names. CSS Modules even enforce this recommendation. Assuming that all styles are written this way allows to optimize CSS loading as request count can be reduced when (small) styles are merged together. But turns out that some applications are written differently. They use global styles that are not scoped to a class name (e. g. to `body` directly instead) and use them in different sections of the application. They are structured in a way that doesn't allow client-side navigations between these sections. This should be valid too, which makes our assumption not always holding true. This PR changes the algorithm so we only make that assumption for CSS Modules, but not for global CSS. While this affects the ability to optimize, applications usually do not use too much global CSS files, so that can be accepted. fixes #64773
-
Jiachi Liu authored
### What Add isEdgeRendering check condition for rewrite logic in edge adpator Fixes #66837 Closes NEXT-3545 ### Why From headers `x-middleware-rewrite`, it's still relative url `/rewrite`, reconstructing the url will lead to crash as it doesn't contain host.
-
Steven H authored
This PR introduces a **breaking change** that returns a 400 error if the Image Optimization API is given a protocol-relative URL. The Image Optimization API currently checks whether the given image URL is relative by checking `url.startsWith('/')`. This means that protocol-relative URLs, such as `//example.com`, pass the check and are treated as relative. They in turn skip any kind of validation provided when matching against `remotePatterns` and are passed back to the optimation logic as a relative URL. My knowledge of the stack stops there, but in our case at GitBook it led to a nasty attack where non-GitBook content could be served over this URL: https://docs.gitbook.com/_next/image?url=//example.com&w=1200&q=100 - even though we have configured `remotePatterns` to protect against it. I originally went into the problem wanting to handle the URL properly (treating it as an absolute URL and potentially using the protocol of the Optimization API itself as the relative protocol), but after seeing the code in https://github.com/vercel/next.js/blob/canary/packages/next/src/client/legacy/image.tsx#L135 and https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/image-loader.ts#L26 it feels that protocol-relative URLs are just not really supported anywhere. My understanding is that very few uses of `next/image` will be allowed to use protocol-relative URLs, so the impact of this breaking change should be quite low? If others disagree I am happy to modify and to use the protocol of the request as a stand-in for the relative protocol. --------- Co-authored-by:Steven <steven@ceriously.com>
-
OJ Kwon authored
### What For loading wasm, path interop to absolute file path occurs in here (https://github.com/vercel/next.js/blob/canary/packages/next/src/build/swc/index.ts#L1249) already so shouldn't pre-populate import path when call loading wasm to make internal path operation (https://github.com/vercel/next.js/blob/canary/packages/next/src/build/swc/index.ts#L1247) work.
-
Jiachi Liu authored
Use `addDependency` to track the file path passed to `next-metadata-route-loader` NOTE: We cannot apply the `next-metadata-route-loader` directly to the metatda convention source files, since the json file could be processed by json loader (Related previous fix #62615) Previously when we passed down the file path as argument to the loader, which sort of breaking the caching of webpack as the actual resource path is string, it's not tracked as a dependency. This change fixed the bad caching issue of static metadata routes. Based on the above reason we use `addDependency` here to track the dependency change Closes NEXT-3521 Closes #65755
-
Jiachi Liu authored
Render noindex into a flight data and rsc payload when page path is `/404` When it's static generation, noindex is not rendered due to the statusCode from mock request is 200, but we can relying on the pagePath as `/404` page should always contain `nonidex` We were missing the noindex before for flight generation, now we'll render it when it's 404 page.
-
Steven authored
-
Jiwon Choi authored
Identified the bottleneck of Turbopack HMR, one of the reason is that we run `execSync` to get user's package manager and fetch their registry to get the latest & canary version of Next.js. This process was located at the initial of HMR, which could have been delayed to the initial of the error handling. - Remove getting user's package manager and just fetch from NPM regardless the user uses Yarn. - Used an async IIFE to await the promise of `getVerionInfo` value inside the synchronous `ws.handleUpgrade`. > Benchmarked with console inside try-finally | Version | Ready | |-------------------------------------|---------| | Canary | 1185ms | | Delta | 896ms | | Delta Webpack vs Canary Webpack | -24.39% | | Version | Ready | |-------------------------------------|---------| | Canary | 1002ms | | Delta (Turbopack) | 509ms | | Delta Turbopack vs Canary Turbopack | -49.20% | --------- Co-authored-by:
Jiachi Liu <inbox@huozhi.im> Co-authored-by:
Tobias Koppers <tobias.koppers@googlemail.com>
-
Jiwon Choi authored
cc @icyJoseph @ztanner NOTE: The canary release [`v14.1.1-canary.51`](https://github.com/vercel/next.js/releases/tag/v14.1.1-canary.51) and below work as expected. ### Why? Introduced from #61535, the initial prefetch cache is set based on the `location.pathname`. When a page is loaded WITH the search param, the cache key does not contain information of the search param. The issue is when on a dynamic page reading the `searchParams` value, the value doesn't change if navigated as: ``` /?q=foo --> / ``` The prefetch cache hits, not re-rendering, and the `searchParams` value is not passed properly. ### How? For the prefetch cache, add the `location.search` as well. Since `createPrefetchCacheKey` uses [`createHrefFromUrl`](https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/router-reducer/create-href-from-url.ts) which includes `location.search`, I'm expecting the change won't affect current cache key behavior. Fixes #64170 Fixes #65030 --------- Co-authored-by:
Zack Tanner <1939140+ztanner@users.noreply.github.com>
-
- 02 Jul, 2024 1 commit
-
-
Donny/강동윤 authored
### What? Backport https://github.com/swc-project/swc/pull/8835. Changes: - `swc_core`: `v0.90.30` => `v0.90.31` - `swc_ecma_transforms_compat`: `0.163.18` => `v0.163.19` ### Why? It fixes a bug of class properties transform. ### How? Fixes #66085
-
- 11 Jun, 2024 1 commit
-
-
vercel-release-bot authored
-