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`.
### 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
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
### 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>
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.'" `
### 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
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>
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>
### 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
## 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)
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.
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.
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.
### 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
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 #
-->
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.
### 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.