Commit Graph

91 Commits

Author SHA1 Message Date
Tobias Koppers e44c5f192c ci: check that Turbopack compiles for wasm (#97588)
### What?

Adds a CI job that checks Turbopack compiles for
`wasm32-wasip1-threads`, so wasm portability
regressions are caught rather than rediscovered.

### Why?

Everything under `#[cfg(target_family = "wasm")]` is invisible to host
builds **and** to host clippy —
it is only checked when you deliberately build for the target. Four
separate defects in this stack were
caught only that way (a wrong build-script condition, two bad imports,
and a value that compiled but was
wrong). Without a gate, the next one lands unnoticed.

This also re-enables coverage that had been off for ~2 years: the old
`test-next-napi-bindings-wasi` job
was disabled with `if: false` pending napi-rs/napi-rs#2009, which closed
in April 2024.

### How?

Modelled on `rust-check` via `build_reusable.yml` (`needsRust`,
`skipInstallBuild`, `skipNativeBuild`),
so it does not pay for a JS build. Beyond `rustup target add` it needs
two things:

- **a WASI C toolchain**, because `lzzzz` (LZ4, via `turbo-persistence`)
and `zstd-sys` have C build
scripts. The SDK build is selected from `$RUNNER_ARCH` —
`build_reusable.yml` defaults to an arm64
runner, and an x86_64 clang fails there with `Exec format error` — with
a pinned sha256 per arch,
  unpacked under `$RUNNER_TEMP` so the workspace stays clean.
- **emnapi**, because `next-napi-bindings`' build script calls
`napi_build::setup()`, whose wasi path
panics without `EMNAPI_LINK_DIR` — so it is required even for `cargo
check`. It is installed into a
scratch directory rather than the root `package.json`, because this job
runs with `skipInstallBuild`
  and therefore never runs `pnpm install`.

Two things worth recording, both of which cost a CI round trip to find:

- pnpm is invoked from the repo root with `--dir`, not by `cd`-ing into
the scratch directory: corepack
resolves the pnpm version from the nearest `package.json`, and outside
the repo it picks the latest
  pnpm (11.x), which cannot run on the pinned Node 20
  (`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`).
- the job is added to `tests-pass`, whose `needs:` list is what actually
blocks a PR — a job that runs
but is absent from that list looks like coverage while blocking nothing.

The `emnapi@2.0.0-alpha.4` pin is deliberate and is the one fragility
here: the archive must define
`emnapi_create_env` / `emnapi_delete_env`, which exists only in emnapi
v2, still a prerelease. Move to
the stable release once it ships.


<!-- fleet b6d0486f-97c7-42a7-bdaf-3490774cdec3 -->

Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2026-09-09 10:25:45 +02:00
Hendrik Liebau c11c0942f2 [test] Run deploy tests against local JavaScript changes by default (#98353)
Deploy tests now use the checkout's built JavaScript packages when
`NEXT_TEST_VERSION` is unset. The harness reuses the isolated-test
packer, includes the tarballs in the deployment source, and installs
them through relative `file:` references.

The previous published-build workflow remains available through
`NEXT_TEST_VERSION`. For example, `NEXT_TEST_VERSION=canary` skips local
packing and tests the published canary. Exact versions and CI preview
tarball URLs remain supported. Existing CI deploy jobs already set
`NEXT_TEST_VERSION`, so their package selection does not change. The
harness skips local package preparation when it reuses an existing
deployment or invokes a custom deploy script, preserving those
workflows.

Staged monorepo peer dependencies use matching local versions so npm
accepts prerelease builds without conflicting direct-package overrides.
Fixture overrides retain their nested rules, including qualified
identity overrides with or without an explicit `.` entry. Configuration
updates preserve linked source files.

Deployments of local JavaScript packages use published SWC binaries
matching the local Next.js version. They do not include locally built
native binaries because those may target a different platform.

**Verification**

```
VERCEL_TURBOPACK_TEST_TEAM=vtest314-next-turbo-e2e-tests \
  pnpm test-deploy-turbo test/e2e/app-dir/third-parties/basic.test.ts
```

```
VERCEL_TEST_TEAM=vtest314-next-turbo-e2e-tests \
  pnpm test-deploy-webpack test/e2e/app-dir/third-parties/basic.test.ts
```

Both deploy modes passed. Additional temporary checks, removed
afterward, verified that:

- Deployments install the local JavaScript packages and use matching
local versions for monorepo peers.
- Qualified npm overrides preserve a nested `sharp@0.34.5` pin, both
with and without an explicit `.` entry. The check resolved `sharp` from
Next's own dependency context.
- Archive preparation leaves checkout manifests and tarballs unchanged.
Repacked archives preserve other package files, permissions, links, and
external peer declarations.
2026-09-08 18:49:13 +02:00
Joseph 67eede2b8d docs: fix stale Dev Overlay README link in contributing guide (#97486)
In #80281 we moved the README from
`../../packages/next/src/client/components/react-dev-overlay/README.md`
to `packages/next/src/next-devtools/README.md`, but did not update the
link in the contributing guide.
2026-08-18 11:53:49 +02:00
Marcos Hernanz 7a5d2f9f32 Allow issue participants to request reopening (#96947)
## Summary

- Let issue authors and people who commented before closure reopen an
issue within 14 days using `Reopen: <reason>`.
- Limit the automation to unlocked issues closed by triage-or-higher
human maintainers, with ordered timeline checks, bot filtering,
idempotency, and state revalidation.
- Align resolved-issue and contributor guidance with the new reopening
window.

## Verification

- `Prettier 3.6.2 --check .github/workflows/issue_reopen.yml
.github/comments/resolved.md contributing/repository/triaging.md`
- Mocked workflow harness covering 19 closure, eligibility, boundary,
bot, idempotency, and race scenarios
- `autoreview --mode local --stream-engine-output` (Codex and Claude
clean)
- Live GitHub API spot-check for ordered same-second `commented` and
`closed` timeline events
- Not run: live issue close/reopen smoke test (issue-triggered workflows
run only from the default branch)
2026-08-12 15:34:54 -07:00
Benjamin Woodruff 0cfc85ceae Clarify AI-assisted contribution policy in PR template and AGENTS.md (#95629)
## Summary

Documents the policy around AI-assisted contributions, for both humans
and agents:

- `.github/pull_request_template.md`: notes that AI use is encouraged
for researching, creating, and reviewing changes, but contributors must
deeply understand their contributions, and PR descriptions from external
contributors must be written by a human.
- `.github/ISSUE_TEMPLATE/1.bug_report.yml`: adds the equivalent note
for bug reports — issue descriptions from external contributors must be
written by a human, though AI may help create reproductions.
- `AGENTS.md`: replaces the old "PR Descriptions" section with two new
sections. "GitHub Pull Requests" distinguishes branch PRs (agents may
write descriptions) from fork PRs targeting `vercel/next.js` (agents may
not). "GitHub Issues, Comments, and Discussions" restricts agent-written
issues, discussions, and comments to members of the
`vercel`/`vercel-labs` GitHub orgs, tells agents how to check membership
via the GitHub API, lists what agents can still help non-members with
(drafting details, reviewing, reproductions, translation, searching for
duplicates), and carves out exceptions (commenting on the user's own PR,
Vercel-operated bots, GitHub/Graphite review bots, and forks of the
repo).
- Renames the LLM watermark marker from `NEXT_JS_LLM_PR` to
`NEXT_JS_LLM` everywhere it appears (`AGENTS.md`,
`contributing/repository/pull-request-descriptions.md`, and the
`create-pr`/`backport-pr` skills), since it now also applies to issues,
discussions, and comments. Nothing in the repo consumes the old marker
name.
- `.agents/skills/create-pr/SKILL.md`: adds a "Fork PRs vs Branch PRs"
section referencing the `AGENTS.md` policy. Assorted typo fixes along
the way.

## Verification

- `gh api /user/memberships/orgs` and `gh api
orgs/vercel/members/<login>` (confirmed the documented membership checks
work and return the documented statuses)
- Not run: no test/build commands (docs-only change; prettier applied
via the pre-commit hook)

<!-- NEXT_JS_LLM -->
2026-07-10 11:27:52 -07:00
Luke Sandberg a7b04690e6 gitignore .next-profiles (#95256)
### What?

When profiling is enabled (`--experimental-cpu-prof` /
`--internal-trace`, or the `NEXT_CPU_PROF` / `NEXT_TURBOPACK_TRACING`
env vars), Next.js writes a `.gitignore` containing `*` into
`.next-profiles/` as it creates the directory. This keeps the profiling
output out of git and out of the way of tools that scan the project
tree.

### Why?

`.next-profiles` is a sibling of `.next`, so it's intentionally *not*
covered by the `.gitignore` create-next-app ships. The motivation was
that profiles wouldn't bloat `.next` and wouldn't be silently ignored.
But a sibling dir full of large profile/trace files turns out to be a
liability:

- **Ecosystem tools scan it.** Tailwind v4 aggressively auto-scans files
and has opened a `trace-turbopack.bin` and crashed; Turborepo <2.8.13
hashes the file and OOMs, and >=2.8.13 fails to start `dev` watchers
because reading the large trace is too slow. (workflow watchers are
likely affected too.)
- **Turbopack NFT globbing** can read/hash the file via overly broad
`fs.read` patterns.
- **Accidental commits.** Pushing a multi-GB trace would be miserable
for a customer helping us debug.

These have each gotten point bandaids (#94587, #94570), but the real fix
preserves the original motivation: a nested `.gitignore` with `*` keeps
the files off git **and** makes gitignore-respecting tools (Tailwind,
Turborepo) skip the whole subtree, which resolves the scanning failures.
Reverting to `.next/profiles` was the alternative; the gitignore
approach keeps the existing path.

### How?

- `ensureProfilesDir()` (`packages/next/src/lib/profiles-dir.ts`)
creates `.next-profiles` and writes the `.gitignore` (only if absent, so
user edits survive). Single source of truth.
- `bin/next.ts` calls a `setupProfilesDir()` helper on build/dev/start,
gated on the env vars so both the CLI flags and direct env-var usage are
covered. Skipped when `NEXT_TURBOPACK_TRACING_PATH` redirects trace
output.
- Rust keeps `create_dir_all` as a backstop for the trace dir; the
`.gitignore` is written in JS only.
- Docs switched from `NEXT_TURBOPACK_TRACING=1` to `next dev
--internal-trace`, and the stale `trace-turbopack` filename corrected to
`trace-turbopack.bin`.

<!-- NEXT_JS_LLM_PR -->
2026-07-01 15:51:33 +00:00
Sebastian "Sebbie" Silbermann 618957c166 [cd] More robust publish pipeline (#94622) 2026-06-17 19:44:59 +02:00
Razin Shafayet d8426d0d04 docs: correct wording and casing in turbopack tracing guide (#94469)
Fixed two missing words and inconsistent capitalization in
`contributing/turbopack/tracing.md`:

- "And there different value modes" → "And there `are` different value
modes"
- "more information how to create one" → "more information `on` how to
create one"
- "Persistently `allocated` Memory" → "Persistently `Allocated` Memory"
2026-06-05 10:12:53 +02:00
Razin Shafayet 5334931662 docs: fix typos in testing.md (#94446)
Fixed two typos in `contributing/core/testing.md`:
- `sett` → `setting` (`Consider also setting NEXT_E2E_TEST_TIMEOUT=0`)
- `again` → `against` (`run a test against both Turbopack and Webpack`)
2026-06-04 09:48:24 +02:00
Tim Neutkens dd0cae63e0 Align issue triage guidance with automated behavior (#94189)
### What?

- Align the public triage guide with the issue workflows current
response windows and confirmed-team labels.
- Update reproduction and canary response comments to describe automatic
closure separately from the later lock workflow.

### Why?

The documented triage contract had drifted from the active automation:
the guide described 30-day response windows and unsupported triage
labeling, while automated comments implied that timed closure
immediately locks issues. This sets inaccurate expectations for
reporters and maintainers.

### How?

Update the four Markdown surfaces that explain manual triage and
automated follow-up behavior to match the existing stale and lock
workflows.

### Verification

- `pnpm prettier --with-node-modules --ignore-path .prettierignore
--check contributing/repository/triaging.md
.github/comments/invalid-reproduction.md
.github/comments/simplify-reproduction.md
.github/comments/verify-canary.md`
- `git diff --cached --check`
- Not run: `pnpm --filter=next build` (`documentation and GitHub comment
text only; no framework source changes`)

<!-- NEXT_JS_LLM_PR -->
2026-05-28 13:24:18 +02:00
Tim Neutkens cdd77ac4f3 Add deployable tarballs to pack-next (#93963)
### What?

Adds a `--deployable-tar` option to `pack-next` that writes generated
tarballs into the target project and patches package references to use
relative `file:` paths.

### Why?

Projects that need to deploy with locally packed Next.js packages should
be able to include those tarballs inside the project directory instead
of referencing tarballs from the Next.js checkout.

### How?

Resolves the target project package.json location, writes tarballs to a
sibling `tarballs/` directory, and maps package override paths to
project-relative references when patching package.json. Existing `--tar`
behavior continues to write to the repository tarballs directory.

### Verification

- `git diff --check`
- `git diff --cached --check`
- `pnpm prettier --with-node-modules --ignore-path .prettierignore
--write scripts/pack-next.ts scripts/pack-utils/patch-package-json.ts
contributing/core/testing.md contributing/core/developing.md`
- `npx eslint --config eslint.config.mjs --fix scripts/pack-next.ts
scripts/pack-utils/patch-package-json.ts contributing/core/testing.md
contributing/core/developing.md` (Markdown files were ignored because no
matching ESLint config was supplied)
- `pnpm pack-next --project ../sandbox/nextjs-duplicated-html-repro/
--deployable-tar`

<!-- NEXT_JS_LLM_PR -->
2026-05-20 08:00:56 -07:00
Tim Neutkens 7da98e1318 Convert more tests from createNext -> nextTestSetup (#93799)
## What?

Converts more tests that use `createNext` to `nextTestSetup`

Follow-up to #93767

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-18 09:51:36 +02:00
Tim Neutkens c5596dd4e0 Turbopack: Write trace file to .next-profiles (#92189)
## What?

Builds on #92078. Also writes the Turbopack trace to the same
.next-profiles directory.
2026-04-08 16:50:17 +02:00
Zack Tanner 7777dadcff docs: add deploy tests documentation to contributing guide (#92388)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## What?

Adds documentation to the contributing guide explaining how deploy tests
work and how to run them.

## Why?

Deploy tests are an important part of the Next.js CI pipeline that
verify the framework works correctly when deployed to Vercel. However,
there was no documentation explaining:
- How deploy tests are triggered on PRs
- How to run deploy tests locally

This came up in a Slack discussion where team members were debugging
deploy test failures and sharing knowledge about how to trigger and run
these tests.

## How?

Added a new "Deploy Tests" section to `contributing/core/testing.md`
that explains:

1. **Triggering Deploy Tests on PRs**: Deploy tests don't run on every
PR by default. To trigger them, you can modify a test file in the deploy
test suite, which causes CI to run deploy tests for that file.

2. **Running Deploy Tests Locally**: You can run deploy tests locally
using:
- `NEXT_TEST_VERSION` to test against a specific commit's pre-built
tarball
- `NEXT_TEST_DEPLOY_URL` to skip the deploy step and test against an
existing deployment

<!-- NEXT_JS_LLM_PR -->
<!-- CURSOR_AGENT_PR_BODY_END -->

[Slack
Thread](https://vercel.slack.com/archives/C04KC8A53T7/p1775265710012189?thread_ts=1775265710.012189&cid=C04KC8A53T7)

<div><a
href="https://cursor.com/agents/bc-014a1052-4dfe-5db4-931d-86efa411016e"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-014a1052-4dfe-5db4-931d-86efa411016e"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-04-05 14:58:02 -07:00
Benjamin Woodruff 124c4000ab docs: Ask AI agents to self-identify themselves in PR descriptions (#92235)
This is inspired by
https://glama.ai/blog/2026-03-19-open-source-has-a-bot-problem#user-content-how-are-these-agents-setup

If agents follow this pattern, we could potentially add labels (this PR
does not touch the labeler) to these PRs which may help with review and
triage. This does not change how we'd deal with these PRs (AI generated
PRs are okay!), but I would like to know if a PR is AI generated when
reviewing it.
2026-04-03 18:55:42 -07:00
Benjamin Woodruff 68dade4679 Turbopack: Remove old macos-compress script (#90967)
@wbinnssmith added these scripts a long time ago at my suggestion/urging, but I think they ended up bad for a couple reasons that were hard to foresee at the time:

- afsctool operates in-place and doesn't atomically write the compressed file, so if the process gets interrupted, your `target` directory is corrupted. https://github.com/Dr-Emann/applesauce is better for this reason.
- This doesn't acquire the cargo lock, and modifying files while cargo is running is a good way to get corruption of the `target` directory.

https://github.com/bgw/cargo-apfs-compress is my latest attempt at solving this, though I don't have a `LaunchAgents` config for it.  
  
Regarding `node_modules`: pnpm creates reflinks from a shared global store on apfs. Trying to compress these reflinked files is just going to hurt you because it'll break the data deduplication that would've otherwise happened.
2026-03-14 01:25:49 +01:00
Benjamin Woodruff ae6406afdd docs(turbopack): Copy over turbopack-trace-server docs (#91111)
**Rendered:** https://github.com/vercel/next.js/blob/dd1cc6fba3cff5fbc38dac3ff4426b481bfcbcb5/contributing/turbopack/tracing.md

This is the content from https://turbopack-rust-docs.vercel.sh/tracing_turbopack.html with some minor updates:

- Use GitHub Flavored Markdown for the warning block
- Some grammar fixes/tweaks
- Add an extra note about `--release` being important
- Add a mention of `pnpm next internal trace`
- Add a link to @timneutkens's youtube video
- Change the filepath from the old confusingly named `.next/trace.log` to `.next/trace-turbopack`
- Add a link to https://trace.nextjs.org/
2026-03-09 16:04:07 -07:00
Benjamin Woodruff 15d9b71744 docs(contributing): Update setup in contributing/core/developing.md (#91018)
A lot of stuff here was slightly out-of-date or not as helpful as it could be.

For the Linux bits, I tested with a fresh Ubuntu image in LXD.
2026-03-09 14:49:39 -07:00
Hendrik Liebau e9b96b4128 Build with dev runtimes when --debug-prerender is set (#89834)
When running `next build --debug-prerender`, React owner stacks are now
captured and displayed in prerender error output. This makes it much
easier to diagnose which component triggered uncached I/O or accessed
request data without Suspense. Previously, `--debug-prerender` only
enabled source maps and disabled minification. Now it also auto-enables
`allowDevelopmentBuild` and sets `NODE_ENV=development`, which loads
React development builds where `captureOwnerStack()` is available.

The main challenge is that with `NODE_ENV=development`, both server and
client bundles include dev-only code paths (HMR, WebSocket connections,
dev overlay, debug channel, etc.) that expect a running dev server. We
don't want these when using `next start`. To solve this, we introduce
`process.env.__NEXT_DEV_SERVER`, an internal env var that is truthy only
during `next dev`. In client bundles, it's inlined at build time (`'1'`
for `next dev`, `''` for `next build`). In production server runtime
bundles, it's inlined as `''` for dead-code elimination. In development
server runtime bundles, it's left as a runtime check because those
bundles are shared between `next dev` (where it's set) and `next build
--debug-prerender` (where it's not). Meanwhile, `NODE_ENV` continues to
control React's dev/prod mode and error formatting, which is exactly
what we want for `--debug-prerender`.

This also replaces the previous `renderOpts.dev` / `workStore.dev`
pattern, which was unreliable because `RouteModule.isDev` was derived
from `NODE_ENV` at compile time. When `allowDevelopmentBuild` set
`NODE_ENV=development`, `isDev` would be compiled as `true` and
incorrectly activate all dev guards during `next start`.

Key changes:

- `config.ts` auto-enables `allowDevelopmentBuild` and sets
`NODE_ENV=development` when `--debug-prerender` is active
- `define-env.ts` inlines `__NEXT_DEV_SERVER` into all bundles (truthy
for dev, falsy for build) so dev-server features are dead-code
eliminated in production and `--debug-prerender` builds
- `next-dev.ts` and `next.ts` set `__NEXT_DEV_SERVER` in the process
environment for externalized server-side code
- `renderOpts.dev` and `workStore.dev` are removed — all consumers now
use `__NEXT_DEV_SERVER` (for dev-server features) or `NODE_ENV` (for
error formatting that should work in both dev and `--debug-prerender`
builds)
- `patch-error-inspect.ts` devirtualizes React server URLs in source map
URLs so they display as readable file paths
2026-02-13 16:29:10 +01:00
Zack Tanner 6138452203 [test]: add ability to run test-deploy with pre-existing deployment (#88829)
When digging into failing deployment tests, I often will re-run the test
itself without wanting to change anything about Next.js or the test
application, especially when I suspect a logic bug in the test itself or
need to figure out what's causing a flake.

This adds an environment variable that can be used to skip the
build/deploy step and will use an existing deployment URL to run the
tests against.

I suggest reviewing this [without
whitespace](https://github.com/vercel/next.js/pull/88829/changes?w=1).
2026-01-20 14:40:49 -08:00
Luke Sandberg a51a2e4c26 [turbopack] Support traversing the graph in reverse order (#86427)
This makes certain aggregations trivial since we are are guaranteed to only traverse relevant edges.

Use it to fix a bug in the async module identification logic.  Previously we would aggregate async cycles after propagating 'asyncness' through the DFS post order traversal, but this could cause us to fail to propagate async to all reverse dependencies depending on which part of a cycle a node would happen to visit first.

By traversing starting from the async modules we just need to mark everything we find and not worry about cycles at all since the underlying DFS mechanism will ensure we don't loop.  In addition to only requiring a single pass, this is guaranteed to visit fewer nodes in that single pass.

One caveat is that reverse traversals only work within a single `SingleModuleGraph` so a debug assert was added to prevent misuse

Closes #85988
Closes #86391
Closes PACK-5806
2025-11-29 09:51:54 -08:00
Sebastian "Sebbie" Silbermann 3b4e4478d4 Use ESLint Flat Config (#84800) 2025-10-13 10:43:51 +02:00
Sebastian "Sebbie" Silbermann 00436856f1 Add link to manually trigger preview builds (#81977) 2025-07-24 07:40:08 +02:00
Sebastian "Sebbie" Silbermann ea1a76a601 Update script location used in pnpm unpack-next (#79626) 2025-05-28 19:10:22 +02:00
Janka Uryga cb49b483f1 Reland "Ensure mangling is disabled for dev runtime builds (#75297)" (#79201)
Reapplies #75297

Also fixes some rspack tests which didn't await assertions properly so they might have looked like they're passing
2025-05-14 17:38:01 +02:00
Tim Neutkens 6e51845ac4 Rename process.env.TURBOPACK to process.env.IS_TURBOPACK_TEST for tests (#77892)
Preparation for removing `process.env.TURBOPACK` being added to
Turbopack tests. That way we can properly test `next start` without
`process.env.TURBOPACK` being set.

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

-->
2025-04-07 14:07:55 +02:00
Will Binns-Smith a6375148dc Refactor build scripts and rewrite pack-next in TypeScript (#77536)
Written with @bgw.

- Transitions to using `tsx` for script execution
- Replaces `patch-package` with TypeScript implementation
- Implements argument parsing and help message with `yargs`
- Uses `execa` for some command execution

Test Plan: Run `pnpm pack-next`, `pnpm swc-build-wasm`, `pnpm unpack-next`, and `pnpm sweep` without errors.
2025-03-28 16:24:32 -07:00
Sam Ko 0aa0ef676d chore(github): remove /examples from contribution guidelines, remove examples issue template (#77050)
## Why?

Start the prep-work for removing/moving [Next.js examples](https://github.com/vercel/next.js/tree/canary/examples).

Today, a lot of these examples already have their own dedicated location in their respective GitHub orgs.

These examples are also now present in other locations.

- https://github.com/nextjs
- https://v0.dev/chat/community
- https://vercel.com/templates/next.js
2025-03-12 15:32:29 -07:00
Jiwon Choi b84bd5221b [dev-overlay] docs: add readme (#76396)
This PR added the README for the dev overlay for future contributors.

[**View
Preview**](https://github.com/vercel/next.js/blob/9136b280a3e194b81c1ea9e4aa7236eeb895a843/packages/next/src/client/components/react-dev-overlay/README.md)

Closes NDX-656

---------

Co-authored-by: Lee Robinson <lee@leerob.com>
2025-02-24 02:55:56 +09:00
Jiwon Choi 71e139d288 docs: update building.md to contain descriptive build process (#76393) 2025-02-23 09:08:34 -06:00
JJ Kasper 0be280dc79 Revert changing bundler for runtime bundle but keep externals fix (#75412)
This reverts the bundler change part while we investigate source map
issue but keeps the externals optimize preventing the runtime bundle
from inflating back to over `4MB`.

This reverts commit 98b0700e97
This reverts commit 04c3f0b29c
2025-01-29 16:50:31 +00:00
JJ Kasper 98b0700e97 Ensure mangling is disabled for dev runtime builds (#75297)
Just ensures we keep mangling behavior prior to
https://github.com/vercel/next.js/pull/75294

---------

Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
2025-01-25 00:34:44 +00:00
Jam Balaya 36dce2fe7e examples: add StackBlitz preview to README.md (#73546)
### Description

Follow up #35349.

1. Update the [example
template](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
with [StackBlitz](https://stackblitz.com/) preview
2. Add `preview live with StackBlitz` to the examples
3. Remove the below old StackBlitz preview section from the examples

```md
## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/active-class-name)
```

CC: @samcx 

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
2025-01-14 05:24:51 +00:00
Sebastian "Sebbie" Silbermann e72dc52be5 Create Jest project for Turbopack (#73769) 2024-12-17 17:25:28 +01:00
Jam Balaya 0a3dd36585 docs: add the link of ESLint example to guideline (#73491)
## Summary

Add
[`with-eslint`](https://github.com/vercel/next.js/tree/canary/examples/with-eslint)
example link to
[adding-examples.md](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
for convenience.

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide
2024-12-09 04:08:50 +00:00
Jude Gao 05c101b9d8 Retire replay-io (#73282)
We had this wired up a long time ago but disabled it since it wasn't
helping much. So cleaning it up now.
2024-12-02 17:49:15 -05:00
루밀LuMir 920b4e9c28 docs: add missing punctuation in developing-using-local-app.md (#73163)
### Improving Documentation

Hello, I’ve added missing punctuation and an inline code block.

The `package.json` file has an inline code block on line 42, but the one
in the heading was missing.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-12-02 22:21:08 +00:00
Sebastian "Sebbie" Silbermann 2a603e7123 Include debug script in test directories (#72992)
I commonly add a `debug` script that allows me to attach a debugger when running Next.js in the isolated test dirs. 

Now we always add it and make it work just like `debug` from the monorepo. So after the test you can `cd` into the created test directory and run `pnpm debug dev`. `debug` is just an alias for `next` with some additional configurations:
- tracing deprecations
- no telemetry
- no canary checks
- debugger attachable
- source maps

`debug` also ensures the SWC version that was used during the test is used. Previously it used the cached version which isn't necessarily the one built in this specific worktree.
2024-11-20 13:09:44 +01:00
Benjamin Woodruff 7e9e18b147 docs(turbopack): Document build dependency on clang for rocksdb (#72493)
Noticed this after rebuilding on top of #71688 

Most Linux distributions default to `gcc` for their default `cc`
implementation (e.g. via Debian's `build-essential` meta-package, which
we can probably implicitly assume is installed), which means that they
won't typically have `clang` installed.

`librocksdb-sys` seems to always depend on `clang` on Linux. It looks
like this might be a consequence of using
[rust-bindgen](https://github.com/rust-lang/rust-bindgen) (though I'm
confused why this didn't come up earlier), as it looks like rocksdb can
otherwise build with gcc.

This shouldn't be an issue for macos, since `clang` is the default `cc`
on that platform.
2024-11-18 15:40:27 +01:00
マルコメ d0b33429d3 docs: change pages to app router links (#71782)
## Description
Some links navigate pages docs.
Then update app router ones.

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-10-29 18:58:25 +00:00
マルコメ fddd022e1b docs: fix broken link of new comments path (#71674)
# Summary
Add missing comments path to which #61416 changed.

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-10-29 11:54:28 -07:00
Benjamin Woodruff 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
hrmny 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 Woodruff 1eb5944b3c Switch from ld (the default linker) to using lld for GNU Linux targets (#65898)
Copies changes from https://github.com/vercel/turbo/pull/8166, and
updates contributing documentation to include the installation of lld.

> **What's wrong with `ld`?** It's very slow and uses a lot of memory.
>
> **Why `lld`?** It's fast, mature, and well-supported. Meta and Google
use it for all their linking workloads. We're already using it for macos
and x86-64 Windows. There is [ongoing work to make it the default for
rustc](https://github.com/rust-lang/rust/issues/71515), and it already
is default on a few platforms.
>
> **Why not `mold`?** Mold is generally faster, but the margin is slim
enough for our workloads that it doesn't really matter. Mold only
recently got support for LTO, doesn't support v0 rust symbol demanging,
doesn't support BOLT (though we don't use that yet), etc. Mold is
maturing quickly, but `lld` still seems like the "safer" choice.
2024-08-05 17:30:35 -07:00
Will Binns-Smith 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
Hendrik Liebau bda92a1be5 Fix VS Code debugging (#66254)
~Due to the entry preloading that was enabled by default in #65289, VS
Code is no longer able to map symbols correctly for production builds.
As a temporary solution, we can disable the preloading when a debugger
is started until a proper fix is found.~

By optionally building the Next.js source code with
`NEXT_SERVER_EVAL_SOURCE_MAPS=1` we can ensure, even with the bundled
next server in the node runtime, that the original names are shown in
the debug "Variables" section.

In addition, the `sourceMapPathOverrides` are improved to cover the
different variations of source mapping URLs. We can now also set
breakpoints in the `example/...` and `test/e2e/...` server components.

~Supersedes #66229~

#### Before

<img width="1276" alt="Screenshot 2024-05-27 at 21 36 52"
src="https://github.com/vercel/next.js/assets/761683/f2840c35-f683-445d-bc95-cac9f719d8e7">

#### After

<img width="1276" alt="Screenshot 2024-05-27 at 21 38 42"
src="https://github.com/vercel/next.js/assets/761683/c801c123-3163-46c3-b442-5b72c0a5d51d">
2024-07-05 16:04:35 +02:00
Sebastian Silbermann f49506703e Improve docs for preview builds (#67422)
Builds can now be addressed by PR number.
2024-07-05 13:12:41 +02:00
Sebastian Silbermann f1488d5d68 Persist package tarballs as GitHub Actions artifacts (#66445) 2024-07-02 15:18:45 +00:00
Jiwon Choi cf71687d69 chore: add swc-build-native script at root package.json (#67345)
When developing in Next.js repo, the maintainers / contributors
sometimes need to build swc native files.

Added a script `swc-build-native` to run the command `pnpm
--filter=@next/swc build-native` which was verbose to run.
2024-07-01 23:10:07 +09:00
Balázs Orbán 90b80faa6f chore: rename 'example bug' label to 'examples' (#64775) 2024-04-19 12:39:44 +02:00