Commit Graph
266 Commits
Author SHA1 Message Date
Benjamin WoodruffandGitHub 882d88381c build(pack-next): Add an option for the pack-next script to automate patching package.json (#69396)
## What is `pack-next`?

This is a script we use for developing turbopack. It builds tarballs for
all the next.js packages, including `next-swc`, and then provides
instructions about how to modify a project's `package.json` to install
from that tarball.

## What does this PR do?

If you provide a `--project ~/path/to/directory` argument to `pnpm
pack-next`, we'll auto-update the `package.json` there for you, instead
of telling you how to do it manually!

This also understands the React 19 RC peer dependencies, which is
something that was missing from the generated instructions.

## Supported Package Managers

I've tested this with `npm` and `pnpm`.
- `bun` fails with `ENOTDIR` for unknown reasons (maybe it's trying to
handle the local tarball as a directory instead of a tarball?).
- `yarn` fails due to an upstream issue:
https://github.com/yarnpkg/yarn/issues/6339

This does generate the entries for yarn's `resolutions` feature,
assuming the upstream issue is eventually fixed.

## Why Rust and `cargo xtask`?

https://github.com/matklad/cargo-xtask

I'd love for these Turbopack-centric scripts to be written in Rust with
xtask, since they're mostly touched by the turbopack team.

However, it's also hard to justify putting too much effort into these
development scripts, so I don't want to rewrite the whole thing right
now.

I figured I'd write the new functionality in Rust and call it from the
old JS script.

## Test Plan

Perform a fresh checkout of shadcn/ui, and then:

```
pnpm pack-next --project ~/shadcn-ui/apps/www/
```

```
Found workspace! Patching "/home/bgw.linux/shadcn-ui/package.json" with overrides.
Successfully patched "/home/bgw.linux/shadcn-ui/package.json" to use local tarball files!
Run `pnpm i` or `npm i` to install the overrides
```

Check the resulting changes to `~/shadcn-ui`:

```diff
diff --git a/package.json b/package.json
index be47ad7..262c13b 100644
--- a/package.json
+++ b/package.json
@@ -63,12 +63,31 @@
     "tsx": "^4.1.4",
     "turbo": "^1.9.9",
     "vite-tsconfig-paths": "^4.2.0",
-    "vitest": "^0.31.1"
+    "vitest": "^0.31.1",
+    "@next/swc": "file:/home/bgw.linux/next.js/tarballs/next-swc.tar"
   },
   "devDependencies": {
     "@types/node": "^20.11.27",
     "@types/react": "^18.2.65",
     "@types/react-dom": "^18.2.22",
     "typescript": "^5.5.3"
+  },
+  "overrides": {
+    "next": "file:/home/bgw.linux/next.js/tarballs/next.tar",
+    "@next/mdx": "file:/home/bgw.linux/next.js/tarballs/next-mdx.tar",
+    "@next/env": "file:/home/bgw.linux/next.js/tarballs/next-env.tar",
+    "@next/bundle-analyzer": "file:/home/bgw.linux/next.js/tarballs/next-bundle-analyzer.tar",
+    "@next/swc": "file:/home/bgw.linux/next.js/tarballs/next-swc.tar",
+    "react": "19.0.0-rc-7771d3a7-20240827",
+    "react-dom": "19.0.0-rc-7771d3a7-20240827"
+  },
+  "resolutions": {
+    "next": "file:/home/bgw.linux/next.js/tarballs/next.tar",
+    "@next/mdx": "file:/home/bgw.linux/next.js/tarballs/next-mdx.tar",
+    "@next/env": "file:/home/bgw.linux/next.js/tarballs/next-env.tar",
+    "@next/bundle-analyzer": "file:/home/bgw.linux/next.js/tarballs/next-bundle-analyzer.tar",
+    "@next/swc": "file:/home/bgw.linux/next.js/tarballs/next-swc.tar",
+    "react": "19.0.0-rc-7771d3a7-20240827",
+    "react-dom": "19.0.0-rc-7771d3a7-20240827"
   }
 }
```
2024-08-29 10:25:34 -07:00
Sebastian "Sebbie" SilbermannandGitHub 1e493fc8e7 Create React sync automatically (#69314)
Closes NDX-245
2024-08-28 17:33:57 +02:00
Sebastian "Sebbie" SilbermannandGitHub 53cf8e2651 sync-react: Fix --version and --no-install being ignored (#69317) 2024-08-27 10:01:31 +02:00
Sebastian "Sebbie" SilbermannandGitHub bb60a00f5c sync-react: Remove redundant work (#69199) 2024-08-23 02:53:10 +02:00
Sebastian "Sebbie" SilbermannandGitHub 3c7af4f96b sync-react: Print to console what should go into PR description (#69195) 2024-08-23 01:39:34 +02:00
Sebastian "Sebbie" SilbermannandGitHub 0fc762c7e3 sync-react: Automatically update all references to the React peer dependency version (#69194) 2024-08-23 00:20:10 +02:00
Tobias KoppersandGitHub 226bd00692 [Turbopack] fix build-native script (#68822)
### What?

fixes `pnpm pack-next --release`
2024-08-13 15:36:45 +02:00
1948f5b4ba fix(create-next-app): link to app dir docs in next-env.d.ts in app dir templates (#68534)
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 <[email protected]>
2024-08-09 22:21:28 +00:00
Sebastian SilbermannandGitHub 3cfce00bad Improve error message when preview builds were not found in deploy tests (#68589) 2024-08-09 10:57:01 +02:00
hrmnyandGitHub 114c29513e chore: port more nextpack scripts (#68586)
### 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
2024-08-07 18:55:20 +00:00
Benjamin WoodruffandGitHub b113937a8a [turbopack] Replace uses of globby in scripts with glob (#68493)
Replace uses of `globby` (which is not in the `package.json`) with
`glob` (which is in the `package.json`).

These scripts were part of the nextpack repository (RIP), and
@wbinnssmith copied them over in #68471

Tested by running `pnpm pack-next`, inspecting the `tarballs` directory,
installing the tarballs into shadcn-ui, and building with turbopack.

`globby` and `glob` share the same API, but Next.js pulls in a pretty
old version of `glob`, so some of the newer APIs don't exist, and it
doesn't natively use promises:
https://github.com/isaacs/node-glob/tree/v7.1.6

We could upgrade `glob` without too much pain... It's only used for
`devDependencies`.
2024-08-05 20:17:39 -04:00
Will Binns-SmithandGitHub c90e03d9d3 Add pack/unpack scripts from nextpack (#68471)
This brings over the utility scripts `pnpm pack-next` and `pnpm
unpack-next path/to/app` from Nextpack, along with the documentation,
which has been added to `contributing/core/developing.md`.
2024-08-02 16:01:32 -07:00
Jiwon ChoiandGitHub b159d60fd6 HOTFIX: pages doc next-config-js was moved from 03 to 04 (#68370)
### Why?

`types-and-precompiled` is failing on CI: 

https://github.com/vercel/next.js/actions/runs/10186089792/job/28178038314

### How?

The script `validate-externals-doc.js` was validating the
`docs/.../03-next-config-js/...mdx` page, but the page was moved to
`docs/.../04-next-config-js/...mdx` in
https://github.com/vercel/next.js/pull/67839
2024-07-31 21:36:52 +02:00
Sebastian SilbermannandGitHub c28b2d25b5 Ensure sync-react updates pnpm overrides (#68329) 2024-07-30 18:53:18 +02:00
Sam KoandGitHub 3fbffe1d1e chore: bump pnpm to 9.6.0 (#68044)
## Why?

- More support for [catalogs](https://pnpm.io/catalogs) (read
[changelog](https://github.com/pnpm/pnpm/releases) for more info).
- Successful
[build-and-deploy](https://github.com/vercel/next.js/actions/runs/10127840891)
run
2024-07-28 04:18:36 -07:00
Sebastian SilbermannandGitHub 0dfcdea234 Label React syncs in GitHub with type: react-sync (#67710) 2024-07-22 20:02:20 +02:00
hrmnyandGitHub cad3a51049 refactor: move rust crates to the repo root directory (#67780)
### Why?
In preparation for moving all turbopack crates

Also makes them easier to work with in general.

Closes PACK-3164
2024-07-22 18:41:27 +02:00
Sebastian SilbermannandGitHub bee02f9a8d Exclude changes that already landed in canary when finding changed tests (#64218) 2024-07-15 22:47:41 +00:00
Zack TannerandGitHub 9b6f713b26 pages router: ensure x-middleware-cache is respected (#67734)
`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
2024-07-13 10:48:38 -07:00
Zack TannerandGitHub 720641ada8 remove leftover code from 'related' deploy tests (#67644)
This wasn't in use anymore and is superseded by
https://github.com/vercel/next.js/pull/67612
2024-07-11 06:47:01 -07:00
16cc5fab2f style: simplify string formatting (#66772)
Co-authored-by: Jiwon Choi <[email protected]>
2024-07-11 09:54:14 +00:00
Zack TannerandGitHub 49377880b1 run changed/added tests in deploy mode (#67612)
Leverages the work from https://github.com/vercel/next.js/pull/66445 to
download artifacts for a particular commit SHA, so that it can be passed
to the `test-deploy` script.

This will let us run deploy tests on PRs, ensuring that they're run from
the Next.js on the target branch rather than `canary`.

This waits until `test-new-tests-dev` and `test-new-tests-start`
complete for 2 reasons:
- No reason to waste deploy resources if the changed/added tests don't
even work in dev/start
- It gives time for deploy-tarball to finish

Sample run:
https://github.com/vercel/next.js/actions/runs/9865244781/job/27241944533?pr=67612#step:28:54
2024-07-10 06:58:58 -07:00
Zack TannerandGitHub 02c02a4707 split out flake detection from utility to detect changed tests (#67611)
This splits out the existing logic for detecting changed/added tests
into a separate util, so it can be leveraged by #67612.

No changes in functionality, aside from replacing informational logs
with `console.log` rather than `console.error` and a tweak to arg
parsing.
2024-07-10 06:40:44 -07:00
a123983994 fix: add whitespace before seconds in trace-to-tree output (#67593)
### What?
Adds a whitespace character before seconds output of
`scripts/trace-to-tree.mjs`

### Why?
I was regexing a big output, looking for sources of slowness and failed
to do so because `\ss` would not find anything, whist `\sms` would,
because it printed whitespace before `ms` but not before `s`.

Co-authored-by: JJ Kasper <[email protected]>
2024-07-10 03:43:52 +09:00
Sam KoandGitHub 2a43b5153c chore: bump pnpm to 9.5.0 (#67555)
## Why?

Upgrading to [9.5.0](https://github.com/pnpm/pnpm/releases/tag/v9.5.0)
allows us to start using [catalogs](https://pnpm.io/catalogs).
2024-07-08 05:13:17 -07:00
Sebastian SilbermannandGitHub f1488d5d68 Persist package tarballs as GitHub Actions artifacts (#66445) 2024-07-02 15:18:45 +00:00
JJ KasperandGitHub 2fceb5b1aa Fix test-new-tests args parsing (#67308)
Noticed we weren't detecting test mode correctly due to incorrect args
parsing so this fixes that

x-ref:
https://github.com/vercel/next.js/actions/runs/9725297814/job/26842454638?pr=67306#step:28:69
2024-07-01 07:27:16 -07:00
Sam KoandGitHub e6983b911b chore: update pnpm to 9.4.0 (#64945)
## Why?

Notable change of v9 is Corepack is enabled by default.  
So we can ensure all package manage/resolved exact same version of pnpm.

- [**v9.0.0**](https://github.com/pnpm/pnpm/releases/tag/v9.0.0):
Discontinued support for Node.js v16 and introduced Corepack
compatibility checks. New configuration updates include enabling
`dedupe-injected-deps` and changing the lockfile to version 9, with
better readability and resistance to Git conflicts.

...

- [**v9.4.0**](https://github.com/pnpm/pnpm/releases/tag/v9.4.0)

- Kudos to @ryota-murakami for the original :pr:! →
https://github.com/vercel/next.js/pull/64854

## Changes

- https://pnpm.io/npmrc#link-workspace-packages defaults to `false` now,
so setting it to `true`

Closes NEXT-3211
2024-06-28 04:41:35 -07:00
Zack TannerandGitHub f7d5e14863 add more examples to run-for-change script (#67250)
These examples are tested, so this ensures tests are run when these
examples change to prevent #67249
2024-06-27 19:51:06 +02:00
JJ KasperandGitHub 42f6dc3d9c Add concurrency for flakey tests detection (#67019)
This ensures we parallelize our flakey test detection since when a lot
are changed it can hit the timeout and not be able to run them all.
2024-06-19 07:01:24 -07:00
Will Binns-SmithandGitHub f30e5dbb29 Run and report benchmarks (#66851)
Using `@vercel/devlow-bench`, this benchmarks changes landed on canary
and reports results to Datadog.
2024-06-18 11:11:15 -07:00
Sam KoandGitHub e296846427 chore: bump turbo to 2.0.3 (#66784)
## Why?

This pull request bumps turborepo from 1.13.3-canary.2 to
[2.0.3](https://github.com/vercel/turbo/releases/tag/v2.0.3) across
multiple GitHub workflows and configuration files.

Re-attempting after we
[reverted](https://github.com/vercel/next.js/pull/66775).
2024-06-12 19:31:42 +00:00
JJ KasperandGitHub d22da49b49 Revert "chore: bump turbo to 2.0.3" (#66775)
Seems the latest turbo version is causing issues with our rust
compilation so reverting for now

Reverts vercel/next.js#66762
2024-06-11 18:17:06 -07:00
Sam KoandGitHub 561dcf6c43 chore: bump turbo to 2.0.3 (#66762)
## Why?

This pull request bumps turborepo from 1.13.3-canary.2 to
[2.0.3](https://github.com/vercel/turbo/releases/tag/v2.0.3) across
multiple GitHub workflows and configuration files.
2024-06-11 22:28:01 +00:00
JJ KasperandGitHub 46d3066c98 Log stdio for pull-turbo-cache script (#66759)
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
2024-06-11 10:30:56 -07:00
Sebastian SilbermannandGitHub b6a45eba45 Fix sync-react changelog (#66532) 2024-06-05 18:57:33 +02:00
Sebastian SilbermannandGitHub 3445a562aa Add hint that sync-react doesn't automate everything (#66531) 2024-06-05 16:50:32 +00:00
JJ KasperandGitHub 913bf03af0 Handle premajor version for canary (#66336)
Ensures we can cut premajors for canary the same as release-candidate
tags.
2024-05-29 08:26:51 -07:00
JJ Kasper f6db3b79b1 add missing -y to start-release 2024-05-23 08:09:29 -07:00
JJ Kasper 11c19cfbf6 Fix validate externals docs 2024-05-23 06:56:52 -07:00
JJ KasperandGitHub 188b37d11d Add release candidate handling to start release (#66107)
This adds support for a new `rc` publish tag to our start release
workflow.
2024-05-22 23:52:56 -05:00
Sebastian SilbermannandGitHub f7c5480b1c React sync: Handle React PRs landed via ghstack (#66069) 2024-05-22 23:59:29 +02:00
Sebastian SilbermannandGitHub fa42f0dba7 React sync: Reduce manual tasks (#66095) 2024-05-22 23:49:56 +02:00
Sebastian SilbermannandGitHub a25e7d2fe9 Update React from 04b058868c to 81c5ff2e04 (#65869) 2024-05-22 14:46:57 +02:00
Sebastian SilbermannandGitHub 99f59438c3 Improve sync-react changelog generator (#66051) 2024-05-21 21:10:08 +00:00
Sebastian SilbermannandGitHub e7065a951c Include base commit in changes included by a React sync (#65868)
Include the base commit in the generated changelog for React syncs.
2024-05-21 11:16:22 +02:00
Tim NeutkensandGitHub aae77765e1 Fix send-trace-to-jaeger boolean span values (#65920)
Jaeger does not support booleans as span values and will throw an error.
This ensures the boolean values are turned into strings.

<!-- 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 #

-->
2024-05-18 18:46:24 +02:00
hrmnyandGitHub 64b718c661 chore: update prettier to 3.2.5 (#65092) 2024-05-08 21:47:14 +02:00
Ethan ArrowoodandGitHub d0d22ac625 Promote and rename server bundling options serverComponentsExternalPackages and bundlePagesExternals (#65421)
This PR promotes and renames experimental configuration options related
to server bundling:
- `serverComponentsExternalPackages` -> `serverExternalPackages`
- `bundlePagesExternals` -> `bundlePagesRouterDependencies`

Existing docs for `serverComponentsExternalPackages` was changed. 
New docs for `bundlePagesRouterDependencies` were added.

Closes NEXT-3332
2024-05-07 11:19:35 -06:00
2c31c79ac8 Support React 19 in App and Pages router (#65058)
Closes NEXT-3218

---------

Co-authored-by: Jiachi Liu <[email protected]>
2024-05-07 18:18:32 +02:00