Commit graph

5224 commits

Author SHA1 Message Date
Tim Neutkens
b2a2e6e550
Revert "Update Turbopack test manifest" (#62534)
Reverts vercel/next.js#62476

Closes NEXT-2595
2024-02-26 12:27:30 +01:00
Tobias Koppers
d9b2a4baea
update turbopack (#62523)
* https://github.com/vercel/turbo/pull/7437 <!-- Tobias Koppers - report
relative start/end and fix start time for events -->
* https://github.com/vercel/turbo/pull/7446 <!-- Tobias Koppers - allow
to aggregate all spans -->
* https://github.com/vercel/turbo/pull/6651 <!-- max -
fix(postcss_configs): support for resolve `postcss.config.json` file -->
* https://github.com/vercel/turbo/pull/7448 <!-- Leah - chore: remove
"rust" npm package -->
* https://github.com/vercel/turbo/pull/7436 <!-- Leah -
refactor(turbo-tasks-fs): move file watching into separate file -->
* https://github.com/vercel/turbo/pull/7396 <!-- Donny/강동윤 -
feat(turbopack): Apply critical ES lint rules -->
* https://github.com/vercel/turbo/pull/7421 <!-- Donny/강동윤 -
fix(turbopack): Use different title for non-parsing issues -->
* https://github.com/vercel/turbo/pull/7501 <!-- Tobias Koppers -
Tracing: Report progress on initial read -->
* https://github.com/vercel/turbo/pull/7508 <!-- Donny/강동윤 -
fix(turbopack): Fix CSS Modules of turbopack in swc mode -->
* https://github.com/vercel/turbo/pull/7424 <!-- Donny/강동윤 -
fix(turbopack): Analyze for-of stmts to allow using `sharp` -->
* https://github.com/vercel/turbo/pull/7510 <!-- Tobias Koppers - dedupe
primary_modules to avoid deduping in chunking, reduce memory usage -->
* https://github.com/vercel/turbo/pull/7509 <!-- Tobias Koppers - split
graph_node_to_referenced_nodes into cacheable and non-cacheable parts
-->
* https://github.com/vercel/turbo/pull/7516 <!-- Tobias Koppers - fix
ignore in package.json -->
* https://github.com/vercel/turbo/pull/7500 <!-- Tobias Koppers - add
span count to trace-server -->
* https://github.com/vercel/turbo/pull/7507 <!-- Donny/강동윤 -
fix(turbopack): Fix CSS module purity validator -->
2024-02-26 11:19:31 +01:00
Vercel Release Bot
222a773d56
Update Turbopack test manifest (#62476)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-02-26 10:04:45 +01:00
Will Binns-Smith
b4231c0318
Turbopack: skip tests for import trace links (#61831)
Some tests in `test/development/acceptance-app/editor-links.test.ts`
test that links in the import trace can be clicked. This is currently
deprioritized with Turbopack, so skip them.


Closes PACK-2450
2024-02-23 13:07:57 +01:00
Jiachi Liu
e5d604f33b
Upgrade vendored react (#62326)
### React upstream changes

- https://github.com/facebook/react/pull/28333
- https://github.com/facebook/react/pull/28334
- https://github.com/facebook/react/pull/28378
- https://github.com/facebook/react/pull/28377
- https://github.com/facebook/react/pull/28376
- https://github.com/facebook/react/pull/28338
- https://github.com/facebook/react/pull/28331
- https://github.com/facebook/react/pull/28336
- https://github.com/facebook/react/pull/28320
- https://github.com/facebook/react/pull/28317
- https://github.com/facebook/react/pull/28375
- https://github.com/facebook/react/pull/28367
- https://github.com/facebook/react/pull/28380
- https://github.com/facebook/react/pull/28368
- https://github.com/facebook/react/pull/28343
- https://github.com/facebook/react/pull/28355
- https://github.com/facebook/react/pull/28374
- https://github.com/facebook/react/pull/28362
- https://github.com/facebook/react/pull/28344
- https://github.com/facebook/react/pull/28339
- https://github.com/facebook/react/pull/28353
- https://github.com/facebook/react/pull/28346
- https://github.com/facebook/react/pull/25790
- https://github.com/facebook/react/pull/28352
- https://github.com/facebook/react/pull/28326
- https://github.com/facebook/react/pull/27688
- https://github.com/facebook/react/pull/28329
- https://github.com/facebook/react/pull/28332
- https://github.com/facebook/react/pull/28340
- https://github.com/facebook/react/pull/28327
- https://github.com/facebook/react/pull/28325
- https://github.com/facebook/react/pull/28324
- https://github.com/facebook/react/pull/28309
- https://github.com/facebook/react/pull/28310
- https://github.com/facebook/react/pull/28307
- https://github.com/facebook/react/pull/28306
- https://github.com/facebook/react/pull/28315
- https://github.com/facebook/react/pull/28318
- https://github.com/facebook/react/pull/28226
- https://github.com/facebook/react/pull/28308
- https://github.com/facebook/react/pull/27563
- https://github.com/facebook/react/pull/28297
- https://github.com/facebook/react/pull/28286
- https://github.com/facebook/react/pull/28284
- https://github.com/facebook/react/pull/28275
- https://github.com/facebook/react/pull/28145
- https://github.com/facebook/react/pull/28301
- https://github.com/facebook/react/pull/28224
- https://github.com/facebook/react/pull/28152
- https://github.com/facebook/react/pull/28296
- https://github.com/facebook/react/pull/28294
- https://github.com/facebook/react/pull/28279
- https://github.com/facebook/react/pull/28273
- https://github.com/facebook/react/pull/28269
- https://github.com/facebook/react/pull/28376
- https://github.com/facebook/react/pull/28338
- https://github.com/facebook/react/pull/28331
- https://github.com/facebook/react/pull/28336
- https://github.com/facebook/react/pull/28320
- https://github.com/facebook/react/pull/28317
- https://github.com/facebook/react/pull/28375
- https://github.com/facebook/react/pull/28367
- https://github.com/facebook/react/pull/28380
- https://github.com/facebook/react/pull/28368
- https://github.com/facebook/react/pull/28343
- https://github.com/facebook/react/pull/28355
- https://github.com/facebook/react/pull/28374
- https://github.com/facebook/react/pull/28362
- https://github.com/facebook/react/pull/28344
- https://github.com/facebook/react/pull/28339
- https://github.com/facebook/react/pull/28353
- https://github.com/facebook/react/pull/28346
- https://github.com/facebook/react/pull/25790
- https://github.com/facebook/react/pull/28352
- https://github.com/facebook/react/pull/28326
- https://github.com/facebook/react/pull/27688
- https://github.com/facebook/react/pull/28329
- https://github.com/facebook/react/pull/28332
- https://github.com/facebook/react/pull/28340
- https://github.com/facebook/react/pull/28327
- https://github.com/facebook/react/pull/28325
- https://github.com/facebook/react/pull/28324
- https://github.com/facebook/react/pull/28309
- https://github.com/facebook/react/pull/28310
- https://github.com/facebook/react/pull/28307
- https://github.com/facebook/react/pull/28306
- https://github.com/facebook/react/pull/28315
- https://github.com/facebook/react/pull/28318
- https://github.com/facebook/react/pull/28226
- https://github.com/facebook/react/pull/28308
- https://github.com/facebook/react/pull/27563
- https://github.com/facebook/react/pull/28297
- https://github.com/facebook/react/pull/28286
- https://github.com/facebook/react/pull/28284
- https://github.com/facebook/react/pull/28275
- https://github.com/facebook/react/pull/28145
- https://github.com/facebook/react/pull/28301
- https://github.com/facebook/react/pull/28224
- https://github.com/facebook/react/pull/28152
- https://github.com/facebook/react/pull/28296
- https://github.com/facebook/react/pull/28294
- https://github.com/facebook/react/pull/28279
- https://github.com/facebook/react/pull/28273
- https://github.com/facebook/react/pull/28269

Closes NEXT-2542


Disable ppr test for strict mode for now, @acdlite will check it and
we'll sync again
2024-02-23 12:46:58 +01:00
Shu Ding
b0c6b00643
Fix module-level Server Action creation with closure-closed values (#62437)
With Server Actions, a module-level encryption can happen when you do:

```js
function wrapAction(value) {
  return async function () {
    'use server'
    console.log(value)
  }
}

const action = wrapAction('some-module-level-encryption-value')
```

...as that action will be created when requiring this module, and it
contains an encrypted argument from its closure (`value`). This
currently throws an error during build:

```
Error: Missing manifest for Server Actions. This is a bug in Next.js
    at d (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/chunks/1772.js:1:15202)
    at f (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/chunks/1772.js:1:16917)
    at 714 (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:2806)
    at t (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/webpack-runtime.js:1:127)
    at 7940 (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:941)
    at t (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/webpack-runtime.js:1:127)
    at r (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:4529)
    at /Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:4572
    at t.X (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/webpack-runtime.js:1:1181)
    at /Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:4542
```

Because during module require phase, the encryption logic can't run as
it doesn't have Server/Client references available yet (which are set
during the rendering phase).

Since both references are global singletons to the server and are
already loaded early, this fix makes sure that they're registered via
`setReferenceManifestsSingleton` before requiring the module.

Closes NEXT-2579
2024-02-23 12:00:24 +01:00
Vercel Release Bot
301dd70ac7
Update Turbopack test manifest (#62433)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-02-23 10:27:49 +01:00
Will Binns-Smith
749e3c4e85
Turbopack react-refresh: perform full reload on runtime error (#62359)
Previously, runtime errors would not be recovered from. Like the webpack
implementation, this addresses the issue by performing a full page
reload when recovering from a runtime error.

Test Plan: `test/development/acceptance-app/error-recovery.test.ts --
Error recovery app default stuck error`


Closes PACK-2569
2024-02-22 17:15:36 -08:00
Dima Voytenko
2451af931c
OTEL: Add top span for middleware (#62421)
Without this, any spans added by the middleware implementation would be
orphaned and create extra traces.
2024-02-23 01:08:29 +00:00
Zack Tanner
93eb32d96a
Remove default fallback behavior when route group is missing a default (#62370)
This test case was added in #59752, but this doesn't seem like the
correct behavior.

The original PR was intended to be smart about resolving `/default.tsx`
to a route group default (e.g. `/(foo)/default.tsx`) when one wasn't
specified. But since the route group is creating a new hierarchy in the
tree and defines its own layout, if the route group layout doesn't
specify a default, then the not found behavior seems correct.

To fix unexpected not-found behavior in this case, you should specify a
default at the same level as the layout where the missing slot(s) might
be rendered.

Closes NEXT-2565
2024-02-22 16:13:50 +01:00
Vercel Release Bot
669f8f3407
Update Turbopack test manifest (#62389)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-02-22 10:35:16 +01:00
Zack Tanner
7b5951827f
Fix test flake (#62379)
This onClick isn't actually being used by the test and seems to be
causing a flake unrelated to the test assertions. This removes the
unused code for now so we can still keep the relevant part of the test
in-tact. (Specifically, this test is asserting that we're using the
correct prefetch cache entry for interception routes that originate from
different trees but resolve to the same URL)

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

-->


Closes NEXT-2568
2024-02-22 00:19:49 -08:00
Tobias Koppers
4545f3e7f1
scope issues from subscriptions to the websocket connection (#62344)
### What?

* scope issues from subscriptions to the websocket connection
* close subscriptions when closing the websocket connection

### Why?

* subscriptions on one page should not affect other pages

### How?



Closes PACK-2567
2024-02-22 08:55:31 +01:00
JJ Kasper
40bc285d21
Update data cache max size error (#62348)
Makes the error message more specific to Next.js and provides specific
size that exceeded the limit.

x-ref: [slack
thread](https://vercel.slack.com/archives/C05U6TZ2DCP/p1708543103375799)

Closes NEXT-2559
2024-02-21 22:03:20 +00:00
Tobias Koppers
e7ff4c02e5
avoid loading the page loader chunk on initial page load (#62269)
### What?

* unnecessary request
* removes a race condition with script loading



Closes PACK-2544
2024-02-21 21:49:49 +01:00
Jiachi Liu
5f635de51f
Revert "Ensure webpack build worker defaults on" (#62342)
Reverts vercel/next.js#62214

Enabling build worker by default breaks some mdx rendering pages with
`next build`
x-ref: https://vercel.slack.com/archives/C04DUD7EB1B/p1708543258307169
2024-02-21 12:00:18 -08:00
JJ Kasper
f994d409c2
Revert "Revert "Update split chunk handling for edge/node" (#62313)" (#62336)
This re-lands the chunking optimization with fix for the split chunks
config to ensure we aren't generating duplicate chunks from not chunking
`all` together.

Tested various configs against our repro case here:

https://vercel.com/vercel/vercel-site/2D5Xirs9Vr1M29WHAuNawgjvgE4G
https://vercel.com/vercel/vercel-site/B2aez1NNCyVvoUBTSMFy8npBKK3j

Closes NEXT-2552
closes: https://github.com/vercel/next.js/issues/51298
x-ref: https://github.com/vercel/next.js/pull/62313
2024-02-21 11:40:29 -08:00
Balázs Orbán
a1b20470c6
feat(error-overlay): hide <unknown>/stringify methods in <anonymous> file from stack (#62325)
### What?

Clean up the error overlay:

<details>
<summary><b>Before:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/22c3ab2c-8445-4c25-8554-a5ab51100af4"/>
</details>

<details>
<summary><b>After:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/403c30fc-8b27-4529-838c-47d9cbe52381"/></details>


I also simplified the current code as it was likely using `useMemo` a
bit eagerly.

### Why?

This is an unactionable line by the user, no value in showing it in the
overlay.

### How?

Filter out the frame before rendering it in the overlay.

This answers [this
question](https://github.com/vercel/next.js/pull/62206#issuecomment-1956636486)
too, since the module grouping is local. Now that `<anonymous>` is
filtered out, the two Next.js groups are now merged into one, further
cleaning up the stack.

Closes NEXT-2505
2024-02-21 16:58:22 +01:00
Balázs Orbán
2a9a7a2cbe
fix(error-overlay): correct module grouping, hide useless frames (#62206)
### What?

While working on hiding useless frames, I also noticed that we regressed
on #44137, meaning it was totally ignored. I haven't tracked down at
which point this happened but made it work again in the same PR.

This should significantly clear up the shown error stack in the error
overlay:

<details>
<summary><b>Before:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/1833abfe-7c0b-4a34-bad8-735799f1cf42"/>
<img
src="https://github.com/vercel/next.js/assets/18369201/70ecc124-1241-4df9-adfe-7f0c8f47d6d3"/>
</details>


<details>
<summary><b>After:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/d0395320-c52c-47a0-a281-f7721410f4da"/>
</details>

### Why?

Some frames in the error stack are useless/unactionable to the user and
make it harder to parse the error. This PR filters out some of them, to
make the stack more readable.

### How?

The stack traces are run through a `.filter()` before being displayed.


Closes NEXT-2505
Closes NEXT-2522
2024-02-21 13:07:40 +00:00
JJ Kasper
fc0f94f8c0
Revert "Update split chunk handling for edge/node" (#62313)
We have a reproduction of OOMs still occurring with this chunking so
going to revert while we investigate further

x-ref:
https://github.com/vercel/next.js/issues/51298#issuecomment-1953004425

Reverts vercel/next.js#62205

Closes NEXT-2548
2024-02-21 11:57:08 +01:00
Vercel Release Bot
0b9d635555
Update Turbopack test manifest (#62314)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-02-21 10:48:24 +00:00
Tim Neutkens
2f961d39ed
Move scss tests into individual directories (#62277)
## What?

Further simplifying the way the tests are created for Sass so that they
can be moved into `test/e2e` in a follow-up PR.


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

-->


Closes NEXT-2537
2024-02-21 09:49:12 +01:00
Sam Ko
745b1b59b2
fix(next-font): update capsize css so fallbacks are updated with the … (#62309)
## Description
We need to manually update the `@capsizecss/metrics` every time it
updates so we get the latest fallback fonts.

## Changes
- https://github.com/vercel/next.js/issues/47115

Closes NEXT-2547
2024-02-20 22:04:56 -08:00
OJ Kwon
6f87054c76
fix(next-core): properly normalize app route for _ (#62307)
### What

This PR amends turbopack's behavior to handle some cases of normalized
path (`%5F` starting path), mainly fixes entry lookup works against
original path without normalization, also bends the output path of
client reference manifest matchs to what next.js expects.

Closes PACK-2553
2024-02-20 21:11:40 -08:00
JJ Kasper
6feb803f78
Add otel span for client component loading (#62296)
This adds a new span to allow tracking the sum of all client component
loading times for a specific request along with the count of items
loaded.

Closes NEXT-2540

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-02-20 13:27:16 -08:00
Tim Neutkens
5be8135982
Move scss tests into test/integration/scss directory (#62276)
## What?

Groups together the scss tests. I'm working on refactoring these to use
`test/e2e` instead as many tests currently only run during builds and we
want to make sure these Sass tests run for Turbopack (which is dev only
currently) to catch bugs.

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

-->


Closes NEXT-2536
2024-02-20 20:30:49 +01:00
OJ Kwon
dd4b52e77e
fix(next-core): fix aliased free var for edge runtime (#62289)
### What?

Matches global free var alias to what webpack does (to the native
instead of polyfill)


Closes PACK-2550
2024-02-20 10:11:34 -08:00
Zack Tanner
d371f648d2
Renew prefetch cache entry after update from server (#61573)
### What
When a prefetch cache entry becomes "stale", it'll remain stale until
eventually it gets evicted. However during that stale window, the cache
is never revalidated, and so instant navigations stop working and data
is fetched from origin every navigation.

### Why
The `lastUsedTime` entry on the prefetch cache is currently only updated
after the first read. Once it becomes stale, `applyFlightData`'s
recursive functions will see that there is no longer a reusable prefetch
cache entry, and will trigger a lazy fetch of the new data on every
subsequent navigation.

### How
This updates prefetch cache handling to always ensure we’re using a
fresh or reusable prefetch cache entry. This means that stale prefetch
entries will be refreshed on a navigation event. As a result of this,
I’ve had to disable one of our tests that relies on this stale cache
behavior. It’s not ideal that we’re blocked on the loading boundary when
fetching child segment data—ideally we can refactor this to cache the
loading component in the CacheNode and copy it over on navigations,
similar to how ‘head’ is handled. I’ll work on this in a separate PR.

Note: The new client cache test for this is disabled in PPR for the same
reason as the other tests: auto prefetching with PPR navigations is
currently loading fresh data rather than reusing the prefetch cache.


Fixes #58969
Fixes #58723
Closes NEXT-1904
2024-02-20 09:07:18 -08:00
Jiachi Liu
d7d636adf5
Tree shake the unused exports in direct relative imported client component module (#62238)
### What & Why

This PR helps fixes a long time tree-shaking issue that if you're import
some identifiers from client components, the whole client component is
being included in the client chunk. Because we're using import eager
mode in webpack to include all the client component modules that make
sure they're present in SSR entry and browser entry when they're
transformed to client reference on RSC layer.

But the way we collect client components is a bit "aggressive" where
contains some spaces to optimize.

### How

We change the collected client components from simpliy collecting it
resolved module request, into collecting both the imported identifiers
(by server components) and the module request. And when we inserted the
used client components imports into the SSR and Client entry, leverage
webpack magic comments `"webpackExports"` to only contain the used
exports in the bundle. Thank you webpack for this nice feature : )

Along the way we also fixed an issue that when you only used default
export, the `default` export itself should also be proxied when the
bundle is in ESM.

#### Notice

There's a limitation yet that it can't work with barrel file, if you
have a shared component `index.js` to re-export the changes several
client components there and you only partially import few from
`index.js` it won't work. For the cases that the node_modules package
contain a barrel file importing multiple client components, please use
[optimizePackageImports](https://nextjs.org/docs/app/api-reference/next-config-js/optimizePackageImports)
config for now. We'll have follow up optimizations

### Testing Result

If we compare the `react-aria-components` the reproduction from #60246,
you'll see the result being optimized a lot:

#### After vs Before

134KB being tree-shaked out 🤯 
```
Route (app)                              Size     First Load JS
┌ ○ /                                    324 B           127 kB
├ ○ /_not-found                          872 B          86.5 kB
└ ○ /other-page                          174 B           127 kB
```

```
Route (app)                              Size     First Load JS
┌ ○ /                                    325 B           261 kB
├ ○ /_not-found                          870 B          86.5 kB
└ ○ /other-page                          176 B           261 kB
```

Fixes #60246
Related report: https://github.com/adobe/react-spectrum/issues/5639
Closes NEXT-2527
phase 1 of NEXT-1799

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-02-20 17:07:25 +01:00
Kuzey Kose
09c0065c3d
fix(create-next-app): add --no-import-alias for non-interactive (#62035)
### What?

The [create-next-app
documentation](https://nextjs.org/docs/app/api-reference/create-next-app#non-interactive)
under API reference says that;

> Further, you can negate default options by prefixing them with --no-
(e.g., --no-eslint).

When I tried to use --no-import-alias, I thought that it would
automatically use the default alias (@/*), but it does not.

### Why?

Each option has --no prefix control but import-alias has no --no prefix
control to give default value to program.

In an [Interactive](https://nextjs.org/#interactive) approach, the user
can select a prompt; `Would you like to customize the default import
alias (@/*)? No / Yes.` If the user selects no, then the default alias
is applied with @/*.

### How?

Implementing a condition solve the problem for general purpose. If
arguments includes `--no-import-alias` then the importAlias section
automatically apply the default value.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2024-02-20 10:23:04 -05:00
Leah
a97725f5f6
fix(turbopack): print missing slots in debug message (#62280)
### What?

The console message was added in
https://github.com/vercel/next.js/pull/60186, but Turbopack outputs
fully resolved paths.


Closes PACK-2548
2024-02-20 16:22:15 +01:00
Tobias Koppers
0c7cc02527
tests are no longer flaky (#62278)
### What?

Next automatic update will update them

Closes PACK-2547
2024-02-20 14:44:11 +01:00
Vercel Release Bot
2af197b81c
Update Turbopack test manifest (#62268)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-02-20 12:59:12 +00:00
Balázs Orbán
ac1c14b8ce
feat(cli): show available memory/CPU cores in next info (#62249)
### What?

Adds a new line to the `next info` output:

```diff
Operating System:
  Platform: linux
  Arch: x64
  Version: #18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 11:40:03 UTC 2
+ Available memory (MB): 31795
+ Available CPU cores: 16
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: N/A
  pnpm: 8.15.1
Relevant Packages:
  next: 14.1.1-canary.61 // Latest available version is detected (14.1.1-canary.61).
  eslint-config-next: 14.1.1-canary.61
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A
```

### Why?

This can help in debugging

### How?

Using [`os.totalmem()`](https://nodejs.org/api/os.html#ostotalmem) and
[`os.cpus()`](https://nodejs.org/api/os.html#oscpus)

Closes NEXT-2529
[Slack
thread](https://vercel.slack.com/archives/C046HAU4H7F/p1708359702870269?thread_ts=1708355509.771049&cid=C046HAU4H7F)
2024-02-20 11:46:51 +01:00
Leah
ecb4d7484e
refactor(turbopack): resolve routes by page name instead of pathname (#61778)
### Why?

We currently use `page` and `pathname` in different places for file
system paths (manifests can be in a different folder to the js entry),
this PR makes more things just use `page` directly instead of going
through `pathname`.

This PR also adds an entry key (similar to the webpack version) uniquely
identifying all entry points (and assets).


Closes PACK-2432
2024-02-19 15:13:39 +00:00
Balázs Orbán
971843d019
fix: clarify Dynamic API calls in wrong context (#62143)
### What?

An unactionable error is thrown when `headers()`, `cookies()` or other
Dynamic API functions are called outside the render/request context.
This PR clarifies what the user can do to fix the problem.

### Why?

The current error is  hard to understand

> Error: Invariant: `cookies` expects to have requestAsyncStorage, none
available.

### How?

I am adding a dedicated error page and rephrasing the error message.

Closes NEXT-2509
2024-02-19 13:41:14 +01:00
Leah
031cf70092
fix(turbopack): catchall route matching (#62114)
This PR adds catch-all matching support to Turbopack. This allows you to
have catch-all parallel slots.

Closes NEXT-2038
Closes PACK-2518

Fixes #59502

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-02-19 10:44:53 +01:00
Tobias Koppers
8250a8419a
add turbo.resolveExtensions to allow to customize extensions (#62004)
### What?

* add `turbo.resolveExtensions` to allow to customize extensions in
Turbopack

fixes PACK-2335
Fixes https://github.com/vercel/turbo/issues/4934
2024-02-19 09:07:09 +00:00
Donny/강동윤
d8865d040a
test: Make css bundle assertion work also for turbopack (#62127)
### What?

Fix one assertion about CSS files emitted by turbopack.

### Why?

Turbopack generates `/_next/static/chunks/2225ce._.css`, which does not
match the regex.
Note that it has `._.css`. The previous assertions match on
`[^.]+\.css`, which does not support two dots in the file name.

I tried `/<link rel="stylesheet" href=".+\.css(\?v=\d+)?"/g`, but it
captured 3 `link` tags at once. So I used `/<link rel="stylesheet"
href="[^<]+\.css(\?v=\d+)?"/g`.


### How?

Closes PACK-2413
2024-02-19 03:35:13 +00:00
Donny/강동윤
755e88b16b
feat: Lint invalid CSS modules (#62040)
### What?

`css-loader` seems to have a linting rule for invalid CSS Modules.
[My Turbopack PR](https://github.com/vercel/turbo/pull/7381) implements
the same rule for `swc_css` and `lightningcss`, and this PR is for
enabling related test suite and updating the jest snapshot.

### Why?

`css-loader` has a similar linting rule.

### How?

Closes PACK-2408
2024-02-19 03:10:08 +00:00
JJ Kasper
8ef58bb113
Ensure webpack build worker defaults on (#62214)
As discussed almost all webpack plugins shouldn't have issues with this
being enabled by default so removing the default condition where we
disable this optimization due to custom webpack config is more
beneficial and in the rare case a custom plugin has issues it can still
be manually disabled.

Closes NEXT-2523
2024-02-18 15:41:35 -08:00
JJ Kasper
0b5f7d9b42
Update split chunk handling for edge/node (#62205)
While investigating OOMs noticed that our split chunks handling for edge
runtime isn't optimized properly causing a lot of duplicate
transpiling/minification which causes exponential memory/cache usage.

On a minimal app before this change the memory usage and cache size were
over `2GB`s after this change they are under `200MB`.

**Before**

![CleanShot 2024-02-17 at 16 08
46@2x](https://github.com/vercel/next.js/assets/22380829/5286e5fb-5e48-4296-a6be-d2ed1455eb95)


**After**

![CleanShot 2024-02-18 at 08 58
51@2x](https://github.com/vercel/next.js/assets/22380829/f813a185-51a7-40e0-b44b-e1ab95649194)



Closes NEXT-2521
2024-02-18 15:27:40 -08:00
Tobias Koppers
8ee776dd17
add support for esmExternals in pages (#61983)
### What?

* add support for esmExternals in pages
* fix default of esmExternals to true
* fix serverComponentExternalPackages support
* add test case

fixes PACK-2311
fixes PACK-1916

Fixes https://github.com/vercel/turbo/issues/4544
2024-02-16 23:09:45 +00:00
Leah
ca1b6184c8
chore: update test template to use nextTestSetup (#62154)
### Why?

Less indentation and allows for IDE integration.



Closes PACK-2523
2024-02-16 17:30:54 +01:00
Jiachi Liu
cbdd1d2654
Fix handling subpath for server components externals (#62150)
Follow up of #61986 where we didn't handle the subpath externals very
well, found by @sokra

Closes NEXT-2517
2024-02-16 17:24:12 +01:00
Tim Neutkens
212553958c
Fix issue with ComponentMod being read in Turbopack (#62141)
## What?

Fixes an issue where trying to build an edge runtime page with
generateStaticParams fails to read `ComponentMod`. Discussed with @sokra
and found that changing it to `import()` resolves the problem.

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

-->


Closes NEXT-2514
2024-02-16 16:06:38 +01:00
Jiachi Liu
dd24033caf
DX: hide the webpack info prefix for module paths (#62101)
### What

Hide the module file path webpack prefix for better visualization.
There're few types of webpack module prefixes 

- `wepack://`
- `wepack:///`
- `webpack://_N_E`
- `webpack-internal:///`

We're stripping them from the module path

### After vs Before
<img width="320"
src="https://github.com/vercel/next.js/assets/4800338/a9f5ae61-4fbf-42d7-b3e0-9bed1c7babb4">
<img width="420"
src="https://github.com/vercel/next.js/assets/4800338/ed6e120a-7c1c-4c31-be5d-9a1726d4e20c">


Closes NEXT-1966
Closes NEXT-1983
Closes NEXT-2504
2024-02-16 11:33:34 +01:00
Donny/강동윤
12639c4847
test: Make css deduplication assertion work for turbopack (#62128)
### What?

Fix one assertion about CSS files emitted by turbopack.

### Why?

Webpack generates 3 links with `?v=` query, and 2 extra links without
`?v=` query. Turbopack does not have query string, so we match 5 links.

### How?

Closes PACK-2414
2024-02-16 17:37:55 +09:00
Dima Voytenko
b4db808822
OpenTelemetry: trace API routes in page router (#62120)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-16 03:45:59 +00:00
Will Binns-Smith
60b60683bd
Update to turbopack-240215.5 (#62119)
Includes:
- https://github.com/vercel/turbo/pull/7401

This makes “conversion to class component” Turbopack tests pass.
2024-02-16 00:52:29 +00:00