- 25 Sep, 2024 12 commits
-
-
vercel-release-bot authored
-
Niklas Mischkulnig authored
Closes PACK-3276
-
Alexander Lyon authored
### What? Add `@taskr/esnext` to the root package.json to get around hoisting rules breaking `taskr`'s automatic discovery (and fix builds on some platforms where it is broken). ### Why? Some types of 'magically' imported packages (such as taskr automatically supporting es6 by just adding a package, or drizzle automatically finding a database driver) aren't hoisted on some platforms in the way the tool expects, breaking it. The symptom of this is taskr throwing a syntax error on some platforms, because we use ES6 syntax and it can't find the package it needs to support it. ### How? By adding it to the root package.json we ensure it is always hoisted in the way taskr expects.
-
Jam Balaya authored
-
Jiachi Liu authored
-
Niklas Mischkulnig authored
Occurs for example in ``` Failed to load chunk server/chunks/08b5e__pnpm_560cbe._.js .... Caused by SyntaxError: Identifier 'require' has already been declared .... ```
-
Niklas Mischkulnig authored
Closes PACK-3275 Among other things, a regression from https://github.com/vercel/next.js/pull/70255, but it could also happen with `__dirname`. To prevent `SyntaxError: Identifier 'require' has already been declared`
-
Tobias Koppers authored
### What? * While looking for server component entries and client components, look for server utils too * Create a separate chunk group for server utils * Mark all user imports in the rsc entrypoint has server component entries * Fix order of imports to allow proper caching --------- Co-authored-by:Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
-
vercel-release-bot authored
-
Benjamin Woodruff authored
Noticed this pattern while touching `turbo-tasks-fs`. Functions that take `self: Vc<Self>` and immediately await it without ever using the `Vc` version of the argument should just take `&self` as an argument. There are some remaining cleanup opportunities here, which I have some still-WIP codemods for: - [x] If we have a trivial `let this = self` or `let this = &self.0`, we should rewrite references to `this` to use `self`. *Done in #70431* - [ ] If we can be sure that a function never returns anything other than `Ok(...)`, we should remove `Result` from the return type. Those changes need to be performed as a separate codemod pass due to limitations with `ast-grep`. ## How? ast-grep: https://ast-grep.github.io/ Using the ast-grep config: https://gist.github.com/bgw/b7bc0a921cf3e3447acaf8feda60b518 Ran it with: ``` sg scan -U -r ../codemod_rewrite_vc_self.yml . ``` ## Should this be a lint? **Maybe.** I've managed to get the false-positive rate down to zero on our existing codebase (at the cost of missing some opportunities for cleanup). ast-grep supports running as a lint rule, and this can be autofixed. However, if we fix the `let this = ...` and `Result<...>` cases as well with additional lint rules, **this might be a bit annoying as it'll trigger cascading lint rules**. You *might* need to run the linter multiple times for it to eventually settle. It does not appear to be possible to do all these changes in a single lint rule, as we require modifying overlapping ranges of code (which ast-grep sadly doesn't seem to support with the `rewriters` rules). We should also consider `dynlint` before heavily investing into `ast-grep` as a linter: https://github.com/trailofbits/dylint
-
Donny/강동윤 authored
### What? Minor refactorings extracted from other PRs. ### Why? To make WIP small
-
JJ Kasper authored
Closes: https://github.com/vercel/next.js/pull/59342
-
- 24 Sep, 2024 28 commits
-
-
JJ Kasper authored
Closes: https://github.com/vercel/next.js/pull/58589/files
-
Benjamin Woodruff authored
Noticed these files while reviewing https://github.com/vercel/next.js/pull/70242 Mark them as generated so that github & graphite collapse them when reviewing code. ``` $ git ls-files | git check-attr -a --stdin | grep __snapshots__ ``` ``` .config/ast-grep/rule-tests/__snapshots__/no-context-snapshot.yml: linguist-generated: true examples/with-jest-babel/__tests__/__snapshots__/snapshot.tsx.snap: linguist-generated: true examples/with-jest/__tests__/__snapshots__/snapshot.tsx.snap: linguist-generated: true examples/with-typescript-graphql/test/__snapshots__/index.test.tsx.snap: linguist-generated: true test/development/acceptance-app/__snapshots__/ReactRefreshLogBox.test.ts.snap: linguist-generated: true test/development/acceptance/__snapshots__/ReactRefreshLogBox.test.ts.snap: linguist-generated: true test/development/acceptance/__snapshots__/ReactRefreshLogBoxMisc.test.ts.snap: linguist-generated: true test/development/acceptance/__snapshots__/error-recovery.test.ts.snap: linguist-generated: true test/development/basic/__snapshots__/next-rs-api.test.ts.snap: linguist-generated: true test/production/eslint/test/__snapshots__/next-build-and-lint.test.ts.snap: linguist-generated: true ```
-
Jiwon Choi authored
### Why? Prerequisite of `@next/codemod upgrade`. Current status of next-codemod is difficult to extend another commands as it relies on [meow](https://www.npmjs.com/package/meow) which requires to handle args and flags manually. For consistency with `next` and `create-next-app`, migrated to `commander` and `prompts`. https://github.com/user-attachments/assets/8d2e53be-4b7d-4755-9a3f-c73df1f9ef7e No behavioral changes **except the help message**.
-
Kutsan Kaplan 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 # --> A new gtmScriptUrl option has been added to the third-parties GTM package. This allows you to replace the default https://www.googletagmanager.com/gtm.js URL with a custom gtm.js URL, such as "https://gtm.example.com/gtm.js". Closes: https://github.com/vercel/next.js/pull/63767 Closes: https://github.com/vercel/next.js/pull/68531 Closes: https://github.com/vercel/next.js/pull/67161 Closes: https://github.com/vercel/next.js/pull/61145 Closes: https://github.com/vercel/next.js/pull/58262 --------- Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
JJ Kasper authored
Lands https://github.com/vercel/next.js/pull/54317 as we can't update the history cleanly on that PR anymore Closes: https://github.com/vercel/next.js/pull/54317Co-authored-by:
Andrés Martínez <78830288+andresmarpz@users.noreply.github.com>
-
Alessio Maffeis authored
Minor tweak to the wording of this section to better convey the behavior of `scroll: false`. "Restoration" can be interpreted as reinstating a previously saved scroll position for that route (as it happens when using `router.back()`), while what it actually does is preserving the current scroll position when navigating to a new route, by means of disabling the default "scroll to top" behavior. Related to: https://github.com/vercel/next.js/issues/57258, and https://github.com/vercel/next.js/discussions/47781#discussioncomment-7338499Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
hrmny authored
### What? Added a step in both `build-native.cjs` and `build-wasm.cjs` scripts to run Prettier on the generated types file after writing it. Should have been added with #69680, but I didn't think about it. Currently, every time you built the native module you have changes in the git repo (which would be fixed on commit, but graphite might not be happy with uncommitted changes).
-
JJ Kasper authored
Original PR is too out of sync so this lands separate. Closes: https://github.com/vercel/next.js/pull/66780
-
Sam Ko authored
## Why? - Refactor popular-prs workflow to `.ts` - Bump packages
-
Wyatt Johnson authored
Updates the configuration to specify a boolean argument rather than string literals.
-
Victor Berchet authored
- Fix `id` to be a string - Use `const` instead of `let` as common ESLint rules would complain otherwise - Add types to tsx files and remove some from jsx Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
PapatMayuri authored
This PR updates the ssr-caching example for using the App Router. Here are the changes that have been made: - Renamed the "pages" folder to the "app" folder. - Added the layout.tsx file as part of the App Router. - Updated the package.json file. CC: @samcx --------- Co-authored-by:samcx <sam@vercel.com>
-
vercel-release-bot authored
-
JJ Kasper authored
This ensures `env` keys in `next.config` are properly exposed during page collecting step during build since the inlining step comes after. x-ref: https://github.com/vercel/next.js/pull/70380 x-ref: https://vercel.com/vercel/vercel-site/9WqUX9vu15oVEy1acDqoXddcH27K?filter=errors
-
Benjamin Woodruff authored
This annotation implies that the field does not contain any `Vc` types, so we can re-use that here. We can skip checking for `ResolvedValue` on these fields. As we start codemodding stuff, we should consider renaming this annotation to something more generic (e.g. `#[turbo_tasks(does_not_contain_vc)]`), but this is good enough for now.
-
Ali Othmani authored
### What? This PR corrects and improves the documentation on the Data Fetching page, ensuring that the information is accurate and clear. ### Why? The previous version of the documentation contained inaccuracies or unclear explanations that could lead to confusion for developers. By addressing these issues, the documentation becomes more reliable and user-friendly. ### How? The changes involve updating the text to correct any misleading statements, adding clarity where necessary, and ensuring that all examples and explanations accurately reflect the intended data fetching process. --------- Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Benjamin Woodruff authored
#70269 adds support for `#[turbo_tasks::function]` to accept arguments of type `ResolvedVc<...>`, while still exposing a signature that uses `Vc<...>`. This PR allows them to also accept `ResolvedVc<...>` for `self`, using the nightly `arbitrary_self_types` feature. This re-uses the same mechanisms used for other arguments, with the added wrinkle that we can't shadow `self`, so we must rewrite the function body to replace references to `self` with `turbo_tasks_self`.
-
PapatMayuri authored
This PR updates the with-vercel-fetch example for using the App Router. Here are the changes that have been made: - Renamed the "pages" folder to the "app" folder. - Added the layout.tsx file as part of the App Router. - Updated the package.json file. CC: @samcx --------- Co-authored-by:samcx <sam@vercel.com>
-
Sam Ko authored
## Why? We should update our documentation and also throw an error if somebody tries to use the `.mts` ( ES Module TypeScript) extension with `next.config`. We currently don't support this extension. - Fixes: https://github.com/vercel/next.js/issues/70201 --------- Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Benjamin Woodruff authored
feat(turbo-tasks): Allow `#[turbo_tasks::function]`s to accept ResolvedVc types as arguments (#70269) ## Why? [We want to codemod structs to use `ResolvedVc<...>` for all of their field types instead of `Vc<...>`.](https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff?pvs=4) There are many constructor-like functions (see #70133) where we must accept an argument of type `Vc<...>`, and then explicitly call `.to_resolved().await?`. However, internally `#[turbo_tasks::function]` arguments are guaranteed to be resolved by the time the function runs. So we can do a cheap conversion here. ## What Instead of needing to do: ```diff #[turbo_tasks::value_impl] impl CustomProcessEnv { #[turbo_tasks::function] - pub fn new(prior: Vc<Box<dyn ProcessEnv>>, custom: Vc<EnvMap>) -> Vc<Self> { - CustomProcessEnv { prior, custom }.cell() + pub async fn new(prior: Vc<Box<dyn ProcessEnv>>, custom: Vc<EnvMap>) -> Result<Vc<Self>> { + let prior = prior.to_resolved().await?; + let custom = custom.to_resolved().await?; + Ok(CustomProcessEnv { prior, custom }.cell()) } } ``` It should now just be possible to accept `ResolvedVc` instead. The exposed function signature will be unchanged, still accepting `Vc` arguments, and a conversion will happen internally. ```diff #[turbo_tasks::value_impl] impl CustomProcessEnv { #[turbo_tasks::function] - pub fn new(prior: Vc<Box<dyn ProcessEnv>>, custom: Vc<EnvMap>) -> Vc<Self> { + pub fn new(prior: ResolvedVc<Box<dyn ProcessEnv>>, custom: ResolvedVc<EnvMap>) ->Vc<Self> { CustomProcessEnv { prior, custom }.cell() } } ``` This should also work for arguments where `Vc` is inside of a `Vec` or `Option` (other collection types are not currently supported). This PR does not support `self` arguments. That is handled by #70367. ## How - The macro inspects the argument type and rewrites it to replace `ResolvedVc` with `Vc` to get the exposed function's signature. - The `FromTaskInput` trait does the actual conversion. ### Why do this type expansion and conversion in the macro, and not as part of [the `TaskFn` trait](https://github.com/vercel/next.js/blob/8f9c6a86177513026ab4bc4fdc3575ca1efe025c/turbopack/crates/turbo-tasks/src/task/function.rs)? Without [specialization](https://github.com/rust-lang/rfcs/blob/master/text/1210-impl-specialization.md) it's not possible to implement the `FromTaskInput` trait for all `TaskInput` types, as we'd end up with overlapping impls for `Option<T>` and `Vec<T>`. There are specialization hacks ([inherent method specialization](https://github.com/dtolnay/case-studies/issues/14), [autoref-specialization, and autoderef-specialization](http://lukaskalbertodt.github.io/2019/12/05/generalized-autoref-based-specialization.html)) but those hacks are mostly for macros, not for generic code: > One thing might be worth clarifying up front: the adopted version described here does not solve *the* main limitation of autoref-based specialization, namely specializing in a generic context. For example, given `fn foo<T: Clone>()`, you cannot specialize for `T: Copy` in that function with autoref-based specialization. For these kinds of parametricity-destroying cases, “real” specialization is still required. As such, the whole autoref-based specialization technique is still mainly relevant for usage with macros. So we need the macro to determine if a type implements `FromTaskInput` or `TaskInput`. We can't do this inside of generic function. Aside from that, even though it's not as technically correct, expanding the types inside the macro results in *much* more readable types in rustdoc, which is why we do this in `expand_vc_return_type` as well, even though we could use a trait's associated type instead: https://github.com/vercel/turborepo/pull/8096 ## Test Plan ``` cargo nextest r -p turbo-tasks-memory test_resolved_vc cargo nextest r -p turbo-tasks-macros-tests function ``` Modify some code to use this, and use `rust-analyzer`'s macro expansion feature (after telling RA to rebuild proc macros).
-
Sam Ko authored
docs(parallel): clarify why separate slots cannot be static and dynamic at the same route segment level (#70386) ## Why? Currently, we do not explain why you cannot have a separate static and dynamic slot at the same route segment level. - Fixes https://github.com/vercel/next.js/issues/70366 --------- Co-authored-by:
Zack Tanner <1939140+ztanner@users.noreply.github.com>
-
Steven authored
This PR adds a new feature to the existing `remotePatterns` allowlist configuration, that enables the ability to filter on `search` (aka query string). The most common usage will likely be `search: ''`, which means no query string allowed. You can also set the exact query string such as `search: '?v=1'` which can be useful to invalidate the cache one time for a specific version without opening the door to any version. Note the leading question mark to match the behavior of `new URL(url).search`.
-
Niklas Mischkulnig authored
Chunk each layout/page segment separately to deduplicate work across pages Fixes PACK-3272
-
Sebastian "Sebbie" Silbermann authored
-
Vercel Release Bot authored
-
Sebastian "Sebbie" Silbermann authored
-
hrmny authored
### Why? All the `any` and `unknown` types kept bothering me. I've also removed some unused napi functions
-