Noticed while testing across CI environments that the `test-pack` handling is not-concurrent or cache safe so this removes it from being used by default and moves it behind a flag to allow further investigating later.
In CI if `test-pack` is called at the same time due to multiple concurrency it can cause the resulted archive to be corrupted so may require a form of lock to resolve in CI although locally re-using the same archive name/path isn't safe with pnpm as it won't bust the store cache and continue to leverage previous cache.
## Issue
To address the problem that we introduced in 13.0.7 (#42589) where we thought we could use same implementation `next/dynamic` for both `pages/` and `app/` directory. But it turns out it leads to many problems, such as:
* SSR preloading could miss the content, especially with nested dynamic calls
* Closes#45213
* Introducing suspense boundary into `next/dynamic` with extra wrapped `<Suspense>` outside will lead to content is not resolevd during SSR
* Related #45151
* Closes#45099
* Unexpected hydration errors for suspense boundaries. Though react removed this error but the 18.3 is not out yet.
* Closes#44083
* Closes#45246
## Solution
Separate the dynamic implementation for `app/` dir and `pages/`.
For `app/` dir we can encourage users to:
* Directly use `React.lazy` + `Suspense` for SSR'd content, and `next/dynamic`
* For non SSR components since it requires some internal integeration with next.js.
For `pages/` dir we still keep the original implementation
If you want to use `<Suspense>` with dynamic `fallback` value, use `React.lazy` + `Suspense` directly instead of picking up `next/dynamic`
* Closes#45116
This will solve various issue before react 18.3 is out and let users still progressively upgrade to new versions of next.js.
## Bug Fix
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
If there's an error when hard navigating to a page, the overlay in `packages/react-dev-overlay` is rendered instead of the one in `next`. This can cause you to get stuck if it's a server component because currently `packages/react-dev-overlay` ignores server component change events. This adds a reload for this case. The next step is probably to make sure the `app` overlay is rendered for errors during hard navigations as well.
## Bug
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Feature
- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Documentation / Examples
- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
<!--
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:
-->
Found a bug with excluding `/_next/static` from Edge Middleware due to
`/_next` being special-cased when deployed and i18n is configured.
```
export const config = {
matcher: [
'/',
'/((?!api|_next/static|favicon|.well-known|auth|sitemap|robots.txt|files).*)',
],
};
```
closes: https://github.com/vercel/next.js/issues/40305
## Bug
- [X] Related issues linked using `fixes #number`
- [X] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
Closes NEXT-397
Resolve `metadata` and `generateMetadata()` exports along with head
during rendering, this is the easy way for now to collect all the
metadata properly. Since we can access segment params and search params
only in rendering, so I moved all the resolving logic from loader to
render process.
<!--
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 that you're making:
-->
## Feature
- [x] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [x]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
---------
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Adds `data-next-font` data attribute to the preload tag if added by
`@next/font`.
```js
// Using `size-adjust` fallback font.
<link data-next-font="size-adjust" rel="preload" href="..." as="font" type="font/woff2" crossorigin="anonymous">
// Not using `size-adjust` fallback font.
<link data-next-font="" rel="preload" href="..." as="font" type="font/woff2" crossorigin="anonymous">
```
If no fonts are preloaded, the tag is added on the preconnect tag.
Fixes NEXT-350
## Bug
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Feature
- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Documentation / Examples
- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Adds support for `router.push('https://google.com')`,
`router.replace('https://google.com')`, and
`redirect('https://google.com')`.
<!--
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 that you're making:
-->
## Bug
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Feature
- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Documentation / Examples
- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
---------
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This fixes a regression in our source map generating which got lost in
the big diff from the `src` folder restructure in
https://github.com/vercel/next.js/pull/44405
These invalid source maps broken plugins that attempted to leverage them
like `@sentry/nextjs` which only attempts in a production environment
15ec85bead/packages/nextjs/src/config/webpack.ts (L586)
For a regression test in a follow-up we will need to investigate a
production test fixture with `@sentry/nextjs` although this requires a
DSN be configured.
This also ensures we setup `unhandledRejection` and `uncaughtException`
listeners during build so that we have proper stack information when
these occur and the process isn't left hanging.
This also moves the `extensionAlias` config from
https://github.com/vercel/next.js/pull/44177 to an experimental config
as it seems to cause conflicts with ESM packages that define `exports`
in their `package.json` which can be considered a breaking change.
## Bug
- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
Fixes: https://github.com/vercel/next.js/issues/45419
x-ref: [slack
thread](https://vercel.slack.com/archives/C03DQ3QFV7C/p1674937545579229)
Since the tests are run with `pnpm test` locally this adds the repo's
`node_modules/.bin` to the PATH env variable although in CI `node
run-tests.js` is used which doesn't augment PATH like this so this
strips these from the env when running isolated tests to match behavior.
x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1674913457101449)
<!--
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 that you're making:
-->
Allows you to `next build --experimental-app-only` which excludes
`pages` altogether. Useful for quickly debugging while migrating.
Co-authored-by: JJ Kasper <jj@jjsweb.site>
We currently don't make it obvious when next export is being leveraged
and middleware is present which won't work when deployed to a static
host so this ensures we warn the same way we do for API routes.
x-ref: https://github.com/vercel/vercel/pull/9319
Right now, when doing the following in an Edge API:
```typescript
export default async () => {
await fetch("https://hello.world");
};
```
The stack trace generated does not contain the actual line of code that caused the error.
This gives a bad developer experience when working with `next dev`.
This PR fixes that for this specific use case and adds a test to make sure there's no regression.
For `next start`, there's also a small change, that needs to be pushed upstream to `edge-runtime`.
In order to run user code in the Edge Runtime, we call `vm.evaluate(code: string)`. However,
if we embrace the `options` from the signature of `vm.runInContext(code, ctx, options)`, we can
pass in the filename so the stack trace is correct.
## Bug
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
- Add support for scrolling to the sides and down when navigating
- Add tests for vertical scrolling
- Add tests for horizontal scrolling
- Add tests for `router.refresh()`
- should not scroll by itself
- should not block router.push from scrolling
- should not scroll when page refreshed using fash refresh
- Scroll to the top of document if that gets page into viewport
- I didn't want to implement some heuristics on if we can scroll to the top of the page so I just scroll there and check.
- This implementation may not play well with some nested scrollable containers (but that never worked, just FYI)
- Improved typings on `BrowserInterface` a little - backward compatible change.
Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>