Commit graph

17291 commits

Author SHA1 Message Date
Robert Bradford
17da2ca1fe
docs: Move general info about next.config.* to its index page (#53542)
I was reading through the current https://nextjs.org/docs/app/api-reference/next-config-js/pageExtensions and noticed it started explaining different file formats for the `next.config.*` file. Is that information better suited for the https://nextjs.org/docs/app/api-reference/next-config-js index page?

There was also a little redundancy at the top. 

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-09-03 00:12:47 +00:00
Rousan Ali
d58603fb63
docs: Update Vercel YouTube channel url (#54912) 2023-09-03 00:10:00 +00:00
Tim Neutkens
0f602f4943
Add types for hot reloader send method (#54932)
First part adding additional types for the various events that are sent through the websocket to the browser.

Will add additional details / comments on the types after landing these changes in the browser-side code too.
2023-09-03 00:07:32 +00:00
Fuma
f74f676f73
docs: Clarify the ability to access current route segments in layouts (#53349)
> Layouts do not have access to the current route segment(s). To access route segments, you can use useSelectedLayoutSegment or useSelectedLayoutSegments in a Client Component.

The term "current" is confusing. 
It should be only the route segments under the layout. For example: `app/layout.tsx` can not access `app/[slug]`.
2023-09-02 23:55:18 +00:00
Curtis L
96e13c3bf1
docs: add missing word in client components (#54830)
Missing word in client component page in docs when discussing the effect of "use client" on a client component's children and imported components. Not sure if 'children' is the appropriate word or whether there should be a reference to imported components too.
2023-09-02 23:47:56 +00:00
Florentin / 珞辰
a0beb340ca
docs: add maxDuration in API Routes config (#54844)
Update the code snippet for configuring API Routes to include `maxDuration` as an option.

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-09-02 23:43:11 +00:00
imageck
6c098a74e3
docs: Minor formatting fix in Pages Router SSG (#54915) 2023-09-02 23:34:21 +00:00
Rob Johansen
166f556f69
Fix typo in description of error.js (#54933) 2023-09-02 22:57:49 +00:00
Balázs Orbán
7a871a9424
chore: fix autolabeler (#54916)
### What?

Follow-up of #54824

### Why?

Correctly detect the section to look for while autolabeling. The text currently being searched is not present in the issue body, just the template. Example: #54911 where "App Router" is present but was not detected.
2023-09-02 21:05:10 +00:00
Okoye Charles
53d6da6cc6
fix: Fix grammar issues on README.md (#54921)
In this PR resolved the grammatical error on the [README.md](https://github.com/vercel/next.js/blob/canary/examples/with-passport-and-next-connect/README.md)

Fixes #54919
2023-09-02 15:10:37 +00:00
Justin Ridgewell
2b9ffb009c
Update turbopack (#54909)
Minor update that includes changes necessary to get HMR errors working.

Closes WEB-1494
2023-09-02 10:45:49 +00:00
Will Binns-Smith
125605c307
Debug tracing: time devserver startup (#54537)
This:

- Profiles dev server startup by wrapping most logic in a debug tracing Span
- Sets tracing globals for this case earlier, as they would otherwise be unavailable
- Allows Turbopack traces to be uploaded, as while currently incomplete, they are accurate


Closes WEB-1440

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-09-02 00:34:37 +00:00
Wyatt Johnson
c3d23c6db6
Simplify getPagePaths logic (#54908)
Simplified some logic around `getPagePaths` as well as another normalization function. This instead utilized some flat arrays using push instead of relying on a separate `flatten` method (allowing us to remove it). This also reduced the number of logic checks for this generation.
2023-09-01 23:42:34 +00:00
Tim Neutkens
dab8f1f0d9
Remove leftover parameter on findPagesDir (#54905)
Cleans up more leftover App Router enabled conditions.




Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-09-01 22:46:05 +00:00
Lee Robinson
5eea161d8b
docs: Add docs on CSP and nonce generation (#54601)
There's been some confusion on the correct way to add a `nonce`, so took the opportunity here to:

- Add a new docs page for Content Security Policy
- Explained how to generate a `nonce` with Middleware
- Showed how to consume the `nonce` in a route with `headers`
- Updated the `with-strict-csp` example
- Update the `nonce` error message page
- Backlinked to the new page in a few places in the docs
2023-09-01 22:13:49 +00:00
Will Binns-Smith
03c3c004a1
Turbopack Experimental: Remove use of SourceMapContentSource (#54862)
Depends on https://github.com/vercel/turbo/pull/5852

This removes references to the `source_maps` module from Turbopack as it no longer exists in https://github.com/vercel/turbo/pull/5852

Test Plan:
- Opened a Next.js app with `--turbo-experimental`
- Change a file, verify the page is updated with HMR
- Confirm the source map for the updated file is correctly loaded in DevTools


Closes WEB-1483

Co-authored-by: Justin Ridgewell <112982+jridgewell@users.noreply.github.com>
2023-09-01 22:01:54 +00:00
Mert Can Altın
469c799c00
fix: fixed grammar error in the code comment (#54902)
hello I tried to solve issue #54857
2023-09-01 19:42:54 +00:00
Shu Ding
d94248418a
Add @tremor/react to optimizePackageImports (#54900)
Tested locally.
2023-09-01 19:40:32 +00:00
Zack Tanner
ef33018a3d
fix next/headers when used in src/middleware (#54889)
This updates the check to see if a request is made in middleware to be a bit less brittle so it doesn't break if middleware is located in `/src/middleware` (`params.page` would be `/src/middleware` rather than `/middleware` in that case)

fixes https://github.com/vercel/next.js/discussions/54853
2023-09-01 18:56:51 +00:00
Will Binns-Smith
7e7914c7f8
Turbopack: remove turbo_tasks::unit() from integration tests (#54901)
Closes WEB-1491
2023-09-01 18:06:39 +00:00
Will Binns-Smith
e76cf06f6a
Turbopack: Remove use of turbo_tasks::unit() (#54898)
This is deprecated -- replace it with `Default::default()` as suggested by the deprecation message.


Closes WEB-1490
2023-09-01 17:47:32 +00:00
Balázs Orbán
9adc7910a2
chore: update bug report template (#54824)
### What?

Follow-up of #54724

- Removed/merged some sections
- Added placeholders to hint the user what the input should be
- Reorganized the sections in terms of importance
- Made all sections but one required (we should not ask irrelevant questions to simplify the reporting process)
- Added a small guide on how to pinpoint an exact version of Next.js introducing a bug

### Why?

Clarifying the fact that a missing/invalid reproduction will result in the issue being closed to avoid confusion

[Slack thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1693321920087959)

### How?

Compare the rendered issue templates:
- Before: https://github.com/vercel/next.js/issues/new?assignees=&labels=template%3A+bug&projects=&template=1.bug_report.yml
- After: https://github.com/balazsorban44/next.js/issues/new?assignees=&labels=template%3A+bug&projects=&template=1.bug_report.yml
- Autoclosing still works: https://github.com/balazsorban44/next.js/issues/52
2023-09-01 17:37:17 +00:00
Rui Ying
49a891deb5
Fix the prerender cache update error with the example Dockerfile (#54870)
It seems the app router attempts to write its cache to both `.next/cache` and `.next/server` in docker.

This fix should fix standalone output server's error `Failed to update prerender cache... [Error: EACCES: permission denied...` when deployed in a docker container with the example Dockerfile.

Related discussion: https://github.com/vercel/next.js/discussions/51164
2023-09-01 17:19:13 +00:00
Shu Ding
46d3a7c104
Remove mutation of renderOpts (#54888)
It's a bad pattern to do things like `(renderOpts as any).fetchMetrics = staticGenerationStore.fetchMetrics` and receive the updated value in the outside. This PR updates it to use `RenderResults`'s metadata instead.

In the future we should use `Reaedonly<RenderOpts>` and ban `as any` <picture data-single-emoji=":lolsob:" title=":lolsob:"><img class="emoji" width="20" height="auto" src="https://emoji.slack-edge.com/T0CAQ00TU/lolsob/2e754996aebc14fa.png" alt=":lolsob:" align="absmiddle"></picture>
2023-09-01 16:26:55 +00:00
Zack Tanner
37fda7f2a4
fix hmr test flake (#54890)
This should hopefully fix this test flake by checking the logs only after the page has been rendered & an initial log is received

x-ref: https://github.com/vercel/next.js/actions/runs/6050063024/job/16418585779?pr=54889#step:29:3102
2023-09-01 15:16:22 +00:00
Jiachi Liu
28ef2473af
Fix performance measures crashing the app (#54858)
There're various of cases would cause the `beforeRender` performance mark is not existed in the performance entries, learned from the issues description. We have to check if that mark is existed.

This PR also refactors all the mark names and measurement names into constants so that we won't easily mistype them


Fixes #20743
Fixes #40903
Fixes #47560

Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2023-09-01 14:51:38 +00:00
Bora Öksüzoğlu
f621defc11
Docs: Add changeFrequency and priority attributes to sitemaps (#54863)
https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-09-01 14:36:41 +00:00
Elijah Ohiwerei
7e76c353b3
feat(examples): Migrate 'with-mongoose' example to TypeScript with total type safety (#53603)
### What?
I kindly request the maintainers to review this Pull Request, which aims to migrate the `with-mongoose` example to TypeScript with total type safety.

### Why?
By doing so, we enhance the overall quality and maintainability of the example, aligning it with modern best practices for type-safe codebases.

### How?
I have thoroughly tested the changes to ensure they do not introduce regressions and maintain compatibility with the existing codebase.



Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2023-09-01 14:34:13 +00:00
Justin Ridgewell
5b5dc4f1f3
Turbopack: Trigger Error Overlay in next-api (#54865)
### What?

This hooks up Turbopack's `TurbopackResult` issues into Next's HMR
messages.

### Why?

We need to deliver good error messages to devs so that they can quickly
fix any issues.

### How?

This builds up a debounced HMR queue (necessary because of the Turbopack
architecture delivering multiple messages via different async
iterators). If any HRM message contains an issue, we'll send down a
`built` message containing the issues and delay sending the real
messages. Once everything has been resolved, we'll resume sending down
HMR messages.

<img width="990" alt="Screenshot 2023-08-31 at 9 01 20 PM"
src="https://github.com/vercel/next.js/assets/112982/d5421779-2415-4a60-8d95-94f0e1147d6d">

Closes WEB-1484

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-09-01 16:05:22 +02:00
Donny/강동윤
a5c180388a
Update swc_core to v0.82.11 (#54653)
### What?

Update swc crates to
44de87f481

### Why?

To use `import with` and etc...

### How?

Closes WEB-1460
Fixes #

---

Turbopack counterpart: https://github.com/vercel/turbo/pull/5820

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-09-01 15:35:04 +02:00
Michael Novotny
e2584c6fb3
Updates minimum node version in documentation (#54839)
Updates minimum node version in documentation as we've changed what we require since written.

DX-2046
2023-09-01 04:02:24 +00:00
Will Binns-Smith
58f1d238c4
Turbopack: Log build progress in development like webpack does (#54806)
This adds logging to indicate build progress while using Turbopack in the same format that webpack uses. It uses the same store object and sets state to log messages like so:

```
- wait compiling /page (client and server)...
- event compiled client and server successfully in 1366 ms
```

Given:

- An app router page `/`, `compiling /page` is logged
- An app router page `/bar`, `compiling /bar/page` is logged
- An app router route `/api/bar`, `compiling /api/bar/route` is logged
- A page router page `/foo`, `compiling /foo` is logged
- A page router api route `/api/foo`, `compiling /api/foo` is logged


Closes WEB-1476
2023-09-01 00:18:24 +00:00
vercel-release-bot
d172e7b72c v13.4.20-canary.15 2023-08-31 22:23:23 +00:00
JJ Kasper
2eef775472
Update tag handling for app cache (#53321)
Optimizes how we handle cache tags for soft tags (auto-added by Next.js)
and normal tags (added manually) and adds differentiating between
`revalidatePath('/blog/first')` and page/layout.

Soft tags are not stored across cache entry and instead auto sent along
when checking cache entries. This allows us to prevent storing
exponential amounts of tags across cache entries while still having the
relationship between them so that single path revalidation can work
properly.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1690586837903309)
2023-08-31 15:17:40 -07:00
Jonathan Steele
acbbf14a49
example: Add elements.update() to ensure latest payment amount is reflected (#54848)
### What?
In the Payment Element demo, call
[`elements.update()`](https://stripe.com/docs/js/elements_object/update)
when the payment amount value is updated via slider. This ensures
wallets (Apple Pay, Google Pay) display the correct payment amount.

---------

Co-authored-by: Michael Novotny <manovotny@gmail.com>
2023-08-31 15:53:41 -05:00
Will Binns-Smith
1fc4b22dd3
Don't send tracing spans if performance.measure doesn't return measurements (#54808)
Fixes #54389.

Old versions of Safari appear to return `undefined` from `performance.measure()` instead of `PerformanceMeasure` values.


Closes WEB-1477
2023-08-31 19:19:42 +00:00
Leah
cc77579589
fix(turbopack): edge api entry path should not have /route suffix (#54851)
### Description

Lookup is done by the page name, which does not include the `route` suffix

Closes WEB-1481
2023-08-31 18:36:59 +00:00
vercel-release-bot
e1cc97f3e4 v13.4.20-canary.14 2023-08-31 17:24:11 +00:00
Jiachi Liu
1be02e36fe
Update @vercel/og to latest (#54849)
Upgrade `@vercel/og` to `0.5.12` and satori to the corresponding version
2023-08-31 17:17:07 +00:00
Zack Tanner
f0fa7c5406
use pnpm for next-with-deps (#54847)
This fixes the "Usage Error: This project is configured to use pnpm" error when running `next-with-deps` since we [enforce a package manager](https://github.com/vercel/next.js/blob/canary/package.json#L252)
2023-08-31 16:12:38 +00:00
Dima Voytenko
826ef8c715
Allow any number of onFetch handlers for a single test (#54846)
Recent usability testing indicated that it's convenient to register multiple `onFetch` handlers and iterate them until one of them response a result.
2023-08-31 15:58:53 +00:00
Mayank
7b54e954c2
update dependencies (#53334)
### 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

### What?
Updated dependencies to latest for Sentry example.

### Why?
Remove tech debt
2023-08-31 15:47:14 +00:00
Balázs Orbán
7fe1ea50c1
chore: update triaging docs (#54828)
### What?

Follow-up of #54724 and #54826 

### Why?

To correctly reflect how we triage issues

[Slack thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1693321920087959)
2023-08-31 15:38:08 +00:00
Balázs Orbán
c2b3ed953e
chore: label invalid issues (#54826)
### What?

Follow-up of #54724

### Why?

Marking auto-closed issues so we can easily filter them.

[Slack thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1693321920087959)
2023-08-31 15:03:29 +00:00
Sadaf
ac56bcafa7
docs: define router instance in code block (#54707)
…g scroll
2023-08-31 03:21:46 +00:00
Aryan Malik
4f0b7156a4
docs: Add JS/TS code switchers to Middleware (#54726)
In case a user needs a `js` code
2023-08-31 03:19:21 +00:00
Xvezda
44509f690a
docs: fix syntax error in i18n example code block (#54749)
Added missing comma to fix syntax error in i18n configuration example.
2023-08-31 03:16:55 +00:00
Justin Ridgewell
9d7f54c11b
Fix the build manifest path for / (#54744)
### What?

Fixes a bug introduced in #54668, where the `/` path would map to the build manifest `.next/server/page/app-build-manifest.json` in App router instead of the correct `.next/server/index/page/app-build-manifest.json`
It also addresses an issue where `not-found` manifests would map to `.next/server/not-found/app-build-manifest.json` instead of the correct `.next/server/not-found/page/app-build-manifest.json`.

### Why?

The `&& type === 'pages'` mean we only rewrote `/` to `/index` in Pages router, where it needs to apply to both App and Pages. Likewise, special-casing `not-found` led to it not finding the manifest.

### How?

Duplicate the logic from d3a107991c/packages/next-swc/crates/next-core/src/util.rs (L65-L76)

Closes WEB-1471


Co-authored-by: Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
2023-08-31 03:14:25 +00:00
vercel-release-bot
fe191f8e54 v13.4.20-canary.13 2023-08-31 01:53:14 +00:00
Justin Ridgewell
8b4bb031ba
Fixes for Turbopack HMR (#54790)
### What?

There were a few issues with the initial implementation of next-api HMR:
1. We incorrectly errored out when we received a Next.js WebSocket message
2. We didn't handle Next's `span-end` message, leading to another error
3. We listened to the `htmlEndpoint` change events instead of the `dataEndpoint`/`rscEndpoint`, leading to us detecting client-side changes and causing full page reloads

### Why?

HMR is the life-blood of development

### How?

Small fixes to our Turbopack reimplementation of the server-side HRM handlers

Closes WEB-1475
2023-08-30 21:14:46 +00:00