- 12 Aug, 2025 17 commits
-
-
nextjs-bot authored
-
Benjamin Woodruff authored
Turbopack: Watch parent directories before watching children in `non_recursive_helpers::start_watching_dir_and_parents` (#82454) Fixes a potential race condition https://github.com/vercel/next.js/pull/82130#discussion_r2249131891: > I think there is a race condition here, when the child dir is created while we are walking the parent directories. > > 1. we try to watch /path/to/dir but it doesn't exist. > 2. /path/to/dir is created > 3. we move to the parent directory (`path/to`) and start watching it. > 4. But we already missed the event that path/to/dir was created. > > I think we need to run the loop reverse direction, watching parent directories first before watching the child directories. This way we already have the parent directory watcher setup before "reading" the child directory (reading in the sense of starting to watch it). Tested by putting a `println!()` in `start_watching_dir` and observing that the parents were watched first when running ``` rm -rf /tmp/fuzz && cargo run -p turbo-tasks-fuzz -- fs-watcher --fs-root /tmp/fuzz ```
-
Joseph authored
Fixes: https://github.com/vercel/next.js/issues/82515 When global-error, and presumably other similar files are defined by users,`next build` (Webpack) outputs this to `.next/server/app/page.js`(removed some values for brevity, see OP for more): ```js layout: [/* */], "global-error": [() => Promise.resolve().then(c.bind(c, 6076)), "/my-app/app/global-error.tsx"], "global-error": [() => Promise.resolve().then(c.bind(c, 6076)), "/my-app/app/global-error.tsx"], "not-found": [/* */], forbidden: [/* */], unauthorized: [/* */], metadata: { /* content */ } ``` Since this is then loaded into memory (copied to a JS file that's later parsed - rather), the last `global-error` key is used ( `{a: 0, a: 100}` is just `{a: 100}`) - In this case though, the duplicate keys have the same value too which makes this a **nice** to fix. This PR does a `reduceRight` pass checking if we have seen this `file` already, if so, skip. That should be safe enough to not introduce regressions. Verified Turbopack builds just for the sake of it - no "issue" there.
-
Jiachi Liu authored
-
Niklas Mischkulnig authored
It ran `postcss(webpack(postcss(filesource)))`, which doesn't work. And changing the order does make sense, since we do want Webpack (SCSS) to run first, and only then PostCSS? #82554 didn't catch every case
-
nextjs-bot authored
-
Steven authored
As a follow up to PR https://github.com/vercel/next.js/pull/82538 this PR adds an experimental flag to optionally skip `sharp.metadata()` and rely only on the JS implementation for format detection.
-
Zack Tanner authored
We are dropping amp support in an upcoming major. This adds a warning for using these configuration options and updates the docs with the warning. --------- Co-authored-by:Sebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com>
-
Niklas Mischkulnig authored
1. Don't resolve symlinks in `outputFileTracingIncludes`. Otherwise if you specify `node_modules/foo/*` in there, it will resolve to `node_modules/.pnpm/foo/*` and `require("foo")` won't work anymore because there no symlink in `node_modules/foo` anymore. This is also what happens with Webpack 2. Align `read_glob` with `read_dir` in that the hashmap keys only contain the path segment, and not the full path. 3. Support globing parents of the start folder: if the glob can match `..`, then also try to match `directory.parent_folder().read_glob(glob)` Closes PACK-5219 -
Luke Sandberg authored
# Fix glob handling for NFT JSON asset includes and excludes The current webpack version uses the https://www.npmjs.com/package/glob package to match and notably only handles `../` when it appears in a prefix position ([ref](https://www.npmjs.com/package/glob#:~:text=..%20path%20portions%20are%20not%20handled%20unless%20they%20appear%20at%20the%20start%20of%20the%20pattern)), so we do the exact same thing here. This allows our read_glob traversal to only consider traversing 'down' from the root since we can preprocess the patterns to not include `../` or `./` Part-Of PACK-5219
-
Niklas Mischkulnig authored
Don't return the `Result:Err`, but turn into an issue and return `Unparseable` Also fixes the location translation: Lightning CSS uses 1-based columns, while Turbopack uses 0-based column indices.
-
nextjs-bot authored
-
Sebastian "Sebbie" Silbermann authored
-
Tobias Koppers authored
### What? make sure to apply PostCSS on .module.css that is requested from RSC. Fixes a regression from #82448 Closes #82545
-
Sebastian "Sebbie" Silbermann authored
To enable `name` on `Activity`.
-
Rob Pruzan authored
Wraps stories in context providers, and replaces any old arguments that were being passed before the props -> context refactor in devtools Closes NEXT-4642
-
Jude Gao authored
The prelude is empty when the entire app is suspended during prerender. Typically this indicates a lack of suspense boundary in the app, which creates no static shell, thus throwing error. However, if the root layout itself is dynamic but wrapped under a suspense, we need special logic in this PR to detect that.
-
- 11 Aug, 2025 22 commits
-
-
Jude Gao authored
`Mediapartners-Google` used to match both `HEADLESS_BROWSER_BOT_UA_RE` and `HTML_LIMITED_BOT_UA_RE`, causing inconsistent state values for `getBotType`, `isDomBotUA`, and `isHtmlLimitedBotUA`.
-
Benjamin Woodruff authored
Turbopack: Rework watcher data structures, store watched list and watcher behind the same RwLock (#82258) Reworks the data structures used for the watcher to achieve a few goals: - I want to avoid multiple locks, as I don't think we actually need two different locks, and multiple locks leaves more room for bugs (e.g. lock inversion). - The information about if we're in non-recursive mode or recursive mode needs to be available outside of the lock for performance reasons. - The `watching`/`watched` set needs to be ordered. We don't have a convenient concurrent BTreeSet or Trie/Radix Tree pulled in, and I'd like to avoid adding more dependencies. We end up locking `notify_watcher` anywhere we'd need a write lock anyways, so it might block a few reads, but otherwise it's not that bad. Fixes in this PR: - Fixes an issue where multiple concurrent calls to `ensure_watching` for the same directory could cause one of those calls to exit early. This may cause a file in that directory to be read before the filesystem watcher is set up, potentially missing events. - Improves the time complexity of `restore_if_watching` using an ordered set to avoid iterating over all of `watched` to find child directories. See `OrderedPathSetExt`. This time complexity problem is introduced in the previous PR, #82130. Other changes: - It turns out that we don't need to explicitly set up any watchers during `start_watching` except for the `root_dir`. If paths have already been read, they'll set up watchers before re-reading the file when we invalidate it! This simplifies things, and means there's less stuff we need to track if you never start the watcher (i.e. `next build`). - Added a `--start-watching-late` option to the fuzzer to test calling `start_watching` after all the initial reads happen, to help validate the safety of the claim in the previous bullet point. Minor (aesthetic) changes: - Use past tense: `watching` is now `watched` and `ensure_watching` is now `ensure_watched`, as the `watched` list includes both currently active paths *and* previously watched but deleted paths. - Shorten the names of non-public types, because we have a lot more of them, and the names would get long otherwise ## Benchmarking This replaces a `DashSet<_>` with (essentially) a `RwLock<BTreeSet<_>>`. There's some risk of increased contention, particularly in the read-only fast-path for `ensure_watched`/`ensure_watching`. Under the assumption that the most heavily lock-contended use-case for this code is after restoring from persistent cache on a large repository: 1. Check out `vercel-site` in `front`. 2. Hack the new tracing span onto the canary version. 3. Build a release version with `pnpm pack-next --project ~/front/apps/vercel-site --no-js-build -- --release` 4. `rm -rf .next` 5. `NEXT_TURBOPACK_TRACING='turbo_tasks_fs' TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next dev --turbopack` 6. Load `http://localhost:3000/vercel`. Wait for it to fully finish loading. Stop the server with `ctrl+c`. 7. Restart the server, wait for it to finish initializing, and then exit. 8. Start the trace viewer: `pnpm next internal trace .next/trace-turbopack`, and look at the aggregated times of `ensure_watched`/`ensure_watching`. Results: before (canary): 313ms ensure_watching (2235x spans) after (this pr): 279ms ensure_watched (2235x spans) So no significant difference.
-
nextjs-bot authored
-
Joseph authored
Adding docs for `browserDebugInfoInTerminal`
-
Niklas Mischkulnig authored
A few months ago, this was fixed for Turbopack. Adding a regression test now
-
nextjs-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
Steven authored
This is a follow up to PR https://github.com/vercel/next.js/pull/82384 which fixed it for `<link>` but not for `next/font` that embeds local fonts in css. https://nextjs.org/docs/14/app/building-your-application/deploying#version-skew
-
Steven authored
In a previous PR https://github.com/vercel/next.js/pull/82118 we added a fallback to `sharp().metadata()` when the magic number didn't detect the image format in order to improve detection. But `sharp` can be slow to read metadata, so we should avoid it if we can. So this PR uses the existing `image-size` package to detect the content type in JS and only then does it fallback to the native `sharp` code if necessary. No tests were added since this doesn't change the behavior, only performance.
-
Benjamin Woodruff authored
These files need to be committed (why they're not in `.gitignore`), but I'm tired of `ripgrep` capturing these generated files.
-
nextjs-bot authored
-
nextjs-bot authored
-
Niklas Mischkulnig authored
Let's try this again ~~Blocked by https://github.com/vercel/next.js/pull/78058~~ Blocked by https://github.com/vercel/next.js/pull/82448 - [x] Add regression test - [x] Update failing assertions Closes PACK-4304
-
Niklas Mischkulnig authored
Replaces and closes https://github.com/vercel/next.js/pull/78058 Closes PACK-4324 Before, you got duplicate modules because `transition_to_client(postcss(webpack(source in rsc)) != postcss(webpack(transition_to_client(source in rsc))` Now, we have: ``` rsc layer --ESM import-> CSSModuleAsset(in rsc, contains raw SCSS source) --CssReferenceSubType::Inner-> CssAsset(first in client layer, then processed with Webpack loader) ``` This aligns it with when you import CSS from a client component, in both cases the CSS module is first transitioned into the client layer, and then processed with Webpack
-
Benjamin Woodruff authored
**This should be merged alongside #82258, as this introduces a potentially high time complexity operation that #82258 solves.** With this PR and the previous one, my fuzzer shows that we capture every (currently tested) file change correctly: ``` rm -rf /tmp/fuzz && cargo run --release -p turbo-tasks-fuzz -- fs-watcher --fs-root /tmp/fuzz ``` However, this does add an `O(n)` iteration of the `watching` map that I'm working on cleaning up (why this is still a draft). I'll do something similar to https://github.com/vercel/next.js/pull/82133, but it's a bit more complicated to switch to a `BTreeSet` because it's currently using a `DashSet`, and I don't want to introduce more locking than I have to.
-
nextjs-bot authored
-
Luke Sandberg authored
## Fix the build under the `tokio_tracing` feature https://github.com/vercel/next.js/pull/80738 changed the definition of LocalTaskSpec and moved the Display trait impl down to LocalTaskType but updating this use was missed since it is guarded by a feature.
-
Luke Sandberg authored
## Optimze cjs codegen by promoting `module` and `exports` to factory parameters *tl;dr; destructing is hard, lets go shopping!* Currently we prefix factories for cjs modules with `var {m:module, e:exports} = __turbopack_context__;` This is problematic since swc is unable to eliminate these bindings when they are dead (too afraid of es5 getter properties and side effects😭 ). Furthermore we are playing a game of telephone with ourselves since our caller basically is doing `factory({m:module, e: module.exports})` when they call us (this is skimming over a bunch of details, ofc). Instead just pass them directly as function parameters. One downside of this is that we still pass them to `esm` factories even though they are ignored (and simply not declared by the factories). This is not too costly since the caller has trivial access already and browsers are pretty good at handling/ignoring extra parameters (see https://v8.dev/blog/adaptor-frame for the clever way v8 optimizes this). ### Alternatives The main alternative considered was compile time replacing references to `module` and `exports` with `__turbopack_context__.(m|e)`. Unfortunately this breaks subtle edge cases of the cjs spec since it is allowed for users to rewrite `module` and `exports` with assignments (e.g. `exports = 'bad idea'`). This is generally a linter error but not unheard of and we cannot break it. The other alternative considered was enhancing `swc` to inline and dead code eliminate destructuring patterns, but from playing with the playgound it looks like swc is pretty conservative about moving/inlining variables across side effectful statements, so we would still be paying the cost of the declaration in many cases. ## Turbopack Performance Comparison: Head vs Change As expected this is a substantial improvement to commonjs evaluation. The ESM results are kind of confusing. I generally expected 'neutral' since the cost of passing a dead parameters is so small in modern vms. | Test Case | Metric | Head (ms) | Change (ms) | Speedup | Improvement | |-----------|--------|-----------|-------------|---------|-------------| | **Client CommonJS** | Load - Average | 31.61 | 24.38 | **1.30x** | **+29.6%** | | | Load - Median | 32.05 | 24.30 | **1.32x** | **+31.9%** | | | Load - P75 | 33.10 | 24.90 | **1.33x** | **+32.9%** | | | Execute - Average | 25.96 | 19.80 | **1.31x** | **+31.1%** | | | Execute - Median | 25.90 | 19.50 | **1.33x** | **+32.8%** | | | Execute - P75 | 26.50 | 20.20 | **1.31x** | **+31.2%** | | **Client ESM** | Load - Average | 22.28 | 21.94 | **1.02x** | **+1.6%** | | | Load - Median | 21.80 | 21.60 | **1.01x** | **+0.9%** | | | Load - P75 | 23.50 | 22.10 | **1.06x** | **+6.3%** | | | Execute - Average | 50.77 | 48.12 | **1.06x** | **+5.5%** | | | Execute - Median | 50.85 | 47.55 | **1.07x** | **+6.9%** | | | Execute - P75 | 51.60 | 48.30 | **1.07x** | **+6.8%** | | **Pages API CommonJS** | Load - Average | 24.18 | 23.33 | **1.04x** | **+3.7%** | | | Load - Median | 23.27 | 23.57 | 0.99x | -1.3% | | | Load - P75 | 25.29 | 23.96 | **1.06x** | **+5.5%** | | | Execute - Average | 32.23 | 24.26 | **1.33x** | **+32.8%** | | | Execute - Median | 31.16 | 24.34 | **1.28x** | **+28.0%** | | | Execute - P75 | 33.42 | 24.52 | **1.36x** | **+36.3%** | | **Pages API ESM** | Load - Average | 23.48 | 28.91 | 0.81x | -18.8% | | | Load - Median | 23.13 | 28.91 | 0.80x | -20.0% | | | Load - P75 | 25.55 | 29.57 | 0.86x | -13.6% | | | Execute - Average | 63.01 | 55.94 | **1.13x** | **+12.6%** | | | Execute - Median | 61.56 | 55.22 | **1.11x** | **+11.5%** | | | Execute - P75 | 69.56 | 56.40 | **1.23x** | **+23.3%** | **Legend:** - **Bold values** indicate performance improvements (speedups) - Regular values indicate performance regressions (slowdowns) - Speedup = Head Time ÷ Change Time (>1.0 = faster, <1.0 = slower) - P75 = 75th percentile -
Luke Sandberg authored
[turbopack] Fix a small issue in the analyzer where we wouldn't skip assignments to free vars that were just identifiers (#82392) Correctly skip assignments when replacing free variables Drop an `Option<..>` for a parameter that is always supplied. These are fixes i tripped over when attempting to compile time replace `module` and `exports`. That approach failed (see #82285 for what happened instead), but we can keep these cleanups.
-
Tobias Koppers authored
### What? Decrease the frequency of persisting since this is very expensive.
-
Andrew Clark authored
Originally, as part of the clientParamParsing feature, I expected that I would omit param values from the FlightRouterState when sending data from the server, and add it on the client. However, I've since realized this is unnecessary because FlightRouterState is only used during runtime server responses. Not in static responses, like per-segment prefetches. Since the goal of clientParamParsing is to omit param values from static responses, we don't need to change anything about FlightRouterState. We may still want to update how params are processed on the server to more closely match the implementation on the client, but that still doesn't require any changes to FlightRouterState. So, this deletes all the code related to adding client-parsed params to FlightRouterState on the client. None of this was being used anywhere; it was added by previous PRs in anticipation that it would eventually be used. But now we don't need it.
-
- 09 Aug, 2025 1 commit
-
-
nextjs-bot authored
-