Commit graph

13383 commits

Author SHA1 Message Date
Hannes Bornö
584d842ae0
Fix @next/font imports from outside of the root directory (#42678)
Similar to https://github.com/vercel/next.js/pull/42106. Make
`@next/font` works as expected when using `transpilePackages`.

Also makes sure `@next/font` is auto-configured correctly when in a
monorepo.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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>
2022-11-09 13:22:45 -08:00
Nathan Hammond
c962f2d6a4
Adopt script rejection pattern for link onerror. (#42645)
The HTML `<link>` element's `onerror` function receives an Event-shaped object. The rejection here expects an `Error` shaped object. This PR 1:1 adopts the same pattern for `<link>` `onerror` that `script` `onerror` uses.

Attached you'll see an image that demonstrates that it _can_ end up in this state from turbo.build's Sentry logs:
<img width="919" alt="Screen Shot 2022-11-09 at 2 43 11 AM" src="https://user-images.githubusercontent.com/20542/200648928-12b85642-c9b5-4d7e-b4fe-2b2d420a6669.png">
2022-11-09 19:58:20 +00:00
Adem ilter
c1b76bd36d
example fix url (#42695)
Co-authored-by: Steven Tey <stevensteel97@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-11-09 12:51:22 -06:00
Hannes Bornö
bb200b922d
@next/font error messages (#42689)
Fix wrong links. Add specific error message if Next.js version < 13.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-09 10:32:32 -08:00
Oleg Zuev
5e55c3c340
Remove useless async declaration and replace regexp to plain string in AMP postProcessor (#42495)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-11-09 17:58:25 +01:00
Bobby Lee
fcfe914b62
fix typo in api-reference next/sever (#42669)
fix typo ResponseCooies to ResponseCookies
2022-11-09 05:13:49 +00:00
JJ Kasper
77b5f79a4d
v13.0.3-canary.2 2022-11-08 18:59:53 -08:00
Balázs Orbán
fa916e4e67
chore: encourage adding reproductions to issues (#42667)
Issues being reported without a reproduction take longer to
triage/resolve. To make the process faster, we should encourage people
always to add one.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 17:44:25 -08:00
JJ Kasper
0cf3e4cc7c
Add missing matcher support (#42660)
This adds support for a `missing` field which is complimentary to `has`
to only match when `query`, `header`, or `cookie` values are not
present. The `missing` field can be applied for middleware matchers as
well to prevent running middleware when these fields are present.

x-ref: https://github.com/vercel/vercel/pull/8874
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1667935428788529?thread_ts=1667850697.542269&cid=C03S8ED1DKM)
x-ref: https://github.com/vercel/next.js/discussions/25653
x-ref: https://github.com/vercel/next.js/issues/34046
x-ref: https://github.com/vercel/next.js/issues/28185
x-ref: https://github.com/vercel/next.js/issues/25930
x-ref: https://github.com/vercel/next.js/issues/24608
x-ref: https://github.com/vercel/next.js/pull/27431

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 16:48:27 -08:00
Artem
1f6c0d0f57
chore: update scripts to work on windows (#42632)
Update `package.json` for Windows users.
1. `concurrently` isn't working with single quotes 🤷🏻
2. `--watch` isn't actually passed, because of that `tailwind` compiles only once and exits.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 19:43:45 +00:00
Hannes Bornö
069692079b
@next/font/google fetch error dev (#42637)
If `@next/font/google` fails to fetch the font in DEV, return the
fallback font instead of throwing so you still can run the app. In build
it still throws.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 11:05:54 -08:00
JJ Kasper
85b200a82d
Ensure skip normalize is handled correctly (#42642)
x-ref: [slack
thread](https://vercel.slack.com/archives/C01224Q5M99/p1667927545637489?thread_ts=1664536480.045539&cid=C01224Q5M99)
x-ref: https://github.com/vercel/vercel/pull/8873

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 10:40:22 -08:00
Josh Story
677c04f088
update react builtin deps for next channel (#42639)
Updates builtin react to latest release on next channel

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 10:35:17 -08:00
Jimmy Lai
bccf186145
feat: add --no-mangling to next build + fix --profile option (#42633)
This PR adds a `--no-mangling` option to `next build` and fixes the `--profile` option so that you can use the React profiling build on production.

The advantage of disabling only mangling versus disabling minification altogether is that we still run terser and still benefit from DCE with this approach, so the `--no-mangling` does not impact performance as much.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 17:53:29 +00:00
Hannes Bornö
25d5d8c2e9
Also create head when creating root layout (#42571)
When creating a root layout automatically in dev - also create a default
head file.

This PR also makes sure more cases are covered when creating root
layouts by trying to find an available dir as close to `
app/` as possible that won't affect other layouts.
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 09:14:14 -08:00
Hannes Bornö
81890c8cfb
Add telemetry for @next/font (#42579)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 09:02:26 -08:00
Rishabh Poddar
90ddc248a5
(with-supertokens example): Fixes infinite redirect issue for unauthorised error during SSR (#42634)
If there is an unauthorised error during `getServerSideProps`, then we
return the same response as the try refresh token error so that all
cookies are cleared from the frontend due to refreshing failure.

If we did not do this, it would cause an infinite loop if the session
was removed in offline mode as the frontend would still think that the
session exists, and would redirect back to the protected route which
would fail verification again.
2022-11-08 07:58:04 -08:00
Tim Neutkens
5af7af5fa0
Add lazy initialize of router cache nodes (#42629) 2022-11-08 16:32:06 +01:00
Shu Ding
601e964e16
Colocate styles with special entries (#42506)
This PR ensures that in app dir, styles imported in loading.js,
error.js, not-found.js, and template.js are properly handled and
rendered together with these components.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [x] Integration 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`

## 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>
2022-11-08 14:49:13 +01:00
Jiachi Liu
f975e3f7ff
Replace global with globalThis (#42627)
`globalThis` is available since node12 which becomes a preferrence
rather than `global`. Besides, in the client components like
`next/image` or async hooks we should prefer to use `globalThis` since
`global` isn't available in browser
2022-11-08 14:45:30 +01:00
Shu Ding
bc4dd732ce
Include @prisma/client in default external packages (#42624)
As per https://twitter.com/shadcn/status/1589667660505427968.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-08 13:06:39 +01:00
JJ Kasper
13126d464c
v13.0.3-canary.1 2022-11-07 17:45:59 -08:00
JJ Kasper
aa7d2776cc
Ensure build trace ignores apply correctly when nested (#42606)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1667821787658109?thread_ts=1667480066.387989&cid=C03S8ED1DKM)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
2022-11-07 17:43:58 -08:00
Max Leiter
2e3e56d911
docs/next/link: Mention middleware + dynamic routes changes (#42607)
Documents the next 13 changes requiring `as` and `href` using `next/link` with Dynamic Routes.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm build && pnpm lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-11-08 00:45:01 +00:00
Tim Neutkens
2358e9c296
Rename RSC and Router headers (#42482)
Removes the `_` prefix from the RSC and Router headers as nginx strips
`_` prefixed headers by default.

Fixes #42164

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

## 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`
- [ ] Integration 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`

## 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)
2022-11-07 16:35:32 -08:00
OJ Kwon
c5bccf4d1b
fix(next/dev): bubble up unhandled exception from --turbo (#42594)
<!--
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:
-->

This PR fixes `--turbo` can shallow some of unhandled exception, trying
to catch and proceed as much as it can.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-07 14:20:10 -08:00
Max Proske
6f136f6a7e
Convert with-absolute-imports example to TypeScript (#42529)
Converted example to TypeScript to match Contribution docs.

- ~~Renamed `with-absolute-imports` example to
`absolute-imports-and-aliases` to match Contribution docs~~
- ~~Replaced deprecated example with a `README.md` file~~
- Used module path aliases in example, to help developers decide which
import strategy to use

## 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: JJ Kasper <jj@jjsweb.site>
2022-11-07 14:19:42 -08:00
JJ Kasper
22b449ba56
Fix default value handling for CNA in CI (#42596)
Fixes: https://github.com/vercel/next.js/issues/42592

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
2022-11-07 14:02:34 -08:00
Alex Kirszenberg
7bbc1aec9a
Aggregate updates using addStatusHandler and Promise.resolve instead of setTimeout (#42350)
The current `setTimeout` logic adds a constant overhead of 30ms when applying updates, which slows down HMR. As @sokra suggested, we can use the `addStatusHandler` API to have the HMR runtime let us know when its status changes. This also switches to `Promise.resolve` for update aggregation.
2022-11-07 21:06:18 +00:00
Shu Ding
5b5e4221d0
Fix relative TypeScript path in monorepos (#42586)
When under a monorepo, it's possible that the installed TypeScript isn't under `./node_modules/typescript`, and hence the `tsdk` option for VS Code won't work correctly. This PR fixes that to ensure the path is correct.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-07 20:24:52 +00:00
Tim Neutkens
0341fb7392
Fix scrolling on router.refresh (#42583)
Accidentally returned `true` in this case whereas all others are
`false`.

Fixes
https://github.com/vercel/next.js/discussions/41745#discussioncomment-4075803.

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

## 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`
- [ ] Integration 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`

## 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)
2022-11-07 11:49:29 -08:00
Edward Thomson
8dea5b0e22
[docs] Document middleware response changes (#42295)
Beginning in Next.js 13, middleware can now respond directly, without
needing to rewrite or redirect, when the experimental
`.allowMiddlewareResponseBody` configuration setting is set. Document
this behavior.

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

## 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`
- [ ] Integration 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`

## 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: JJ Kasper <jj@jjsweb.site>
2022-11-07 11:19:17 -08:00
Wyatt Johnson
fa19c4410f
next/compat/router (#42502)
After speaking with @timneutkens, this PR provides a smoother experience to users trying to migrate over to app without affecting users in pages.

 This PR adds a new export available from `next/compat/router` that exposes a `useRouter()` hook that can be used in both `app/` and `pages/`. It differs from `next/router` in that it does not throw an error when the pages router is not mounted, and instead has a return type of `NextRouter | null`. This allows developers to convert components to support running in both `app/` and `pages/` as they are transitioning over to `app/`.

A component that before looked like this:

```tsx
import { useRouter } from 'next/router';

const MyComponent = () => {
  const { isReady, query } = useRouter();
  // ...
};
```

Will error when converted over to `next/compat/router`, as `null` cannot be destructured. Instead, developers will be able to take advantage of new hooks:

```tsx
import { useEffect } from 'react';
import { useRouter } from 'next/compat/router';
import { useSearchParams } from 'next/navigation';

const MyComponent = () => {
  const router = useRouter() // may be null or a NextRouter instance
  const searchParams = useSearchParams()

  useEffect(() => {
    if (router && !router.isReady) {
      return
    }

    // In `app/`, searchParams will be ready immediately with the values, in
    // `pages/` it will be available after the router is ready.
    const search = searchParams.get('search')
    // ...
  }, [router, searchParams])

  // ...
}
```

This component will now work in both `pages/` and `app/`. When the component is no longer used in `pages/`, you can remove the references to the compat router:

```tsx
import { useSearchParams } from 'next/navigation';

const MyComponent = () => {
  const searchParams = useSearchParams()

  // As this component is only used in `app/`, the compat router can be removed.
  const search = searchParams.get('search')

  // ...
}

```

Note that as of Next.js 13, calling `useRouter` from `next/router` will throw an error when not mounted. This now includes an error page that can be used to assist developers.

We hope to introduce a codemod that can convert instances of your `useRouter` from `next/router` to `next/compat/router` in the future.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-11-07 18:16:28 +00:00
Jiachi Liu
01a1a7f1e7
Fix server html insertion target (#42591)
Fixes #42493

Make sure searching for the close head tag instead of partial of head
tag

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
2022-11-07 18:16:13 +01:00
Shu Ding
b1932b081a
Refactor error codes in the TS plugin (#42585)
Small code refactoring.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-07 16:02:28 +01:00
Shu Ding
3e2e39c559
Show inlined error if the "use client" directive is not before other statements/expressions (#42507)
An example will be:


![image](https://user-images.githubusercontent.com/3676859/200087667-53548f58-4627-422f-a191-548aba194707.png)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-07 15:13:35 +01:00
Max Proske
984627a65e
Remove all custom server integration examples (#42549)
Fixes @leerob's comment https://github.com/vercel/next.js/pull/42110#issuecomment-1304897491

~~Deprecated~~ Removed all custom server integration examples (Express, Fastify, etc.) in favour of the main `custom-server` example, ~~and left behind a helpful `README.md` in case they might be linked to.~~

## 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)
2022-11-07 01:08:51 +00:00
bot08
a9f79980db
Example: fixed tailwind ver in readme (#42551)
- [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)
2022-11-07 01:03:03 +00:00
Shin Yeongmin
de18a9badc
Check properly whether SWC is used or not when using forceSwcTransforms (#42531)
Check whether SWC is used or not by checking "useSWCLoader" variable, not by checking "babelConfigFile".
Since we can bypass babel config file by turning on experimental.forceSwcTransforms, we should not check babel by its config file.



Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-11-07 00:00:15 +00:00
JJ Kasper
af3c5063a6
Fix replaceAll usage in font loader (#42550)
This removes usage of `replaceAll` as it wasn't introduced [until
Node.js
v15](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#browser_compatibility)
although we support v14 still.

x-ref:
https://dev.azure.com/nextjs/next.js/_build/results?buildId=43457&view=logs&jobId=8af7cf9c-43a1-584d-6f5c-57bad8880974

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-06 15:23:02 -08:00
JJ Kasper
98106ba8d2
Re-enable sandbox cache and update AsyncLocalStorage usage (#42547)
Follow-up to https://github.com/vercel/next.js/pull/41402 this
re-enables the sandbox cache and updates to leverage our global
`AsyncLocalStorage` for isolating request meta in both the edge and
Node.js runtime.

Closes: https://github.com/vercel/next.js/issues/42349
Closes: https://github.com/vercel/next.js/issues/38235
Closes: https://github.com/vercel/next.js/issues/42225
Closes: https://github.com/vercel/next.js/issues/42351

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-06 14:56:48 -08:00
Max Proske
48dbdf930f
Convert custom-server-express example to TypeScript (#42110)
Converted Express example to TypeScript to match Contribution docs.

- Added `nodemon` to match the `custom-server` example, and allow live reloading of `server.ts`
- Updated README with explainer for non-standard `<Link href="/a" as="/b">` routing

## 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)
2022-11-06 21:32:41 +00:00
Max Proske
6290689281
Convert middleware-matcher example to TypeScript (#42520)
Converted example to TypeScript to match Contribution docs.
- Set cookies using `NextResponse` instead of the `Set-Cookie` header

## 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)
2022-11-06 06:08:06 +00:00
Balázs Orbán
257835569c
fix: correctly mention generateStaticParams in error (#42524)
Fixes #42517

Not sure if it warrants a test case, but let me know if I should add one.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-06 06:02:24 +00:00
Lee Robinson
27159d07e3
Update turbopack docs to use create-next-app@latest (#42528)
So it's always pulling the latest stuff!
2022-11-06 05:24:20 +00:00
sivtu
3913e4e396
Removed duplicate MONGODB_URI check in example (#42518)
This PR removes the duplicate check if the MONGODB_URI environment variable is set.
2022-11-05 22:17:36 +00:00
JJ Kasper
dd3e851af5
v13.0.3-canary.0 2022-11-04 16:40:57 -07:00
JJ Kasper
192dc6bad6
Ensure RSC is detecting correctly during revalidate (#42508)
Fixes: https://github.com/vercel/next.js/issues/42504

Patch tested against provided reproduction here
https://portfolio-pcmtikvrv-ijjk-testing.vercel.app/

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-04 16:37:00 -07:00
Tim Neutkens
00e416bf7c
Fix undici warning in Node.js 18 (#42477)
- Remove warn for undici in Node.js 18
- Add node about the type being wrong

Follow-up to #42444. The other day I noticed that the type is incorrect.
This just removes the warning.

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

## 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`
- [ ] Integration 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`

## 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>
2022-11-04 15:46:50 -07:00
fantaasm
ee7c5aa0ec
Include app directory in Tailwind config (#42407)
Updated with-tailwindcss example to include new _app_ directory according to [Tailwind docs](https://tailwindcss.com/docs/guides/nextjs)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `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`
- [ ] Integration 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`

## 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)
2022-11-04 22:44:33 +00:00