Commit graph

3854 commits

Author SHA1 Message Date
JJ Kasper
bfc3849b1f
Update generateStaticParams handling with fetch cache (#46906)
This ensures we leverage the fetch cache when calling
`generateStaticParams` and also ensures paths with
`generateStaticParams` without `dynamicParams = false` don't error when
only partial params are provided.

x-ref: [slack
thread](https://vercel.slack.com/archives/C035J346QQL/p1678149362238089)
2023-03-07 22:59:06 -08:00
Shu Ding
105e5b0088
Add retry to the hmr acceptance test (#46902)
This one seems to be flaky ([example](https://github.com/vercel/next.js/actions/runs/4357945817/jobs/7618498044)) as the default `page.goto` timeout is set to 30s, while it already takes 15~20s to load locally on my laptop. So let's add some retries here.
2023-03-07 22:39:50 +00:00
JJ Kasper
9c36a3204a
Update app-static e2e test (#46900)
This ensures we properly check for the none cached content correctly

x-ref:
https://github.com/vercel/next.js/actions/runs/4351711739/jobs/7603961011
2023-03-07 12:51:37 -08:00
Jiachi Liu
030fd1d684
Fix conflict dev entry key between app and pages (#46832)
Add unique identifier `@app@` / `@pages@` / `@root@` for entry key of on
demand entries, so that they'll be unique for each path when the page
key is similar bewteen app and pages like (`"app/page"` and
`"pages/page"` will both end up with `/page`)


## Bug

Follow up for #46736
Closes NEXT-472

- [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)

---------
2023-03-07 12:27:10 -08:00
Shu Ding
4b8240b842
Support unnamed default export expression (#46888
This PR adds the support for unnamed default export expression support
`export default async function () {}` in a "use server" entry, with
corresponding test.

Also fixed an existing bug that the default exported action's name
should be aligned with the export name, which is `"default"`.

Closes NEXT-769.
2023-03-07 19:16:45 +01:00
JJ Kasper
e0e627cf2a
Ensure chained middleware rewrites work properly (#46866)
Follow-up to https://github.com/vercel/next.js/pull/45772 this ensures
the rewrite header can be correctly set when a chained middleware
rewrite is occurring.

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

## 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)
2023-03-06 23:21:42 -08:00
Sukka
26768571ad
test(unit): add cases for cssnano simple (#46862)
Continues from #46380. The PR migrates the unit test cases from the original repo into the Next.js repo.
2023-03-07 06:28:53 +00:00
JJ Kasper
8f5ffed72e
Update fetch cache handling with POST requests (#46856)
This updates to no longer skip caching POST or authed requests with the
fetch cache and instead we bail when `cookies()` or `headers()` is used
prior which is a better heuristic to signal user specific data would be
related to the fetch request.

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

## 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)
2023-03-06 21:30:29 -08:00
Hannes Bornö
d59aa9655e
Port error overlay hydration error to pages directory (#46677)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-06 19:40:25 -08:00
Hannes Bornö
533748d383
next/font refactoring and additional unit tests (#46731)
Currently all helper functions are exported from huge utils files. This
moves the helper functions to their own files, this approach aligns
better with the rest of the codebase.

The unit tests are split up and colocated with the function it tests.
Also added some missing tests.

Plus some overall cleanup, added comments and fixed types.

## 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)
2023-03-06 17:16:25 -08:00
Ngô Đức Anh
ceb028a469
Fix(typedRoutes): fixed type Route resolving to type any (#46679)
This PR makes `typedRoutes` stricter by constraining generics in  `Route` to type string. I've also made generating types for routes a bit more efficient by moving `redirects` and `rewrites`'s processing to the plugin's constructor since `rewrites` and `redirects` don't change in both dev and prod.

I've also been trying to fix a bug where route types doesn't generate all the routes (some appear, some don't), but I've got no clues since that doesn't seem easy to reproduce (perhaps it only happens in my case?)

## 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)
2023-03-07 00:05:39 +00:00
Will Binns-Smith
a9be890292
next/font tests: support Turbopack css module format (#46658)
Turbopack uses a different format for its css module classnames [0].
This adds and uses a helper function to the next-font tests to assert
against these classnames when testing with Turbopack. Ideally these
tests could be more behavioral (e.g. asserting on rendered dimensions),
but these can't capture things like fallback fonts.

[0] https://github.com/vercel/turbo/pull/3437
2023-03-06 15:06:36 +01:00
Shu Ding
088c19f709
Correct server reference manifest in prod build (#46683)
Since we have 2 server compilers (node and edge), the `serverActions`
object will always get overridden by the second compilation during `next
build`. Like the client reference manifest, we need to have 2 objects
for each compiler and merge them when outputting the asset.

Besides that, to avoid `export default` being tree-shaken as unused
export, I changed the loader to use CJS `module.exports` instead. Can't
easily figure out a proper way for now but we plan to create separate
worker for the action endpoint and this will be gone then.

Fixes NEXT-759, read NEXT-761 for the full future plan.

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

## 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)
2023-03-05 10:00:48 -08:00
JJ Kasper
9dd24a5931
Fix middleware 404 prefetch case (#46782)
Ensures we properly generate the 404 page when a path is being prefetched with middleware configured. 

## 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: https://github.com/vercel/next.js/issues/38239#issuecomment-1454928413
2023-03-05 02:32:53 +00:00
JJ Kasper
3e9a99c8b0
Fix middleware notFound: true handling (#46759)
This ensures we properly handle rendering the `404` page when `notFound:
true` is returned and middleware is present.

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

Fixes: https://github.com/vercel/next.js/issues/38239
x-ref: https://github.com/vercel/next.js/issues/43772

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-04 21:35:45 +01:00
Jiachi Liu
9a768d5e62
test: refactor metadata tests to test multi matches easier (#46746)
Use some utils to match multiple dom nodes together

#### Match multiple props for single DOM node
```tsx
const matchDom = createDomMatcher(browser)
await matchDom('meta', 'name="description"', { content: 'description' })
```

#### Match multiple same pattern DOM nodes in html
```tsx
const $ = await next.render$('html')
const matchHtml = createHtmlMatcher($)
await matchHtml('meta', 'name', 'property', {
  description: 'description',
  og: 'og:description'
})
```

#### Match same pattern DOM nodes in browser after hydration
```tsx
const matchMultiDom = createMultiDomMatcher(browser)
  await matchMultiDom('meta', 'property', 'content', {
  description: 'description',
  'og:title': 'title',
  'twitter:title': 'title'
})
```
2023-03-04 17:20:47 +00:00
JJ Kasper
8303c5648a
Pass through original matcher source in manifest (#46753)
This ensures we pass through the original matcher source in the
middleware manifest for posterity.
2023-03-03 16:55:41 -08:00
Steven
25efdfad36
Add support for output: export config (#46744)
## Background

In the early days, `next export` was created when Next.js was SSR-only in order to statically export your pages for self hosting where no server was available. However, around the time `getStaticProps()` and `getStaticPaths()` were introduced, Next.js began [automatically generating static pages](https://nextjs.org/docs/advanced-features/automatic-static-optimization) (SSG first and SSR opt-in) during `next build`. This meant there were very few reasons to use `next export` and it started to become a stale feature.

## Problem We Need To Solve

Users targeting `next export` currently have a really bad experience. They start a new project and use all the features Next.js has to offer because they all features work with `next dev`. Then when development is finished and it comes time to deploy, running `next build && next export` will fail with errors for [unsupported features](https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features).

## Solution

This PR introduces a new configuration option, `output: 'export'`, to indicate that the user intends to run `next export`.

With this change, Next.js can fail fast during `next dev` if any [unsupported features](https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features) are used, thereby improving developer experience with instant feedback.


```js
/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  output: 'export',
}

module.exports = nextConfig
```
2023-03-04 00:46:20 +00:00
Shu Ding
ef685e8fb1
Adjust API route loader (#46726
Similar to #46328 but with `hasServerComponents: false` for the compiler
so RSC syntax constrains don't apply here.

Note that since we don’t bundle external modules in API routes, we can't
resolve to `react-server` so that one will be tricky.

Fixes NEXT-625

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

## 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)
2023-03-04 01:18:07 +01:00
JJ Kasper
33827ede54
Update client router filter to separate redirects handling (#46752)
x-ref: [slack
thread](https://vercel.slack.com/archives/C017QMYC5FB/p1677875647422339)
x-ref: [slack
thread](https://vercel.slack.com/archives/C049YV4U2F6/p1677875992732789)

## 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)
2023-03-03 16:02:02 -08:00
JJ Kasper
35d8e8379e
Ensure app chunk URLs are encoded properly (#46749
This ensures we properly encode chunks for app dir the same we do for
pages.

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

x-ref: https://github.com/vercel/next.js/pull/8435
2023-03-03 14:17:07 -08:00
Jiachi Liu
bca80141d1
Fix require cache conflict between app and pages (#46736)
Related NEXT-472

When you have `app/page.js` and `pages/page.js`, the `pagePath` are the
same, which is `/page`. This will result require cache conflicts. When
you visit the `app/` page first, then the `pages/` page, the 2nd request
will still get the app dir page module, which result in server error.

Solution: use different cache key of pagePathCache for pages/ and app/ 

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

## 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)
2023-03-03 12:24:09 -08:00
Wyatt Johnson
45492eacc0
Fix originalRequest not available for edge requests (#46741)
For requests made via the edge runtime, they will not contain the
`originalRequest` object used by the request storage to enable
headers/cookie access. This uses the request object passed when in the
edge runtime.
2023-03-03 18:14:49 +00:00
Jiachi Liu
4e54429369
Support multi title for alternates (#46700)
This allows to have different titles for alternates urls, but for canonical, you can only have one.

Closes NEXT-624

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] 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)

## 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)
2023-03-02 22:42:10 +00:00
Wyatt Johnson
3229ed79a6
Support force-static on App Routes (#46693)
Supports `export const dynamic = 'force-static'` on App Routes. This strips pieces of information from the request object to ensure subsequent requests don't accidentally cache user specific data:

- Removes `searchParams`
- Removes `headers`
- Removes `cookies`
- Removes `host`
- Removes `port`
- Removes `protocol`

[NEXT-682](https://linear.app/vercel/issue/NEXT-682/force-static-doesnt-work-with-app-routes)
2023-03-02 19:28:37 +00:00
JJ Kasper
e7ee310f32
Add build worker exit tracking and enable tests (#46698)
Ensures we properly log when a compilation worker unexpectedly exits and ensures we enable the flag for some test suites to ensure it's covered. 

x-ref: https://github.com/vercel/next.js/pull/46666
x-ref: [slack thread](https://vercel.slack.com/archives/C04S835KUC9/p1677777414887749?thread_ts=1677775341.172509&cid=C04S835KUC9)
2023-03-02 18:33:20 +00:00
JJ Kasper
ed51bd870b
Fix static to dynamic on revalidate (#46668)
Since it's perfectly valid to do an authorized request during revalidate we shouldn't consider this a reason to throw the static to dynamic error during runtime. If an authorized request is done during build and caching isn't enabled for a path it will still bail from being turned into a Prerender. 

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

## 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)
2023-03-02 10:14:56 +00:00
Jiachi Liu
63d81de6bc
test: add preconnect tests and move error tests (#46652)
* Add tests for `ReactDOM.preconnect | prefetchDNS | preload` usage
* Move mutate erroring tests to rsc-build-errors test suite
2023-03-01 23:09:16 +00:00
JJ Kasper
c62791294e
Ensure default config passes schema checks (#46656)
This ensures our config schema correctly validates with the default
config we provide.

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

## 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)
2023-03-01 14:45:58 -08:00
Michael Novotny
5e112c062e
Updates next/image eslint message to denote that costs may be incurred. (#46640)
Changes ESLint warning message to still encourage usage of `next/image`
for the best experience, but also denoting that optimization could come
with incurred costs.

## Feature

- [x] Documentation added
- [x] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm build && pnpm lint`
- [x] 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: Steven Tey <stevensteel97@gmail.com>
Co-authored-by: Steven <steven@ceriously.com>
2023-03-01 14:28:09 -08:00
teobler
5cc9010277
fix: distDir in verifyTypeScriptSetup for nextLint (#46630)
fixes #46611 

this PR fixed customer dist type(`distDir` option in next.config.js) in
`tsconfig.json` will be a hard coded absolute path issue which is a bug
from PR #46249
since dist type only be added when user using app dir, to reproduce this
issue you need to make `app dir` toggle on and add a `distDir` option in
`next.config.js` file

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

---------
2023-03-01 14:01:45 -08:00
Shu Ding
dd2a1c693a
Add request callback in Flight client (#46650)
Adding the `callServer` option to Flight client with a naive implementation.

Fixes NEXT-393.

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

## 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)
2023-03-01 20:28:01 +00:00
JJ Kasper
68a1d54465
Update app-static test page (#46645
x-ref: https://github.com/vercel/next.js/pull/46522/files#r1120671063
2023-03-01 11:12:00 -08:00
Shu Ding
1717fd2dbc
Fix IntelliSense for generateMetadata (#46624)
Related to #46431, this makes sure the IntelliSense for both sync and async `generateMetadata` is correct.

## 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)
2023-03-01 17:25:25 +00:00
John Daly
725fbc29ce
[next/jest] Support path aliases from tsconfig/jsconfig (#45815)
<!--
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:
-->

# Description

fixes #31159
fixes #44553

Path aliases defined in `tsconfig.json` or `jsconfig.json` are not
automatically configured to work with Jest. This means that these
aliases have to be defined in multiple places.

This PR configures the SWC Jest transform to handle the `baseUrl` and
`paths`, so that users don't need to configure a `moduleNameMapper` for
Jest.

~This PR intends to make the experience more seamless by automatically
configuring Jest's `moduleNameMapper` and `moduleDirectories` based on
the settings in a project's `tsconfig`/`jsconfig`.~

~Users will be able to supply their own configuration for these fields,
if they have use-cases that require manual configuration.~

~The implementation is taken from the [`paths-to-module-name-mapper`
function in
`ts-jest`](5a0880add0/src/config/paths-to-module-name-mapper.ts).~

## 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.
- [x] 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)
2023-03-01 10:52:32 +01:00
OJ Kwon
5acabf00d8
test(utils): support turbopack-based overlay error text lookup (#46589
<!--
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:
-->

- closes WEB-672. 

Due to differences of error overlay layout between turbopack and normal
next-dev, test fixtures cannot lookup corresponding error text with same
data-* tag. Companion PR https://github.com/vercel/turbo/pull/4015 added
new tag for the turbopack specific, and this PR utilizes those if test
runs against --turbo.

## Bug

- [x] Related issues linked using `fixes #number`
2023-03-01 10:23:39 +01:00
Hannes Bornö
b0b5cd8dc0
Add page path to repeated slashes in href error (#46557)
Currently if you find this error in your logs it's difficult to know
where it occurred. This adds the page pathname to the error message.

Before

![image](https://user-images.githubusercontent.com/25056922/221892504-383c0d31-5cc4-4e32-b317-9ebc42696151.png)

After

![image](https://user-images.githubusercontent.com/25056922/221892431-1dd2c3e5-b6aa-46a2-8ca9-3be266fee76f.png)

Ref:
[slack](https://vercel.slack.com/archives/C03KAR5DCKC/p1677527238287849?thread_ts=1677521794.667229&cid=C03KAR5DCKC)


## 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)
2023-03-01 00:10:11 -08:00
JJ Kasper
abf8a42326
Fix static to dynamic error in dev (#46597)
This corrects the static to dynamic error incorrectly showing in
development since we don't have enough information to accurately know if
this error should be thrown or not unless a build has been done.

Fixes: https://github.com/vercel/next.js/issues/46436
x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1677637140906959)

## 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)
2023-02-28 23:37:12 -08:00
Ngô Đức Anh
ff699471bf
Fix(typedRoutes): fixed Webpack crashing without redirects/rewrites (#46591)
<!--
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:
-->

This PR fixes some issue caused by PR 46327, which asserted that
`NextBuildContext.original(Rewrites|Redirects)` are defined although
`config._original(Redirects|Rewrites)` (which these two copied from) are
not actually defined when `config.redirects`/`config.rewrites` are not
as well (see `loadRedirects`/`loadRewrites`). So this PR fixes that by
removing those assertions and checking whether those are defined in
`createRouteDefinitions` before iterating them.

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

---------
2023-02-28 22:12:11 -08:00
JJ Kasper
076844e59f
Ensure URL can be passed to fetch correctly (#46592
Fixes: 

![CleanShot 2023-02-28 at 22 35
57@2x](https://user-images.githubusercontent.com/22380829/222042856-ee6dc3c4-c143-49f2-8023-5def749d6a64.png)


## 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)
2023-02-28 21:32:28 -08:00
Jiachi Liu
b5f92c444b
Fix: canonical should allow relative urls (#46584)
alternate urls should allow string type for relative paths

## Bug

Fixes #45824

- [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)

---------
2023-02-28 16:17:08 -08:00
Shu Ding
5532b6a93f
Fix app client child entry not being disposed when deleting the file (#46583)
Currently if a file or folder (that contains an entry) is renamed in app dir, the dev server will stop working because we never remove the old entry. Since all client entries in app dir are created as child entries programmatically via the RSC plugin, they're different and not handled by our existing hot reloader logic:

f0cbe84e4c/packages/next/src/server/dev/hot-reloader.ts (L666-L677)

This PR adds a file path to child entries as well (it can be layout, page and other entries) so in the entry generation step we can prune the invalid ones.

Fixes #46379, fixes NEXT-650.

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

## 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)
2023-02-28 23:32:03 +00:00
Jiachi Liu
4b705a5473
Use og:image instead of og:image:url (#46570)
x-ref: https://github.com/vercel/next.js/discussions/46545

In the open graph protocol spec, `og:image` and `og:image:url` are identical. But some platform might don't have full support for it.

We change it back to render `og:image` as it's the most common and compatible format, also easy to align with the code docs
2023-02-28 21:46:15 +00:00
teobler
b6b7933377
fix: generate next-env.d.ts file during next lint command (#46249)
fixes #46104

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

---------

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2023-02-28 11:51:22 -08:00
Steven
18dc09bf55
fix: should not warn when image unmounts (#46567)
- Fixes #40762

---------
2023-02-28 11:28:55 -08:00
Shu Ding
9edf2d3d1f
Fix CSS imports not included in entries with a custom extension (#46571)
`entryName` will contain the extension if it's not a normal JS entry, this causes CSS being missing in pages with a custom extension in app dir (e.g. MDX). Here we add a `.replace(/\.[^\\/.]+$/, '')` to the entry name.

Fixes NEXT-709

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

## 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)
2023-02-28 18:53:48 +00:00
JJ Kasper
d49c700d0d
Fix shared entries/invalidators module scope (#46533)
This ensures we don't keep `entries` and `invalidator` in module scope
directly and nest it under a key specific to each compilation so
multiple `next` instances in the same process don't override one and
another.

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

Closes: https://github.com/vercel/next.js/pull/46432
Fixes: https://github.com/vercel/next.js/issues/45852
2023-02-28 10:17:28 -08:00
Jimmy Lai
886dc9f30f
feat: add support for the src folder for the instrumentation hook (#46529) 2023-02-28 12:08:30 +01:00
JJ Kasper
619c76c0f9
Fix infinite invalidations loop in app dir (#46526)Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This fixes a case where depending on the timings of compilers being done
could cause an infinite invalidation loop.

**Before**


https://user-images.githubusercontent.com/22380829/221786587-1a4cc6ab-f273-4191-92af-a57e9fff1261.mp4

**After**


https://user-images.githubusercontent.com/22380829/221786611-f55c3da9-0201-40be-95a8-3ef1869d6a66.mp4

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1677441845988529?thread_ts=1677429424.151329&cid=C03KAR5DCKC)

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

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-28 11:07:29 +01:00
Shu Ding
5ff005f7b5
Refactor route types to include rewrites and redirects (#46327)
This PR refactors the implementation of `Route<T>` to be more compact
(2/3 fewer union types), and adds support for static rewrites and
redirects. Check the updated test for more details.

In the future I plan to continue to refactor this by extract static
routes out as unions (instead of always relying on type inference) for
better autocompletion. Maybe a dev-only feature?

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

## 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)
2023-02-28 10:18:47 +01:00
Shu Ding
877f2f5996
Upgrade precompiled react packages (#46365)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-28 10:13:02 +01:00
JJ Kasper
4ac4b757d4
Update fetch cache internal handling (#46522)
x-ref:
https://github.com/vercel/next.js/actions/runs/4288511720/jobs/7470646795
x-ref:
https://github.com/vercel/next.js/actions/runs/4288511720/jobs/7470647108
x-ref:
https://github.com/vercel/next.js/actions/runs/4288511720/jobs/7470647255
2023-02-27 21:39:11 -08:00
JJ Kasper
82f4fd3e8c
Update router filter to be less sensitive (#46515)
This skips including dynamic redirects in the client router filter as it
causes extra unexpected hard navigations.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04MEB9L9RQ/p1677521159911179?thread_ts=1677255545.574209&cid=C04MEB9L9RQ)

## 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)
2023-02-27 17:07:26 -08:00
RTrace
9ad1f321b7
Add interactive-widget optional property to Viewport type (#46506)
## 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: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-02-27 23:12:56 +00:00
JJ Kasper
aa614635d6
Update fetch cache key (#46513
x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1677461963151879?thread_ts=1677360662.652689&cid=C042LHPJ1NX)

## 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)
2023-02-27 14:14:14 -08:00
Shu Ding
9376a5afb2
Add image generation test to app route (#46449)
~~Currently blocked by #46448.~~
Closes https://github.com/vercel/satori/issues/410.

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

## 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)
2023-02-27 19:29:09 +01:00
Jiachi Liu
04547e8163
Add theme color media support for metadata (#46502)
x-ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color

Resolves NEXT-525



## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] 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)
2023-02-27 18:22:05 +00:00
Hannes Bornö
ce234fb9ad
Add error for styled-jsx in Server Component (#46482)
Add specific error for the `styled-jsx` import that's implicitly added
to the file when using `<style jsx>`.

Before

![image](https://user-images.githubusercontent.com/25056922/221547281-7b25a979-ee03-4d29-97c8-a038b9ebb214.png)

After

![image](https://user-images.githubusercontent.com/25056922/221547152-ed122163-93e5-48ae-bf95-484388f462ea.png)

Fixes NEXT-669

## 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>
2023-02-27 15:04:34 +01:00
Hannes Bornö
bd9ad97c8e
Fix next/font/google config not being used (#46484)
Make sure both `@next/font/google` and `next/font/google` works when setting subsets in `next.config.js`.

Fixes NEXT-668

## 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)
2023-02-27 12:18:19 +00:00
Jan Kaifer
714720ffa9
dynamic = "error" violations should be shown in error overlay (#45893
dynamic = "error" should throw in dev mode, currently, it just gets
ignored.
It doesn't throw a nice custom error, but at least it isn't silently
ignored anymore.

Build behavior stays the same.
2023-02-27 12:20:23 +01:00
Jan Kaifer
f3ef4e99b0
Cover 1st-party examples with tests (#45270)Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
We want to make sure that our examples are not breaking.
We don't want to be slowed down by broken 3rd party packages, but we
need to ensure that examples covering next.js features are always green.

Added as a standalone workflow that doesn't parallelize. It will just
run on a cron schedule, so we can check for current status. We can add
Slack ping later if we need to.

The workflow tests just that our examples can build, so mostly TS
issues. We could definitely follow up with actual tests, but that is not
as low-hanging.

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-02-27 11:54:24 +01:00
Seth Falco
adefdd2aaa
chore: show large data warning once per page on prod (#46323)
<!--
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:
-->

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Related

* Closes https://github.com/vercel/next.js/pull/39146 - PR abandoned.

## Details

I was having the same issue at work, as a workaround, we've changed the
`largePageDataBytes` setting as advised but we'd like to keep the
warning ideally. It's something we need to address, but just don't want
to spam our log aggregators while the large data issue isn't resolved.

I believe I've more or less copied what was in the original PR, some
small differences:
* I use `Set` instead of `Map`, please let me know if there is an
advantage to using Map!
* Just to keep code a bit tidier (subjective) put an early return
instead of nesting all the code in an if.
* Added a test to verify only one log appears even when the page is
accessed twice [as requested
here](https://github.com/vercel/next.js/pull/39146#pullrequestreview-1064486985).
2023-02-25 12:29:59 -08:00
JJ Kasper
ebed7396f5
Ensure fetch fields are detected with RequestInit (#46398)
This ensures we properly detect fetch fields when a `new Request()` is passed to fetch instead of a separate `init` param. 

Fixes: [slack thread](https://vercel.slack.com/archives/C035J346QQL/p1677264109548949)
Closes: https://github.com/vercel/next.js/issues/46349

## 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)
2023-02-25 15:50:51 +00:00
Ngô Đức Anh
821c251a61
Fix(typedRoutes): replaced readFile + replaceAll, hid utils types, fixed duplication in type Route, fixed route groups on Windows (#46378)
Fixes #46401

This PR fixes route groups not working with Windows by handling slashes properly by replacing RegEx expressions with `ensureLeadingSlash`, `getPageFromPath` (which uses `normalizePathSep`),... It also adds a test that ensures `typedRoutes` works with route groups to `app-types.test.js`.

It also replaces `fs.readFile` and String's `replaceAll` that were used to augment `next` in PR 46332 (which were rather overkill and inefficient in my opinion) with a `export * from "next/types/index.d.ts"`.

I've also converted `edgeRouteTypes` and `nodeRouteTypes` to 2 Sets so as to avoid duplications. When we write type `Route`, we also check if a route in `nodeRouteTypes` is already defined in `edgeRouteTypes`.

Types like `SearchOrHash`, `Suffix`, `SafeSlug`,... have also been made private to module "next" (before this PR users could access to these types anywhere in their workspace, which doesn't seem like an expected behaviour in my opinion).

## 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)
2023-02-25 14:50:14 +00:00
Shu Ding
516bc83296
Fix SWC error wrongly formatted (#46412)
We currently use the `NEXT_RSC_ERR_INVALID_API` error code for metadata API conflicts which is wrong. The format should be `NEXT_RSC_ERR_INVALID_API: foo` and then the formatter transforms it into `foo isn't supported in app/`.

This PR adds a new `NEXT_RSC_ERR_CONFLICT_METADATA_EXPORT` error code and improves the message. Closes #46406.

## 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)
2023-02-25 14:00:06 +00:00
Kevin Wang
b942a6f494
chore: improve error when exporting metadata from client component (#46334)
<!--
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:
-->

This improves the ambiguous error seen when exporting `metadata` or
`generateMetadata` from a component marked with the `"use client";`
directive.

Example output from tests (`pnpm test-dev
test/development/acceptance-app/rsc-build-errors.test`)

```console
File path:
  app/client-with-errors/metadata-export/page.js
  console.log
    browser log: ./app/client-with-errors/metadata-export/page.js
    ReactServerComponentsError:
    
    You are attempting to export "generateMetadata" from a component marked with "use client", which is disallowed. Either remove the export, or the "use client" directive. Read more: https://beta.nextjs.org/docs/api-reference/metadata
    
       ,-[6:1]
     6 | 
     7 | // export const metadata = { title: 'client-metadata' }
     8 | 
     9 | export async function generateMetadata() { return { title: 'client-metadata' } }
       :                       ^^^^^^^^^^^^^^^^
       `----
    
    File path:
      app/client-with-errors/metadata-export/page.js
```

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] 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

- [x] 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: Jiachi Liu <inbox@huozhi.im>
2023-02-24 21:23:32 -08:00
JJ Kasper
725a4de0ef
Fix failing app-static deploy test (#46395)
x-ref:
https://github.com/vercel/next.js/actions/runs/4267518385/jobs/7429540548
2023-02-24 18:03:09 -08:00
JJ Kasper
4c6e8d480c
Add relative app dir field (#46393)
This adds a relative app dir field to the required files manifest so
that we don't rely on absolute paths from a cached build since the cache
can be restored in a separate context where the value no longer applies.

x-ref: https://github.com/vercel/next.js/pull/45864

## 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)
2023-02-24 16:51:07 -08:00
JJ Kasper
c5336132c3
Fix fetch cache key inputs and encoding (#46392
This ensures we properly filter caching on uncachable request methods by
default and correct encoding handling in edge runtime.

Fixes: https://github.com/vercel/next.js/issues/46349
x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1677253242022489)

## 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)
2023-02-24 16:44:47 -08:00
JJ Kasper
51f9f5df2b
Apply filtering after rewrite as well (#46390
x-ref: [slack
thread](https://vercel.slack.com/archives/C04MEB9L9RQ/p1677279320253929?thread_ts=1677255545.574209&cid=C04MEB9L9RQ)

## 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)
2023-02-24 15:57:30 -08:00
JJ Kasper
de47336613
Revert "Support server-only inside pages/api" (#46388)
Looks like this is breaking when run against `vercel-site`, going to revert temporarily to allow investigating further without blocking canary. 

Reverts vercel/next.js#46328
2023-02-24 22:16:34 +00:00
OJ Kwon
dee944bb0f
test(next-script): teardown next-dev instance via jest hooks (#46383)
<!--
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:
-->

Partially resolves WEB-628

This PR is minor improvement to the fixture setup for next-script test:
if one of test assertion using `finally` to teardown next instance
(next.destroy) times out, those clause won't be called so next instance
will leak, makes subsequent test fail. PR moves teardown to `afterEach`
hook instead. This relies on the assumption we run test in band
(serial), but internals of nextdevinstance already assumes it via its
own singleton.
2023-02-24 13:28:05 -08:00
Steven
0b248f81a1
fix: improve next.config.js validation for images prop (#46326)
This PR removes the custom validation in favor of json schema
validation.

Previously Next.js would print warnings on schema errors and only throw
when custom validation failed (albeit with a nasty stack trace).

### Before

<img width="1193" alt="image"
src="https://user-images.githubusercontent.com/229881/221045942-b035092b-1236-4da6-b676-58e3adae030d.png">

### After

<img width="794" alt="image"
src="https://user-images.githubusercontent.com/229881/221046100-fc0041b3-8fa8-4938-bd99-d0e3d3c0fae6.png">

---------
2023-02-24 13:08:24 -08:00
Shu Ding
130ab594cd
Support server-only inside pages/api (#46328)
This can be a special case for the API layer.

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

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

---------
2023-02-24 12:44:12 -08:00
Hannes Bornö
18232f6e75
Dedupe next/font preload tags (#46354)
Just like https://github.com/vercel/next.js/pull/44938 did for CSS tags,
this makes sure `app-render` will only render one preload tag per font
file by keeping track of the rendered files in a set while building the
component tree.

Tested locally with react, react-dom and react-server-dom-webpack with
version `18.3.0-next-4fcc9184a-20230217`.

## 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)
2023-02-24 19:28:27 +01:00
Balázs Orbán
9df7df137f
fix(ts): correctly augment next when typedRoutes: true (#46332) 2023-02-24 02:58:43 +00:00
JJ Kasper
66b82931a1
Handle same page reload case in filter (#46324)
Follow-up to https://github.com/vercel/next.js/pull/46317 this ensures
same page case is handled as well.

## 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)
2023-02-23 17:18:59 -08:00
Lee Robinson
4f0d76c40b
Migrate create-next-app and e2e tests to Metadata API. (#45819)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2023-02-23 23:40:06 +00:00
JJ Kasper
8ff3d7ff57
Fix client filter case with redirects (#46317)
Follow-up to https://github.com/vercel/next.js/pull/46283 this ensures we properly handle redirects with matchers at the base and we don't use the normalized redirects when generating the filter as the breaks with i18n. 

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

## 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)
2023-02-23 20:14:57 +00:00
JJ Kasper
1bd84f5827
update test setup 2023-02-23 09:36:18 -08:00
JJ Kasper
99a7a34f96
Ensure generateStaticParams works in route (#46310)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1677165000745519)

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

---------

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
2023-02-23 18:33:08 +01:00
Steven
604b0129c3
fix: lazy load dynamically generated next/image in Safari Firefox (#46306)
- Fixes https://github.com/vercel/next.js/issues/46019
- Related to https://github.com/facebook/react/issues/25883

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-23 11:44:07 -05:00
Shu Ding
bcb20100db
Fix error on 404 page when middleware exists (#46303)
Closes #44293.

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

## 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)
2023-02-23 15:55:58 +00:00
JJ Kasper
5792533781
Update app cache handler loading (#46290
Follow-up to https://github.com/vercel/next.js/pull/46287 this updates
how we load the cache handler for the incremental cache so it's
compatible with edge and also adds regression testing with a custom
handler.
2023-02-23 01:19:59 -08:00
JJ Kasper
6d25125ff1
Update app dir cache heuristics (#46287)
x-ref: https://github.com/vercel/next.js/pull/46271
x-ref: https://github.com/vercel/next.js/pull/46081
2023-02-23 07:59:38 +00:00
JJ Kasper
1149cccd94
Add client router filter handling (#46283)
This adds a new client router filter for app paths and redirects so that
we correctly hard navigate when a transition for one of this paths is
encountered. This fixes the longstanding issue where redirects weren't
applied on the client so a redirect that matches a dynamic route as well
would transition to the dynamic route on client transition but not on
direct visit. Similarly this ensures we hard navigate to app paths from
pages even if a page dynamic route matches the path.

The specific filter leveraged here is a bloom filter as we can tolerate
some false matches (currently targeting an error rate of `2%`) as they
just trigger a hard navigation which should be acceptable and this also
avoids needing to send an entire manifest with the related paths.

We can leverage a manifest for the generated SSG paths as well in a
follow-up to fix `fallback: false` routes not being navigated correctly
on client-transition in some cases as well.


The filter is initially behind an `experimental.clientRouterFilter` flag
in `next.config.js` although this is auto-enabled when leveraging app
directory to ensure proper transitions.

fixes NEXT-609
closes: https://github.com/vercel/next.js/pull/46235
x-ref: [slack
thread](https://vercel.slack.com/archives/C035J346QQL/p1677028663246719)

x-ref: https://github.com/vercel/next.js/issues/41344
x-ref: https://github.com/vercel/next.js/issues/40062
x-ref: https://github.com/vercel/next.js/issues/37889
x-ref: https://github.com/vercel/next.js/discussions/26426
x-ref: https://github.com/vercel/next.js/issues/35837

## 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)
2023-02-22 22:02:31 -08:00
Steven
c700548638
chore: refactor image optimization tests (#46269)
This is a small refactor to image optimization tests. Previously, the
`ctx` object was used for input options as well as next.config.js
options but this PR separates the latter into `nextConfigImages`.
2023-02-23 01:43:55 +00:00
Shu Ding
19240383b0
Improve type checking (#46276) 2023-02-23 00:37:19 +01:00
Shu Ding
ff05d9b7b5
Skip pre-rendering the default param when no params are provided (#46265)
Closes #45850.

## 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: JJ Kasper <jj@jjsweb.site>
2023-02-22 14:59:19 -08:00
Steven
57d2963507
feat: add contentDispositionType config to Image Optimization API (#46254)
Add `contentDispositionType` config to Image Optimization API so the user can configure `inline` vs `attachment`.

This is recommended when `dangerouslyAllowSVG` is enabled but can also be used when its disabled.
2023-02-22 19:56:51 +00:00
Hannes Bornö
d38035ccf1
Make build error urls clickable (#46251)
Makes urls in build errors clickable by turning them into `<a>`. Reuses the `<HotlinkedText />` component in build errors that previously only was used in runtime errors.  Also fixes an error that made the links break if they had `\n` before or after the url.

Fixes NEXT-586

## 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)
2023-02-22 18:35:38 +00:00
Jiachi Liu
ab123c1e7c
Add test for next-found and redirect for metadata (#46248)
Add tests for using `redirect` and `notFound` in `generateMetadata`
2023-02-22 18:54:14 +01:00
Jiachi Liu
65ecd9c3e2
Fix missing metadataBase for static tw,og image resolving (#46243)
Replacement for #46156
Closes NEXT-587

* `metadataBase` will always need to be provided for twitter image and
opengraph image
* Fixing the metadataBase isn't picked up by static og/twitter images

## 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)
2023-02-22 14:21:52 +01:00
Luba Kravchenko
9d2824e995
Update app dir cache handling (#46081)
Updates handling for app dir caching for edge runtime and adds additional tests. 

x-ref: NEXT-511

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-02-22 07:10:25 +00:00
JJ Kasper
aa7cc31b6c
Fix app-dir vary test in deploy mode (#46224
x-ref:
https://github.com/vercel/next.js/actions/runs/4238645116/jobs/7366078010
2023-02-21 18:51:57 -08:00
Steven
0b563e86de
fix: image optimization content-type (#46219)
Upstream images can have any arbitrary `content-type` header so this PR
normalizes the value before checking it.
2023-02-21 18:00:14 -08:00
Hannes Bornö
b8837ad636
fix file name in next/font unresolved import error (#46187)
Use the actual file name in the overlay when a local font can't be resolved.

Before
![image](https://user-images.githubusercontent.com/25056922/220339649-86d1ede7-178e-4d88-820a-0eda6bd7ba18.png)

After
![image](https://user-images.githubusercontent.com/25056922/220339492-1d5a755f-5393-4121-b30d-32b49574035a.png)

Fixes NEXT-600

## 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)
2023-02-22 01:48:56 +00:00
JJ Kasper
44c5886cf6
Breakup telemetry test further (#46218
x-ref:
https://github.com/vercel/next.js/actions/runs/4237778783/jobs/7364168054
2023-02-21 17:26:21 -08:00
Tim Neutkens
5160aa72a9
Fix route.js trailingSlash handling (#46185)
<!--
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:
-->

Fixes NEXT-598

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] 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: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-21 17:19:56 -08:00
Jan Kaifer
16aa8e9b7e
fix: CNA issues when using @/ in custom import alias (#46184)
unrelated changes:
- add missing await
- fix TYPO in test comment


This issue was caused by the fact that we have been replacing `@/` ->
`[importAlias]` even in tsconfig.json itself.

fixes #45884
2023-02-21 16:45:32 -08:00
Dylan Staley
3615ede703
fix: don't append domain to absolute urls when using i18n (#46201
<!--
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:
-->

When passing absolute URLs to `<Link>` on a Next.js site using
Internationalized Routing, the site's domain will be prepended to the
URL, causing broken links. This PR checks if the provided URL is an
absolute URL, and if so, skips the logic that prepends the domain.

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

## 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)
2023-02-21 16:27:14 -08:00
Jiachi Liu
ccdc836713
Fix flaky script test (#46211)
x-ref:
https://github.com/vercel/next.js/actions/runs/4198362898/jobs/7282523186
2023-02-21 15:52:40 -08:00
JJ Kasper
1253a3035f
Add ISR handling for app routes (#46133)
Follow-up to https://github.com/vercel/next.js/pull/45716 this updates
the ISR handling for app routes. This also ensures the E2E deploy tests
are running for the `app-routes` test suite.

fixes NEXT-509

Relies on https://github.com/vercel/vercel/pull/9489

---------
2023-02-21 15:25:42 -08:00
Shu Ding
7af4308b11
Fix handle extracted CSS modules without layer info (#46200)
Closes #46091. As explained in the comments, in certain cases CSS
extracted via mini-css-extract-plugin doesn't have layer info attached
and we can't simply skip them. Since this is more of an optimization,
it's fine to add a special case for CSS.

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

## 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>
2023-02-22 00:02:48 +01:00
Hannes Bornö
a5ef594a1a
Update flaky dev tests (#46179)
ref:
[slack](https://vercel.slack.com/archives/C04DUD7EB1B/p1676914009577859)

## 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: JJ Kasper <jj@jjsweb.site>
2023-02-21 14:28:25 -08:00
JJ Kasper
185a8921c8
Fix turbopack route resolver (#46206
This ensures we correctly handle the new route matchers with turbopack.
Also updates the custom-routes test suite to allow it to run against
turbopack although relies on changes in
https://github.com/vercel/turbo/pull/3894 for the tests to run
correctly.
2023-02-21 13:53:20 -08:00
Shu Ding
0ab8dcb09d
Fix client boundary defined in a module (#46171)
This PR fixes the bug where a client boundary (`"use client"`) is defined in a module (`"type": "module"`). Currently Next.js throws this error:

```
error - Error: Cannot find module 'private-next-rsc-mod-ref-proxy'
```

...that will be resolved with this PR.

The only limitation after this fix is, you can't have `export *` under a client boundary in a module. Added a error message for that.

NEXT-595

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

## 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)
2023-02-21 15:20:45 +00:00
Hannes Bornö
9e86fd1d58
Fix "use client" in pages dir errors (#46191)
When in the pages dir, the compiler errors where the `"use client"` directive is used incorrectly should tell the user how to fix the error - not just say:
```
You have tried to use the "use client" directive which is not supported in the pages/ directory.
```

This removes those cases and instead displays the same error as in the app dir. However, if you try to import something that requires it to be a Server Component, the pages error is still:
```
That only works in a Server Component which is not supported in the pages/ directory.
````

ref: [slack](https://vercel.slack.com/archives/C035J346QQL/p1676983422753729)

## 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)
2023-02-21 14:07:41 +00:00
JJ Kasper
c765fadfbe
Update CI test setup (#46138
This updates our CI testing flow to only run against LTS Node.js version
on PRs and then run against the maintenance Node.js version when cutting
a release. This will allow speeding up PR test runs to get feedback
faster and remove un-necessary duplicate testing as it's very rare a
change breaks the maintenance Node.js version but not the LTS version.
2023-02-20 16:33:36 -08:00
Jiachi Liu
888384c5e8
Add icon descriptor property media and fetchPriority (#46149)
* Add `fetchPriority` and `media` property to icon descriptor
* Add more jsdoc

Closes NEXT-544
Fixes https://github.com/vercel/next.js/issues/45859

Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2023-02-20 22:27:55 +00:00
Jimmy Lai
bee51b6c87
feat: add instrumentation hook (#46002)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-02-20 19:04:09 +01:00
Hannes Bornö
b3f3bf59b9
Improve app-render error log with edge runtime (#46157)
`app-render` server errors aren't logged correctly with the edge runtime. This adds logging of a filtered stack trace.

Before
![image](https://user-images.githubusercontent.com/25056922/220144922-06aba048-0166-4114-8421-8f61e6137d5e.png)

After
![image](https://user-images.githubusercontent.com/25056922/220145019-83c1cf80-d6c7-4ce0-b76f-201265c7fafb.png)

Still some improvements left to figure out. This change doesn't log the original stack frame, and the `Log.error` is not printed with a red text like it should be.

Fixes NEXT-593

## 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)
2023-02-20 16:24:15 +00:00
Hannes Bornö
9b2e3c5ec7
Use next/font in create-next-app (#45897)
Rmove `@next/font` package and use `next/font` in create-next-app.

Fixes NEXT-484

## 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)
2023-02-20 16:42:18 +01:00
Hannes Bornö
a9b56610e1
Send correct stats in hot reloader sync event (#46150)
If there's a build error on initial page load, the error is sometimes displayed as a server error instead of a build error:
![image](https://user-images.githubusercontent.com/25056922/220099125-5f538551-342f-4bca-a670-a04d8428de2d.png)

When the hot reloader sends the `sync` event to the client, it always picks the latest compilation. The problem occurs if only the server has errors and the client is the latest. In that case the server errors are ignored and the client stats are sent instead.

This PR makes it check if the server compilation has errors, if that's the case we use those stats. `built` events acts the same, new client builds are [ignored if the server has errors](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/dev/hot-middleware.ts#L123.): 
```ts
onClientDone = (statsResult: webpack.Stats) => {
  this.clientLatestStats = { ts: Date.now(), stats: statsResult }
  if (this.closed || this.serverLatestStats?.stats.hasErrors()) return
  this.publishStats('built', statsResult)
}
```

Fixes NEXT-403

## 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)
2023-02-20 12:55:29 +00:00
Jiachi Liu
2f967ccd48
Detect invalid metadata exports errors in next-swc (#46077)
* Use next-swc to detect invalid metadata exports
* In client components page under app dir, metadata exports are not
available
* In server components page under app dir, metadata and gM exports can
be exported together

Move sync metadata / async metadata typing resolving test to UT

Closes NEXT-368

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-19 08:36:50 +01:00
Tim Neutkens
28eb15f6c6
Fix manifest error when using route.js (#46102)
This ensures there is no client component entry created for route.js.
@shuding is going to investigate further why this would break the
manifest generation in development.


Fixes #45956
Fixes NEXT-588

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

## 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)
2023-02-18 20:31:49 +01:00
Shu Ding
be2d413600
chore: Rename internal Webpack plugin (#46088)
Rename `FlightTypesPlugin` to `NextTypesPlugin` as it's more general now (handles https://beta.nextjs.org/docs/configuring/typescript#statically-typed-links as well).

`test/integration/app-link-types` was a non-existing test that I accidentally committed previously.

## 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)
2023-02-18 19:12:20 +00:00
Hannes Bornö
70c087e4cf
Fix flaky invalid import test (#46089)
<!--
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:
-->

## 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)
2023-02-18 12:33:06 +01:00
Shu Ding
0fe793f51c
Add vary header to responses from pages and Edge SSR (#46073)
This PR ensures that the `vary` header is set for pages responses and
Edge SSR responses too, to avoid potential caching problems when
navigating between them.

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

## 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: JJ Kasper <jj@jjsweb.site>
2023-02-17 22:54:48 -08:00
Hannes Bornö
bac00ba7d7
@next/font migration warning (#46036)
Print warning with migration instructions if `@next/font` is in deps.

Fixes NEXT-483

## 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: Tim Neutkens <tim@timneutkens.nl>
2023-02-17 16:39:26 +01:00
Tim Neutkens
ae3442c37a
Fix RSC navigation when overriding headers in middleware (#46049)
Fixes NEXT-583

Ran into this when looking into adding an integration test for the RSC
normalizing PR.

Middleware has the ability to override `headers` which causes
client-side navigation to break as it'll remove the `rsc` header which
causes Next.js to respond with the HTML response instead of the RSC
payload.

This PR ensures the RSC headers are always copied over as middleware
does not get access to them.

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

## 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)
2023-02-17 16:34:35 +01:00
Balázs Orbán
c16e28715f
feat: show version staleness in error overlay (#44234)Co-authored-by: Sukka <isukkaw@gmail.com> Co-authored-by: Steven <steven@ceriously.com> Co-authored-by: Hannes Bornö <hannes.borno@vercel.com> Co-authored-by: Hannes Bornö <borno.hannes@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Supersedes #37750 as the overlay has been refactored and moved into the
Next.js package itself.

If it detects an older major version, it will show "outdated". Older
minor shows "out of date". Old canary will show "out of date", with a
different message. Matching latest canary or latest will show "up to
date". It will show nothing if we could not detect the versions due to
some error.

<details>
<summary>States: Fresh, stale, outdated</summary>

Fresh:

![image](https://user-images.githubusercontent.com/18369201/208972067-8f2bd8d5-bb92-440a-a3aa-0685b18b4871.png)


Stale:

![image](https://user-images.githubusercontent.com/18369201/208971789-baec0b90-718a-4cdc-bb15-ed23ce5efcbc.png)


Outdated:

![image](https://user-images.githubusercontent.com/18369201/208972153-923ab865-e0f7-405d-9411-45ad1f545d0e.png)

</details>

Fixes NEXT-316

---------

Co-authored-by: Sukka <isukkaw@gmail.com>
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Hannes Bornö <hannes.borno@vercel.com>
Co-authored-by: Hannes Bornö <borno.hannes@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-17 16:18:28 +01:00
Balázs Orbán
be5a9f53a8
chore(deps): use external @edge-runtime/cookies (#42736)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-02-17 15:10:09 +01:00
Jiachi Liu
15aa25f27a
Refactor freezing metadata while resolving and fix title merging (#45965)
Addressing @gnoff 's comments from #45923

* Only freezing for the parentMetadata `argument`
* Group dev specific code in one place for less branches and better DEC
* Concurrently run the metadata resolving promises

Fix title merging: should use the parent layout instead of adjacent
layout
2023-02-16 17:02:39 -08:00
OJ Kwon
9b91fd5a08
test(integration): emits successful test output for continue on error (#46008)
<!--
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:
-->

- closes WEB-600
- partially resolves WEB-544

This PR applies minor ergonomics changes to the test runner. First,
allows to emit successful test reports if continue_on_error is enabled:
this allows to track total test stats with --turbo runs. Secondly allows
to specify custom timeouts for the e2e - as written in comment otherwise
it can exceed total 6 hours of job limit due to having lots of
timeout-related failing tests.

## 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)
2023-02-16 15:44:38 -08:00
Jiachi Liu
ee0cbeceb7
Fix metadata manifest field rendering (#46004)
x-ref:
https://github.com/vercel/next.js/pull/45945#issuecomment-1433278890

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

---------
2023-02-16 15:29:28 -08:00
Gal Schlezinger
282c1a0637
[edge] support edge-light exports when bundling edge functions (#45188)
This PR implements `edge-light` as a main field for bundling edge
functions as defined in https://runtime-keys.proposal.wintercg.org

Resolves EC-614

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

---------
2023-02-16 13:30:34 -08:00
JJ Kasper
f3b231ccf1
Fix folders included in trace (#46011)
We should not include directories themselves in the trace files so this
ensures they are excluded and adds a test case for this.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1676568891229219?thread_ts=1676543026.736539&cid=C03S8ED1DKM)

## 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)
2023-02-16 12:45:08 -08:00
Tim Neutkens
5599c47ed6
Add edge support for route handlers (#45990)
- Add test for edge route
- Add edge route loader
- Ensure edge route does not trigger static generation
- Remove unused import
- Use new loader during compilation
- Add names for routeKind to help debugging
- Ensure route is considered a appDir page
- Return response from edge runtime
- Handle edge route in dev and prod

Fixes NEXT-510

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

## 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)
2023-02-16 16:32:37 +01:00
Tim Neutkens
ffee09b6ff
Move initial head (#45695)Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Move initial into the cache, so the top level boundaries will wrap the
head contents. Then we can use navigation API like `notFound` in the
`generateMetadata`, the notFound errors could be still captured in that
case

Closes NEXT-292

Added tests for not found in metadata

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-02-16 16:26:48 +01:00
Hannes Bornö
435eca3fc5
Add next/font import (#45891)
Enables using `next/font` by adding `@next/font` as a dependency and
reexporting its loaders.

Always generates the `font-loader-manifest` as we can't know beforehand
if the user intends to use `next/font` or not.

Also adds telemetry for `next/font` usage.

The tests are updated to use `next/font`. But `@next/font` is tested in
`test/e2e/next-font/index.test.ts` and `test/e2e/app-dir/next-font` as
well to ensure it doesn't break.

Fixes NEXT-351

## 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)
2023-02-16 15:33:39 +01:00
Hannes Bornö
0484dc4097
Use metadata API in automatically created root layout (#45938)
Use the Metadata API instead of creating a `head.js` when automatically
creating a root layout. The generated layout is the same as the one in
https://github.com/vercel/next.js/pull/45819, but with a different title
and description.

Automatic root layout:
```tsx
export const metadata = {
  title: 'Next.js',
  description: 'Generated by Next.js',
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}
```

Fixes NEXT-545

## 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)
2023-02-16 15:17:58 +01:00
JJ Kasper
3e919b6add
Fix flakey app cli output checks (#45960)
x-ref:
https://github.com/vercel/next.js/actions/runs/4186567737/jobs/7255320047
2023-02-15 11:33:17 -08:00
Jiachi Liu
9101440020
Metadata fields improvements (#45945)
Resolves the comments from beta docs

* fix typing of `metadata.authors` rendering
* add `metadata.manifest` field

## 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)
2023-02-15 17:35:50 +00:00
Quinn Rohlf
af6c26ccc9
Stop overriding the user's TS config with defaults during next build (#45670)
## Bug

The `next build` command is silently overriding the user's tsconfig when
it shouldn't be; this results in mismatched behavior between `tsc
--noEmit` and `yarn build` and user confusion.

For example, a configuration option like `"moduleResolution":
"nodenext"`, which is preserved and respected by `next dev`, will be
silently overridden to `"moduleResolution": "node"` during `next build`.

This change:
- Fixes #38854
- (probably fixes) #45452 (I have not verified)
- (probably fixes) #41189 (I have not verified)

## Details

Next has a concept of both _defaults_ and _permitted options_ when
modifying/validating the user's tsconfig. The user's config is only
modified if it does not match the _permitted options_. This means that
if the user has specified a permitted value like `"moduleResolution":
"nodenext"`, it will not be overwritten in the user's config file.

However, there was some logic in `runTypeCheck.ts` that did not
adequately capture this nuance – instead, it spread all of the defaults
into the tsconfig it was building before running typecheck, which meant
that if a user had specified an option that was _permitted_ but
_non-default_, it would be overwritten, silently, during `yarn build`
only.

Because Next is already (1) rewriting the TSconfig in
`writeConfigurationDefaults` when the user's config doesn't line up with
what we're expecting and (2) verifying the user's TSConfig remains
correct (in `verifyTypeScriptSetup`) during a `next build`, I believe
that it is safe to remove this config-steamrolling behavior.

## Documentation / Examples

I believe this is strictly a bugfix; it updates the behavior of `next
build` to conform to the same configuration behavior exhibited by `tsc
--noEmit` and `next dev`. Since this is already the user expectation, it
should not require documentation changes.

---------

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-15 18:11:00 +01:00
Hannes Bornö
087aa6e83e
Log dev error in Server Router (#45951)
Fixes NEXT-561

## 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)
2023-02-15 17:09:48 +00:00
Shu Ding
430f1b8c9b
Improve type checking with tests (#45940)
Closes #45088.

Rewrite the type guard implementation, it now works via 2 parts:

- `Diff<A, B>` this makes sure that `B` is either `any` or extends `A`, and then excludes all fields in `A` from `B`, only keeps the extra fields
- `checkFields<X>()` ensures that `X` doesn't have any fields

So with `checkFields<Diff<ExpectedInterface, Interface>>()` we can ensure that it is a valid interface and it does not have extra fields. For functions, we use the same utility to check parameter types and return types.

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

## 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)
2023-02-15 14:49:45 +00:00
Jiachi Liu
2b2c7462cd
Freeze resolved metadata object in dev mode (#45923)
In dev mode, instead of `resolve(resolvedMetadata)` for the parent metadata argument we pass down `resolve(freeze(deepClone(resolvedMetadata)))` as parent metdadata, this approach will avoid users mutating resolved metadata manually but still allowing next manage to merge it during resolving

Closes NEXT-559

- [x] linked task
- [x] e2e tests
2023-02-15 13:49:34 +00:00
Joe Freeman
73065bebe7
fix(link): do not reload when Link is in svg (#41320)Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
<!--
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`

I believe this fixes `<Link>`s that appear inside an `<svg>`. For
example:

```typescript
<svg width={200} height={200}>
  <Link href="/about">
    <a>
      <text x={0} y={20}>About</text>
    </a>
  </Link>
</svg>
```

There's a comment in `next/link` (["anchors inside an svg have a
lowercase
nodeName"](bef709bc74/packages/next/client/link.tsx (L163)))
that implies `Link`s are supposed to work inside an `svg`, but at the
moment, I'm finding that clicking the link causes a full page reload.

This seems to be because Next.js considers the link to be a 'modified'
event (as per `isModifiedEvent`). In the case where the event's
`currentTarget` is an `SVGAElement` (rather than a `HTMLAnchorElement`),
the `event.currentTarget.target` is actually an
[`SVGAnimatedString`](https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimatedString).
This looks a bit like `{"animVal": "", "baseVal": ""}`, so the `(target
&& target !== '_self')` check is truthy.

Using
[`getAttribute`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute)
instead seems to consistently give a string value in either (SVG or
HTML) case.

I've attempted to add a test, but I haven't worked out how to run it
yet...

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-02-15 11:05:10 +01:00
JJ Kasper
778a2a7442
Fix app routes on deploy (#45931)
Follow-up to https://github.com/vercel/next.js/pull/45716 this ensures
we correctly construct the initial URL value as it must be a fully
qualified URL. Existing tests caught this failure when running in deploy
mode.
2023-02-15 09:54:39 +01:00
JJ Kasper
7d8f85bd8d
Update E2E deploy tests (#45929)
Updates test cases that aren't expected to work for deploy mode at the
moment.

x-ref:
https://github.com/vercel/next.js/actions/runs/4180235531/jobs/7241206278
2023-02-14 20:00:58 -08:00
Hannes Bornö
1127df4d6a
Make app-render error logging less verbose in dev (#45472)
Make the app-render error less verbose in dev. Reuse
`logErrorWithOriginalStack` from the dev server but hide frames from
`node_modules`, `next/dist/compiled` and `node:internal` if we're in the
app directory. Also removes `webpack-internal` from the frame file name.

<details>
<summary>Before</summary>


![image](https://user-images.githubusercontent.com/25056922/215798020-9aea3401-95dd-4f09-9e4c-26d822c0ce38.png)
</details>

<details>
<summary>After, with source</summary>


![image](https://user-images.githubusercontent.com/25056922/216609074-66039be9-f599-47af-8c5d-b64a6be503ab.png)
</details>

<details>
<summary>After, no source</summary>


![image](https://user-images.githubusercontent.com/25056922/216608526-46ada990-7e6f-4c9e-b1d3-347ebb03f6fa.png)
</details>

<details>
<summary>For comparison, from `pages/`</summary>


![image](https://user-images.githubusercontent.com/25056922/216610761-dd87e5e6-1e9c-4b41-8adf-650cf15464e3.png)
</details>

Fixes NEXT-441

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

---------
2023-02-14 18:46:30 -08:00
JJ Kasper
24186f51c4
Use latest CLI for E2E tests (#45925)
Ensures we're testing against the latest version of the CLI even if it
hasn't been rolled yet to catch regressions faster.

x-ref:
https://github.com/vercel/next.js/actions/runs/4176809448/jobs/7235660705
2023-02-14 18:43:29 -08:00
Shu Ding
e50d22b992
Include tsconfig.json in tests (#45879)
As per
https://github.com/vercel/next.js/pull/45670#issuecomment-1428729000,
it's very necessary to include `tsconfig.json` in our tests as we need
to test specific TS configurations sometimes.

## 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)
2023-02-14 18:37:09 -08:00
Hannes Bornö
c01f8da559
Improve server-only imported in external package error (#45749)
Fail at build time with helpful message instead of getting a runtime error when external package imports 'server-only' in a Client Component.

Before
![image](https://user-images.githubusercontent.com/25056922/217865154-57fd821c-9502-4e0a-a31c-19f2f89b5847.png)


After
![image](https://user-images.githubusercontent.com/25056922/217864843-b30702e7-38c7-4edc-b42a-31a2eb3a301f.png)

Fixes NEXT-494

## 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)
2023-02-15 01:54:41 +00:00
Wyatt Johnson
cdf1d52d9a
next/navigation Typescript support for pages/ (#45919)
When you're trying to migrate an application from `pages/` to `app/`,
you'll need to access data like search parameters and the pathname in a
way that lets you migrate safely.

This adds support for dynamic typing of some of those exported functions
from `next/navigation`, namely `useSearchParams` and `usePathname`.
Currently, `searchParams` can’t be known when prerendering if the page
doesn’t use [Server-side
Rendering](https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props)
in the `pages/` directory. `pathname` can’t be known during prerendering
if the page is a fallback page or has been automatically statically
optimized when accessed from `pages/`.

To make migraitons easier, this adds a new feature to `next dev` that
will automatically add the correct types for `next/navigation`. It does
this by checking if you have both a `app/` and `pages/` directory. If it
detects you have a `app/` directory, it will also enable the suggested
Typescript feature,
[`structNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks)
which will warn developers when trying to access a value that may be
`null`.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-02-14 17:26:01 -08:00
Shu Ding
c8fe390041
Rename manifest file names (#45877)
Here we rename names of manifest files to align better with React.

## 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)
2023-02-15 01:03:17 +00:00
Hannes Bornö
4eb55d0ff6
Use details tag in collapsed call stacks (#45907)
Currently the collapsed frameworks uses a `<button>` and React to
show/hide the frames in the error overlay. This change utilizes the
native `<details>` tag instead to achieve the same behaviour.

The default `<details>` arrow is hidden to preserve the same look:

![image](https://user-images.githubusercontent.com/25056922/218769518-fc5ad1ef-fa1a-4d18-8027-adb24b870089.png)

Fixes NEXT-546

## 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)
2023-02-14 16:31:59 -08:00
Jiachi Liu
4ef0bcc779
test: update flaky app dir test (#45921) 2023-02-14 16:18:21 -08:00
Wyatt Johnson
74ca99c866
Server Router Improvements (#45716)
This adds updated matching handle for the server to separate out the matching and executing of different route types e.g. page routes, API routes, and app routes. 

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-02-15 00:16:45 +00:00