Commit graph

17627 commits

Author SHA1 Message Date
OJ Kwon
e8adcd8527
feat(turbopack): support next.js specific node polyfills (#55343)
- feat(turbopack): support next.js specific node polyfills
- test(turbopack): migrate polyfill tests

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



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

This PR fulfills gap for the node.js polyfill between next.js to
turbopack, then enable corresponding integration tests.


Closes WEB-1552
2023-09-14 14:52:16 +02:00
Will Binns-Smith
17ba84b7a7
WEB-1135: Update examples and schema for Turbopack loaders config change (#54584)
This addresses inconsistencies with existing examples and config schema
from changes in #49535.


Closes WEB-1451
2023-09-14 14:50:02 +02:00
Tobias Koppers
9b788c592e
fix memory leak in require.cache cleanup (#55377)
### What?

We need to clear `.parent` and `.children` when deleting from require.cache

### Why?

otherwise we leak memory


Closes WEB-1558
2023-09-14 12:49:39 +00:00
Tim Neutkens
b61dd99753
Fix CPU profile generation (#55365)
Noticed not all CPU profiles were written since the recent server changes. This ensures they're always written as `CPU.main`. Also adds support for `next build`.
2023-09-14 09:47:28 +00:00
Tobias Koppers
1ffc40ac6d
fix turbopack HMR, fix disconnect detection (#55361)
### What?

Fix reload in turbopack on every change
Fix loosing of events due to debouncing
Fix writing of CSS files for CSS HMR

### Why?

Since we removed the pong event, the websocket impl would cause reconnects every 5 seconds loosing HMR events...

### How?


Closes WEB-1555
2023-09-14 09:03:52 +00:00
Will Binns-Smith
423d66b086
Dev tracing: include page visibility when reporting HMR (#55247)
Since browsers throttle JavaScript execution when pages (tabs) aren't visible, this can impact the accuracy of this metric.

Test Plan: Tested with page visible and not, and verified the request body reflected this.


Closes WEB-1536
2023-09-14 02:22:57 +00:00
Umoh Andem
055b5df50d
Update generate-metadata.mdx (#55347)
fixed a grammatical blunder
2023-09-14 02:08:23 +00:00
Ngô Đức Anh
f2f582c17f
Fix network URL logging in start-server (#55260)
### What?
Follow-up of #54926.
While that PR's main fix is no longer necessary due to the removal of render workers, I figure that some changes are nice-to-have and have isolated them into this PR. This includes fixing `appUrl` and `networkUrl` in `start-server`, fixing docs and removing some unnecessary template literals in `turbopack-warning`.

### How?
`appUrl` now tries to use `hostname` instead of `actualHostname` (an address like `example.com` seems to be more useful here than an IP like `xxx.xxx.xxx.xxx`), and `networkUrl` is now prefixed with `http://`.

Other simple changes include fixing docs.



Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-09-14 02:01:26 +00:00
Vercel Release Bot
f89caca530
Update font data (#55348)
This auto-generated PR updates font data with latest available
2023-09-14 00:17:46 +00:00
Jiachi Liu
b3e95edab4
Warn experimental.appDir option can be removed (#55346)
We have dropped `experimental.appDir` option, to share the insights that can be removed, add a warning `"App router is enabled by default now, <experimental.appDir> option can be safely removed.'" `
2023-09-13 23:38:17 +00:00
simonri
2ea7290824
Fix next swc windows bug (#55294)
### What?
Updated regex to support Windows paths in `is_layout_or_page`, resolving inconsistent behavior between OSes.

Previously, the regex was tailored for Linux paths, causing certain checks to fail on Windows such as:
- Server entry can't export `generateMetadata` and `metadata` together.
- Client entry can't export `generateMetadata` or `metadata`.

Fixes #55267
2023-09-13 23:22:09 +00:00
vercel-release-bot
800fdc11ae v13.4.20-canary.28 2023-09-13 22:47:32 +00:00
JJ Kasper
2d354ac3a5
Revert react-server-dom require change (#55345)
Reverts a piece of https://github.com/vercel/next.js/pull/55287 which seems to break edge-functions. We'll need to investigate an alternative and add a test case to ensure it fixes the case as expected. 

```sh
Error: The Edge Function "hello/world/dashboard/another-edge" is referencing unsupported modules:
--
- index.js: react-server-dom-webpack/client.edge
```

x-ref: https://github.com/vercel/vercel/actions/runs/6177961848/job/16770369085?pr=10504#step:9:308
2023-09-13 22:42:29 +00:00
Jiachi Liu
14e94e69c5
fix duplicated error logging when start server (#55328)
There're few places calling `loadConfig` to access nextjs config for different purpose, and every of them will do validation of next config scheme and could log the warnings potentially to cause duplicated warnings. To address that issue this PR limit the places when should the warnings be logged in certain places, mainly the `next` command entry. Refactor the API here to make it more explicit

Previous logging redeisgn also might trigger duplicated compilation, for instance you compiled page A but then editing another component it might still displaying page A is recompiled. Now we always display `"Compiled .."` message when there's a recompilation but avoid the unnecessary ones such as initial edge compilor ready but there's no modules inside. Then when it recompiles or recovers from error nextjs server will tell "Compiled .." instead of the specific page which might be not related.

Also refactors a minor issue: When `silent` option is set to `true`, auto recorrect next config option from `loadConfig` API like `traillingSlash` is not working

Closes NEXT-1610

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-09-13 22:25:41 +00:00
OJ Kwon
4a6a2ca258
feat(turbopack): attach type metadata for static metadata item (#55340)
### What?

Trying to mimic 32e066ff6c/packages/next/src/build/webpack/loaders/next-metadata-image-loader.ts (L160C7-L160C12), when there's a static metadata turbopack does not includes `type` properties. This partially fulfills existing metadata test cases for checking those values.

Closes WEB-1551
2023-09-13 22:05:33 +00:00
Mayank
f94d4f93e4
fix: upgrade listr2 from 5.0.5 to 5.0.8 (#55223)
upgrade listr2 from 5.0.5 to 5.0.8.





Co-authored-by: Snyk bot <19733683+snyk-bot@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-09-13 21:02:14 +00:00
Arseny Kruglikov
3561baa5d4
docs: add explicit units to isrMemoryCacheSize option (#55108)
This PR clarifies `isrMemoryCacheSize` value units. Units is not obvious
due to `Defaults to 50MB` comment and lack of TSDoc comments

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-09-13 15:52:04 -05:00
vercel-release-bot
32e066ff6c v13.4.20-canary.27 2023-09-13 17:38:35 +00:00
Leah
d64bc4c619
fix react-server-dom-webpack cache invalidation (#55287)
### What?
Webpack wrapped the external import in a new module, making `require.cache` invalidation impossible.

This also adds a basic fallback manifest for turbopack.

Closes WEB-1522
2023-09-13 17:20:48 +00:00
Michael Novotny
fe797c1074
Updates Mozilla links to not include language preference (#55326)
Internal suggestion to remove `en-US` from Mozilla urls since MDN is
available in multiple languages nowadays it will automatically redirect
to the viewer’s language preference.

Closes
[DX-2076](https://linear.app/vercel/issue/DX-2076/make-external-mozilla-links-language-agnostic-in-nextjs-docs)
2023-09-13 11:06:29 -05:00
Jiachi Liu
083f49c247
Logging improvements (#55298)
## Logging Improvements

* Delay server start logging
Post start logging after request handler is created, so when error
occurred like missing "app" or "pages" directory it won't log start
server message, instead it will only show error message.

* Fix jsconfig hmr case
Previously the `jsconfig.json` is patched too early that didn't trigger
the hmr reload, this PR enables it to show on the

* Adding timestamp for "ready" event
Display a timesmap after "ready" message, so we can monitor how long
does it take, and keep perfing on it

* Polish logging format
  * Starts with captital letter
  * align the indentation


![image](https://github.com/vercel/next.js/assets/4800338/fb87e0c4-3965-48da-86ef-a178e77d83f2)
2023-09-13 15:27:02 +02:00
Jimmy Lai
b784d819d8
server: switch pages to react dom edge renderer (#55318)
This PR fixes the warnings that have started to appear because of #54813

```
Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.
    at PathnameContextProviderAdapter (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/shared/lib/router/adapters.shared-runtime.js:84:11)
    at Be (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/compiled/next-server/pages.runtime.dev.js:1:47625)
    at Ze (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/compiled/next-server/pages.runtime.dev.js:1:48314)
    at div
    at Ye (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/compiled/next-server/pages.runtime.dev.js:1:55388)
Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.
    at PathnameContextProviderAdapter (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/shared/lib/router/adapters.shared-runtime.js:84:11)
    at Be (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/compiled/next-server/pages.runtime.dev.js:1:47625)
    at Ze (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/compiled/next-server/pages.runtime.dev.js:1:48314)
    at div
    at Ye (/Users/feedthejim/Projects/vercel/next.js/packages/next/dist/compiled/next-server/pages.runtime.dev.js:1:55388)
```

they appear because we are using two variants versions of `react-dom` on the server between pages and app router. This changes so that we only use one when you use app and as such, makes the warning disappear.
2023-09-13 12:41:04 +00:00
Tim Neutkens
83e2c67a69
Use NextJsHotReloaderInterface in router-server (#55317)
Small typing win as it ensures this is the same type between Turbopack/webpack.
2023-09-13 11:43:47 +00:00
OJ Kwon
6111845e11
test(next-dev): clean up 404 tests (#55292)
### What?

Previous change migrated 404 tests https://github.com/vercel/next.js/blob/canary/test/turbopack-tests-manifest.js#L112-L115 from next.js.

Closes WEB-1542
2023-09-13 06:35:32 +00:00
Zack Tanner
926b207306
remove --experimental-turbo from supported next-dev args (#55300)
Follow-up to https://github.com/vercel/next.js/pull/55063 so that we give a proper error when using the wrong `--turbo` flag. 

[slack x-ref](https://vercel.slack.com/archives/C04KC8A53T7/p1694561343223349)
2023-09-13 00:20:52 +00:00
Jiachi Liu
94ae5098bd
Test with latest node@18 (#54000)
Basically revert #52894, should be able to keep testing against latest node 18
2023-09-12 21:47:51 +00:00
Jiachi Liu
85d30b62db
Remove unused option and unified ready message into start server (#55289)
Remove the `logReady` optional option introduced in #52492, never being passdown but alwasy `true` by default.
2023-09-12 20:29:32 +00:00
Lee Robinson
6e3c4e24ed
docs: Add some App Router FAQs (#55186)
Based on questions I've seen in issues and discussions.
2023-09-12 19:45:55 +00:00
Daigo Shitara
49a876d456
Update route-segment-config.mdx for fix broken link (#55212)
Fixed link to `Node.js Runtime` in the revalidate section, as the link
was broken by the leading `/`.

Co-authored-by: Steven <steven@ceriously.com>
2023-09-12 15:43:19 -04:00
Mayank
546bd28c00
fix: upgrade react-native-web from 0.11.7 to 0.19.7 (#55221)
upgrade react-native-web from 0.11.7 to 0.19.7.




Co-authored-by: Snyk bot <19733683+snyk-bot@users.noreply.github.com>
2023-09-12 19:36:33 +00:00
JJ Kasper
c2f587640a
Update docs for revalidatePath fix (#55083)
This updates docs for the fixes landed in
https://github.com/vercel/next.js/pull/53321 related to
`revalidatePath`.

Fixes: https://github.com/vercel/next.js/issues/49387

---------

Co-authored-by: Lee Robinson <me@leerob.io>
2023-09-12 11:28:16 -07:00
OJ Kwon
45fbd4db14
refactor(next-font): use next-transform-font (#55252)
Closes WEB-1539

### What?

It looks like there are duplicated codes between `next-font` and `next-transform-font`, and the prior is not being referenced anywhere.
2023-09-12 17:48:58 +00:00
Wyatt Johnson
e6ec464e58
fix: removed unused intercepting route definition references (#55285)
This removes unused references to intercepting routes that was not fully implemented.
2023-09-12 17:10:19 +00:00
Pekka Enberg
45ee4ed260
Add libsql to external package list (#55266)
The `libsql` package is a fork of `better-sqlite3` that powers the Turso database client. Let's add `libsql` to the list of external packages, like `better-sqlite3`, so that people don't have to add extra configuration for their Next.js applications.
2023-09-12 16:48:48 +00:00
OJ Kwon
0bf5cbb901
feat(next-dev): reenable turbopack beta message (#55116)
### What?
Minor PR brings back turbopack beta message. We'll need to improve the actual checks per progress, but that might need auditing what's working vs not later.


Closes WEB-1517
2023-09-12 16:39:26 +00:00
Wyatt Johnson
d3656cc42b
reafactor: renamed pathname -> page (#55282) 2023-09-12 16:02:43 +00:00
Mayank
9f852403f0
fix: upgrade sharp from 0.29.3 to 0.32.5 (#55254)
upgrade sharp from 0.29.3 to 0.32.5.

Fix Remote Code Execution (RCE)
[SNYK-JS-SHARP-2848109](https://snyk.io/vuln/SNYK-JS-SHARP-2848109)




Co-authored-by: Snyk bot <19733683+snyk-bot@users.noreply.github.com>
2023-09-12 15:38:10 +00:00
Mayank
c91e6609bf
fix: upgrade date-fns from 2.28.0 to 2.30.0 (#55274)
to upgrade date-fns from 2.28.0 to 2.30.0.



Co-authored-by: Snyk bot <19733683+snyk-bot@users.noreply.github.com>
2023-09-12 15:26:49 +00:00
vercel-release-bot
366885f387 v13.4.20-canary.26 2023-09-12 13:20:27 +00:00
Jimmy Lai
2a7f5cdb0a
build: fix minimal trace caching (#55279)
This PR fixes a small issue where we would not save nor read the minimal
server trace file from the cache, meaning that whenever you would do two
builds in a row, the build would skip the tracing of the server as
expected but not include a minimal server trace in the dist folder.

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

-->
2023-09-12 15:15:43 +02:00
Jiachi Liu
180d55248f
Make open editor icon size non-shrink in error overlay (#55273)
In error overlay when the error trace file path is too long, the open editor icon on the right side get shrinked to very small. Mark it as `flex-shrink: 0` to avoid the unexpected size change

### After

![image](https://github.com/vercel/next.js/assets/4800338/31d93520-ee82-4867-97b3-9e22e5f71da7)


### Before

![image](https://github.com/vercel/next.js/assets/4800338/57c27636-b9e6-4e1d-b68b-0247dbd882cd)
2023-09-12 11:17:30 +00:00
vercel-release-bot
8e1626851e v13.4.20-canary.25 2023-09-12 10:34:24 +00:00
Jimmy Lai
f4e6dea1f2
build: fix externals resolution when importing from next/dist (#55269)
This fixes a "bug" where Sentry was trying to access some of the internal async storages and it would fail because their imports would be compiled as-is instead of using the special rules for Next externals as we are short-cutting it for `next/dist` requests for some reason.

Not a bug per se because this is technically an undocumented API but I think it's a reasonable fix since we don't provide an API for that. The alternative for them would be to try to play around with the bundling, which is not a good use of anyone's time.
2023-09-12 10:26:34 +00:00
Nick Olinger
3afba0d12d
feat: add reserved port validation (#55237)
### Fixing a bug

- [x] Related issues linked using `fixes #number`
- [x] Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- [x] Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md

Closes NEXT-
Fixes #55050 


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2023-09-12 07:31:35 +00:00
OJ Kwon
92e1b3fef9
test(fixture): improve finding ports to reduce flaky (#55151)
### What

Found a flaky test like https://github.com/vercel/next.js/actions/runs/6125719281/job/16628276301?pr=55118#step:29:174, `get-port` throws by port is not available. Peeking bit, there seems an upstream fix hope to improve the situation but unfortunately it happened after get-port switched to native esm only, so bumping is non trivial work. Instead adapting get-port-please as a replacwement but leave get-port as fallback for a while to verify its stability. Once we are certain, we can remove old get-port entirely.
2023-09-11 21:48:29 +00:00
OJ Kwon
ddc26c9904
test(turbopack): migrate 404-related tests from next-dev (#55243)
Closes WEB-1535
2023-09-11 21:16:51 +00:00
vercel-release-bot
476fe4a1f6 v13.4.20-canary.24 2023-09-11 20:24:23 +00:00
Lee Robinson
591d4e11ef
docs: clarify setting cookies docs (#55149) 2023-09-11 15:19:57 -05:00
JJ Kasper
7d93808c43
Remove render workers in favor of esm loader (#54813)
Currently we create separate workers to isolate `pages` and `app`
routers due to differing react versions being used between the two. This
adds overhead and complexity in the rendering process which we can avoid
by leveraging an `esm-loader` similar to our `require-hook` to properly
alias `pages` router to the bundled react version to match `app` router
when both are leveraged together.

This aims to seamlessly inject the `esm-loader` by restarting the
process with the loader arg added whenever `next` is imported so that
this also works with custom-servers and fixes the issue with custom
req/res fields not working after upgrading.


x-ref: https://github.com/vercel/next.js/issues/53883
x-ref: https://github.com/vercel/next.js/issues/54288
x-ref: https://github.com/vercel/next.js/issues/54129
x-ref: https://github.com/vercel/next.js/issues/54435
closes: https://github.com/vercel/next.js/issues/54440
closes: https://github.com/vercel/next.js/issues/52702
x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1693348443932499?thread_ts=1693275196.347509&cid=C03KAR5DCKC)

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-11 22:17:52 +02:00
Daniel Salvadori
e486d74464
Fix typo (#55245)
This PR fixes a single character typo.
2023-09-11 12:09:06 -07:00