Commit graph

6826 commits

Author SHA1 Message Date
JJ Kasper
29a913467f
v13.0.6-canary.0 2022-11-23 19:16:49 -08:00
Ngô Đức Anh
f4610c31b0
Fix outputting un-necessary trace files for edge functions (#43304)
<!--
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

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

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

fixes #39275 and related issues like #39858 and hopefully #41395 (can't
test because `pnpm next-with-deps build ./dev-app` keeps crashing on
`Collecting page data...` - `useContext` seems to be null, and even
without the changes it still crashes).

This works by checking if the file is an edge function in Next.js's
Webpack plugin `TraceEntryPointsPlugin`, if true then output the nft
file to the output path, if not move up a folder like previously. I
tried changing Webpack config's output.path from `path: !dev &&
isNodeServer ? path.join(outputPath, 'chunks') : outputPath` to `path:
!dev && (isNodeServer || isEdgeServer) ? path.join(outputPath, 'chunks')
: outputPath`, but it just causes the build script to crash because
files like middleware-manifest.json are output to outputPath/chunks
instead of the expected outputPath. So I find this to be the better
solution.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-11-23 18:56:11 -08:00
Ngô Đức Anh
2eaa3ae146
fix appDir returning 404 in production with "output": "standalone" (#43268)
<!--
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:
-->

Fixes: https://github.com/vercel/next.js/issues/42812
Fixes: https://github.com/vercel/next.js/issues/43037

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

This PR fixes the issue in which urls from appDir will always not be
found in production when built with `"output": "standalone"` by copying
.next/server/app and .next/server/app-paths-manifest.json into
.next/standalone/server.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-11-23 18:45:19 -08:00
Shu Ding
60d5c9615c
Improve RSC plugin to provide better errors (#42435)
This PR improves the RSC plugin for SWC to throw an error when the `"use
client"` directive is in the top level, but not before other statements
/ expressions. For example:

Code:

```js
import 'react'

'use client'
```

Error:

```
The "use client" directive must be placed before other expressions. Move it to the top of the file to resolve this issue.

   ,----
 3 | 'use client'
   : ^^^^^^^^^^^^
   `----
```

## 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: JJ Kasper <jj@jjsweb.site>
2022-11-23 17:26:38 -08:00
Hannes Bornö
5788f602a4
Improve @next/font error handling (#43298)
Use `WellKnownErrorsPlugin` when formatting `@next/font` errors.

The error handling is different for expected errors (like validation
errors) and unknown ones. If the error is expected it just displays the
formatted error message. If it's an unknown error it will also display
the stacktrace, and in case the versions of `@next/font` and `next` are
different it will encourage you to try to update them both.

Removes the usage of `error-loader` when importing from
`pages/_document.js`, handle that case with `WellKnownErrorsPlugin` as
well.

The current warning when using different versions is removed. If the
versions are incompatible you'll get an error in the overlay instead.

## 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)
2022-11-23 16:08:28 -08:00
JJ Kasper
538c11021b
Ensure loaderFile is included in webpack cache key (#43315)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-23 15:31:31 -08:00
OJ Kwon
5d7e1425d7
test(integration): allow to run --turbo dev server tests dynamically (#42967)
This PR is companion to https://github.com/vercel/next.js/pull/42656.

Previous PR https://github.com/vercel/next.js/pull/41908 allowed to set up integration / e2e tests spawn `next dev` with `--turbo` as needed. This PR leverages those, change all the tests suites to run with `--turbo`. One additional change is it can be configured dynamically via env variable. Setting env `__INTERNAL_NEXT_DEV_TEST_TURBO_GLOB_MATCH` to glob pattern will selectively enables tests to run with --turbo, normally it'll skip and only current devserver will be used.

These changes allow gradual integration between https://github.com/vercel/turbo to next.js. Plan is to run these tests with latest turbopack dev branch. Each time turbopack fixes / implements changes to enable certain set of tests, its CI will change its env variable without manually patching next.js's test cases. Once those change goes to upstream `next-swc` those tests can be permanantly enabled.

For those reasons, PR have somewhat verbose changes to touch individual test cases runs devserver. Changed file counts are lot, but mostly identical changes.

## 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-23 23:00:49 +00:00
JJ Kasper
f3a728bef1
v13.0.5 2022-11-23 14:00:15 -08:00
JJ Kasper
e079fbb10f
v13.0.5-canary.7 2022-11-23 12:09:15 -08:00
Balázs Orbán
aa51c26c2e
docs: add error link when missing appDir: true (#43293)
[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1669206360940399)

## 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>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2022-11-23 12:07:14 -08:00
Shu Ding
685c87c946
Show error for invalid page props in the TS plugin (#43300)
For page entries, currently it's only allowed to have `params` and
`searchParams` in props:

<img width="677" alt="CleanShot 2022-11-23 at 16 18 57@2x"
src="https://user-images.githubusercontent.com/3676859/203583323-12c24900-8046-4b3b-ac95-b0ed1bee37e4.png">

In the future, this will cover more cases for layout entries too.

## 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: Jiachi Liu <inbox@huozhi.im>
2022-11-23 19:27:06 +01:00
Shu Ding
2089af4535
Refactor code (#43291)
It seems that hot reloader's `start` method is only referenced in one
single place.

## 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)
2022-11-23 19:08:14 +01:00
Jiachi Liu
e581dc81dd
Resolve next api for layouts to esm for edge runtime (#43302)
The edge runtime should all use esm assets to keep the hooks and the react context are matched

Fixes: #43080

The issue is caused by the app router context and server inserted html context are not aligned. One side is using esm and other side is using the cjs asset.

## 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)
2022-11-23 18:01:16 +00:00
Jiachi Liu
e901feffc3
Update precompiled react (#43288)
Update pre-compiled react to fix the streaming issue with node 18.
x-ref: https://github.com/facebook/react/pull/25645

Fixes: #42466
Manually tested locally works for the reproduction from the issue

## 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)
2022-11-23 15:57:38 +00:00
Laityned
369d6b76c4
Imageloader: collect images serverside to include images from staticp… (#41554)
In #41548, I show that I would like to provide an object with images in
getStaticProps. The StaticImageData is parsed correctly and provided as
a prop to the page. Nonetheless, the image is not available in the
static directory. Therefore the image is not shown. This is also
addressed in issue #29571. The underlying cause is that the import of
the image is removed from the client bundle and only present in the
server bundle.

Evaluating the next-image-loader shows that the file is only placed in
the static directory if emitted from the client bundle by firing
this.emitFile. By changing this to only emitting the file from the
serverside bundle in the webpackloader, static images loaded in the
getStaticProps are made available properly as well as images directly
used in componts (so present in server and client bundle).

This would PR would prevent the circumventing solution which enforces
that the StaticImageData should be present in the client side bundle
while it will also be present in the staticprops.

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

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`


Closes #42783, Fixes #42443

Co-authored-by: Diederik <diederik@digitalpatrol.nl>
2022-11-23 09:28:53 -05:00
Mateusz Burzyński
33d4694ba7
Remove unused use-sync-external-store dependency (#43281)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-11-23 14:11:25 +01:00
JJ Kasper
9fe5317417
v13.0.5-canary.6 2022-11-22 22:06:19 -08:00
Balázs Orbán
3f30e26a3a
fix: apply default export interop to next/error (#43238)
Applies the same interop as we did for `next/jest` in #36824

We could potentially apply the same for other submodules, or do it on
the basis of someone hitting the issue.

Fixes #43206
## 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-22 21:37:18 -08:00
Shu Ding
0caf8000e7
Add fallback aliases for React (#43203)
These aliases are needed by default (removed in
b0f87fbc7c)
because when transpiling external packages specified via `file:./` in
package.json, these external packages might not have `react` in their
dependencies and the package manager might not move or link them into
the current project's node_modules. In these cases, `react` can't be
resolved unless we alias it.

Related discussions can be found in
https://github.com/vercel/next.js/discussions/42136. This PR fixes the
test case
2f0b38197c/src/__tests__/__files__/pages/test-local-typescript-module.tsx.

## 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-22 21:32:53 -08:00
OJ Kwon
55232c2d0d
fix(next-swc): aarch64 build (#43275)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Bug

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

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-22 21:02:01 -08:00
OJ Kwon
0d6e689e3d
build(cargo): bump up turbopack (#43273)
This PR bumps up turbopack to latest version.

## 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)
2022-11-23 02:22:14 +00:00
Tim Neutkens
28454c6ddb v13.0.5-canary.5 2022-11-22 19:56:20 +01:00
Tim Neutkens
fa5dcbd7fa
Fix React.cache() in layout/page file (#43187)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-11-22 19:49:51 +01:00
Balázs Orbán
274341373e
chore: add firebase-admin to default serverComponentsExternalPackages list (#43249)
Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-11-22 19:26:19 +01:00
Shu Ding
3a770fd143
Fix app routes are not correctly matched when src directory is used (#43234)
When creating the client entries, the `src/` prefix shouldn't be included in the entrypoint's name. Closes #42874.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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-22 14:03:46 +00:00
Balázs Orbán
7596132a0c
fix(ts): re-export PageComponent and LayoutComponent types (#43226) 2022-11-22 13:49:01 +01:00
JJ Kasper
7ae1cb8e8d
v13.0.5-canary.4 2022-11-21 17:03:50 -08:00
Julius Marminge
9f93d34061
fix: create-next-app copies files it shouldn't (#43131)
<!--
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:
-->

Closes #43130

This fixes the bug where the CLI copies files it shouldn't, by adding a
`/` separator at the end of the directory name.

Given `examples/next-prisma-starter` and
`examples/next-prisma-starter-websockets`, only files inside the
`examples/next-prisma-starter` will now be copied.

Here is a repo created by the CLI after this fix, using

```bash
# Inside packages/create-next-app
pnpm build
node dist/index.js --example https://github.com/trpc/trpc --example-path examples/next-prisma-starter
```

https://github.com/juliusmarminge/create-next-app-bugfix

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

- [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)
2022-11-21 16:51:57 -08:00
Colin
ed2aa9fd75
Fix HMR error: "Cannot read properties of null (reading 'length')" (#43145)
After upgrading to Next.js 13, we started seeing the following HMR
errors:

```sh
$ next dev
# ...
warn  - Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/basic-features/fast-refresh#how-it-works
TypeError: Cannot read properties of null (reading 'length')
    at eval (webpack-internal:///./node_modules/next/dist/client/dev/error-overlay/hot-dev-client.js:262:55)
```

This error appears related to the changes made in
https://github.com/vercel/next.js/pull/42350 (cc @alexkirsz). It appears
that `module.hot.check` will pass `null` when there are no updates:

```ts
  /**
   * Throws an exceptions if status() is not idle.
   * Check all currently loaded modules for updates and apply updates if found.
   * If no update was found, the callback is called with null.
   * If autoApply is truthy the callback will be called with all modules that were disposed.
   * apply() is automatically called with autoApply as options parameter.
   * If autoApply is not set the callback will be called with all modules that will be disposed on apply().
   * @param autoApply
   */
  check(autoApply?: boolean): Promise<null|ModuleId[]>;
```

When `updatedModules` is `null`, we skip the `apply()` call as this was
producing `apply() is only allowed in ready status (state: idle)`
errors. This matches [the prior behavior when `autoApply` was
enabled](8241da7f1e/lib/hmr/HotModuleReplacement.runtime.js (L266-L272)).

Fixes #43143. Also reported on Stack Overflow: 
-
https://stackoverflow.com/questions/74415937/nextjs-typeerror-cannot-read-properties-of-null-reading-length
-
https://stackoverflow.com/questions/74504229/nextjs-v-13-typeerror-cannot-read-properties-of-null-reading-length

I tested this change locally and no longer see these HMR errors.

## Bug

- [X] Related issues linked using `fixes #number` - no related issues
- [X] Integration tests added - there aren't any existing tests, afaict
- [X] Errors have a helpful link attached, see `contributing.md` - N/A

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-11-21 16:50:03 -08:00
Hannes Bornö
d8d9b2c985
Remove app routes from _devPagesManifest (#43188)
Currently in dev the `_devPagesManifest` includes the `/app` routes as
well. However, In production, the `_buildManifest.js` does not include
the `/app` routes. This causes the `/pages` router to behave differently
in the two environments.

This change excludes the `/app` routes from `_devPagesManifest` to make
it work the same in dev/prod.

Fixes #42513
Fixes #42532

## 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-21 15:52:12 -08:00
Jiachi Liu
ee969ea8fc
Fix middleware not executed when pages directory is empty (#43205)
Fixes #41995

Closes #43144

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

Co-authored-by: Bruno Nascimento <bruno.hn@icloud.com>
2022-11-21 15:37:58 -08:00
Jiachi Liu
869039529c
Alias esm next document to avoid mismatch react context (#43192)
<!--
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:
-->

When using custom document and importing from `next/document`,
`HtmlContext` instance will mismatch due to CJS version of
`next/document` is consumed. Gotta alias it to the ESM version for edge
runtime

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
2022-11-21 14:15:55 -08:00
Jiachi Liu
2763f60806
Avoid bundling appDir rendering into pages edge SSR bundle (#43184)
Do not directly import app-render into base-server since base-server is
shared module for both nodejs SSR and edge SSR.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-11-21 14:09:46 -08:00
JJ Kasper
c1370c923e
Update experimental skipTrailingSlashRedirect handling (#43201)
Fixes: [slack
thread](https://vercel.slack.com/archives/C01224Q5M99/p1669029502713689?thread_ts=1668452468.314249&cid=C01224Q5M99)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
2022-11-21 13:25:01 -08:00
Shu Ding
447cba0f5d
Remove the timestamp query for CSS resources (#43185)
As discussed [here](https://vercel.slack.com/archives/C035J346QQL/p1668425692084449), we don't need the timestamp for CSS resources in the app dir for now as we are not preloading them. Manually tested with Safari and added corresponding e2e tests.

Closes #42862.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] 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-21 13:35:57 +00:00
JH.Lee
6aaa9fc234
fix(next-swc/relay): make pages directory optional (#43116)
Fixes:
https://github.com/relayjs/relay-examples/pull/241#issuecomment-1318756698

**Context:**
Current relay transformer requires `pages_dir` in its entry point:

ecfd2f4cd6/packages/next-swc/crates/core/src/relay.rs (L184)

But consider the case that `pages_dir` is not provided because the page
system is built entirely in the app directory introduced from Next.js
13.

In this case, transformer causes unconditional panics even though
there's nothing wrong with it.

This PR removes panic in entry point and changes the type of `pages_dir`
into `Option<T>` so that keeps [build stability for existing page
system](ecfd2f4cd6/packages/next-swc/crates/core/src/relay.rs (L157-L160))
even if `pages_dir` is not provided.
2022-11-20 12:31:26 -08:00
JJ Kasper
e3387dbb06
v13.0.5-canary.3 2022-11-19 20:12:30 -08:00
Donny/강동윤
3d62f467cf
chore: Update swc_core to v0.43.23 (#42977)
This PR updates swc crates to
a4ed624f81

---

 - Closes https://github.com/vercel/next.js/issues/42978
 - Closes https://github.com/vercel/next.js/issues/42801

<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202788043-4ba0c3a4-b4c5-43e7-8eb3-42b8341e5d5f.png">

 - Closes https://github.com/vercel/next.js/issues/43027
<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202788522-e4884f91-c83c-45e8-983a-f210144effef.png">

 - Closes https://github.com/vercel/next.js/issues/43042
<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202788866-2c319588-5a01-4628-95cc-47bb51e19153.png">

 - Closes https://github.com/vercel/next.js/issues/43060

<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202789993-2bf3af55-9752-4aa8-bcc2-98f08ecd47b7.png">


 - Closes https://github.com/vercel/next.js/issues/42852

<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202804509-88bb3d55-182d-457d-b59e-d12b30c52100.png">
2022-11-19 18:18:31 -08:00
Sukka
0e65335aeb
types: better type definition for internal utils (#43070)
The PR removes some `as unknown as` assertions by improving type
definitions.
2022-11-19 16:09:13 -08:00
Max Proske
9fce9964b6
Remove unstable_revalidate (#43119)
Reverts https://github.com/vercel/next.js/pull/38070

I stumbled upon @ijjk's TODO to remove the deprecated
`unstable_revalidate` renaming error and e2e test after v12.2.

```tsx
// TODO: remove in next minor (current v12.2)
```

I also removed the deprecated function stub, since it probably shouldn't
exist if there's no error, e2e test, and doesn't match the new
`revalidate` function signature anyways.

<img width="675" alt="image"
src="https://user-images.githubusercontent.com/14317828/202842660-be9977e2-252c-4ccf-84fc-e0c00bf25e05.png">
2022-11-19 15:54:19 -08:00
JJ Kasper
a35612aec9
v13.0.5-canary.2 2022-11-18 15:46:45 -08:00
JJ Kasper
97520cc32d
Leverage outputFileTracingIgnores for next-server trace as well (#43108)
Follow-up to https://github.com/vercel/next.js/pull/43103 this adds the
ignores to the `next-server` trace as well since it may be needed for
some cases as well.

## 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-18 15:39:39 -08:00
JJ Kasper
ebbd9a98e9
v13.0.5-canary.1 2022-11-18 14:39:40 -08:00
JJ Kasper
70c6f15522
Add experimental outputFileTracingIgnores config (#43103)
This allows filtering out known traces that should be ignored even if
`node-file-trace` detects them as being potentially used.

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


## 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-18 14:35:28 -08:00
JJ Kasper
24867fd785
v13.0.5-canary.0 2022-11-18 11:03:31 -08:00
JJ Kasper
abd5a8436f
Add force-static handling for app dir (#43061)
Fixes: https://github.com/vercel/next.js/issues/42932
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1668639343426429?thread_ts=1668631260.554489&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-18 09:47:44 -08:00
Hannes Bornö
ce5b59d2ed
Remove unnecessary async function when preloading async components (#42957)
The fix in #42793 added an unnecessary step by returning a new async function when the result is a promise. We only have to make sure we don't get an unhandledRejection error if the promise rejects, React takes care of getting the data from the promise.

Ref: [slack thread](https://vercel.slack.com/archives/C035J346QQL/p1668528003500329?thread_ts=1668434306.364449&cid=C035J346QQL)

## 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-18 09:51:23 +00:00
JJ Kasper
58fa90f1bf
v13.0.4 2022-11-17 20:42:47 -08:00
JJ Kasper
ef81fc3f8d
v13.0.4-canary.5 2022-11-17 19:27:35 -08:00
Ilya Konstantinov
4d2b7e573a
Fix app render: escape segment value #42626 (#42823)
Fix: https://github.com/vercel/next.js/issues/42398

relates to
https://github.com/vercel/next.js/pull/42626#pullrequestreview-1172032873

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

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] 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-17 17:45:39 -08:00