### 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).
### What?
A couple of small fixes for the scripts ported from nextpack.
- use ignore globs correctly
- get path for patch after removing other arguments
- display cargo colors
## 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"
}
}
```
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]>
### 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
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`.
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`.
`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
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
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.
### 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]>
## 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