Commit graph

7872 commits

Author SHA1 Message Date
JJ Kasper
fab164dcc8
Update id handling for fonts (#52559)
We don't need to apply the ID here as these assets should always be available across deploys. 

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1689035592272659)
2023-07-11 17:14:25 +00:00
vercel-release-bot
63a6cdaf53 v13.4.10-canary.3 2023-07-10 23:02:55 +00:00
Florentin / 珞辰
0648a109eb
add version to function config manifest (#52507)
Adds `version` to function config manifest as suggested in https://github.com/vercel/vercel/pull/10069#discussion_r1255021336
2023-07-10 20:28:59 +00:00
Shu Ding
d175aea210
perf: Refactor recursiveReadDirSync (#52517)
- Use `opendirSync` instead of `readdirSync`
- Use `.slice` instead of `.replace` as the rootDir

Before (1.54ms):

![CleanShot 2023-07-10 at 18 33 23@2x](https://github.com/vercel/next.js/assets/3676859/829e0a49-35da-4754-bc3f-6fe243e815f4)

With the change (0.88ms):

![CleanShot 2023-07-10 at 18 47 43@2x](https://github.com/vercel/next.js/assets/3676859/cabe1fdd-5861-49ba-8c8d-b505c16fbf7a)

This scales when public/ folder grows.
2023-07-10 17:51:42 +00:00
SleeplessOne1917
0ce55e3f09
Chore: Remove redundant intersection type (#52453)
### What?
The type definition of `ImgProps` is the following:
```typescript
export type ImgProps = Omit<ImageProps, 'src' | 'alt' | 'loader'> & {
  loading: LoadingValue
  width: number | undefined
  height: number | undefined
  style: NonNullable<JSX.IntrinsicElements['img']['style']>
  sizes: string | undefined
  srcSet: string | undefined
  src: string
}
```

`ImgProps` is then used as part of the definition of the `ImageElementProps` type. For the latter, `Omit<ImageProps, 'src' | 'alt' | 'loader'>` is intersected with `ImgProps` even though the intersection with that type is already part `ImgProps`'s definition. This PR removes the redundancy.

### Why?
I was looking at how Next.js implemented it's optimized image component to create something similar for a WASM framework when I noticed this typing and got confused. I figured making a PR would be the polite thing to do.

### How?
Removed redundant part of type definition.
2023-07-10 16:48:02 +00:00
Jimmy Lai
810f0e8710
perf: create an experimental bundled version of the next server (#52206)
This PR:
- adds a minified bundled server for Next with some optimisations applied
- a test server in minimal-server.js
- misc changes:
   - makes some polyfills lazy
   - adds a cached version of node-html-parser
   -
2023-07-10 15:40:06 +00:00
vercel-release-bot
4e710645f8 v13.4.10-canary.2 2023-07-10 14:44:00 +00:00
Shu Ding
0fe6e850fe
Fix tracking of client reference manifest (#52505)
The problem was introduced in #52450, that the client reference manifest isn't being tracked and included in the function.

Verified that this fixes the issue.
2023-07-10 14:27:08 +00:00
Tim Neutkens
73e2979cb8
Ensure useParams return array for catch-all routes (#52494)
## What?

Ensures `useParams` matches `params` passed to the page, also matches the docs.

Fixes #50856
Fixes NEXT-1419
2023-07-10 12:04:44 +00:00
Yagiz Nizipli
85bca2e778
refactor: avoid unnecessary async scopes in eslint (#52418)
This pull request:
- removes unnecessary object copying in `hasEslintConfiguration`
- returns always `null` on `runLintCheck`, and make sure it does not return undefined.
- removes unnecessary async scope creation on `isDirectory`
2023-07-10 10:52:20 +00:00
Balázs Orbán
a06775cdf3
fix: add aws packages to default serverComponentsExternalPackages (#52388)
Related #51969

[Slack thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1688734253149379?thread_ts=1688734176.782469&cid=C04DUD7EB1B)
2023-07-10 10:24:03 +00:00
Ngô Đức Anh
98cc99df46
fix(standalone): fixed output: "standalone" crashing build when there is no app/ page (#51993)
### What?
This PR fixes build crashing when `output: 'standalone'` and `experimental.appDir` is enabled but there is no app pages.

### How?
It does that by checking whether `.next/server/app` exists before copying the folder to `.next/standalone/...`

Closes #51828
Fixes #44442
Fixes #44120
2023-07-10 08:40:02 +00:00
vercel-release-bot
62c2c5abc2 v13.4.10-canary.1 2023-07-10 08:01:26 +00:00
Shu Ding
990c58c5ef
Split the client reference manifest file to be generated per-entry (#52450)
This PR changes client manifest generation process. Instead of one big
manifest file that contains client references for the entire app, we're
now generating one manifest file per entry which only covers client
components that can be reached in the module graph.
2023-07-10 09:48:03 +02:00
Jiachi Liu
85033e3add
Override file based images with social images property (#52416)
Metadata API should provide a way to override the filebased metadata
images. As usually for child routes, if there's new social images or
icons are provided, the ones from parent routes should be overridden /
skipped.

The `metadata` object export or `generateMetadata` should be able to do
that. Sometimes users still add other og info (besides images) to
metadata export (both object and `generateMetadata`).
I think we should check if they really have returned images property,
then decide to override.

- For the same level of routes:
- If there's no `openGraph.images` in the returned value, merge with
file based images
- If there's any `openGraph.images` in the returned value, ignore file
based ones

- For child level of routes:
Always override the parent level, ignoring parent level file based
images unless they use `generateMetadata` to merge from
`resolvingParentMetadata` value, then the parent level's file based ones
will present there


Closes NEXT-1418
2023-07-10 09:09:01 +02:00
Jiachi Liu
632a582807
Fix metadata layer webpack rule for server-only (#52403)
After we separating the metadata routes to a separate layer, we didn't apply the webpack alias rules properly to it as it's should still be treated as pure "server" side

This PR fixes the aliasing for that new metadata layer and make it working properly with "server-only"

Fixes #52390
2023-07-09 18:23:51 +00:00
Shu Ding
e50c9180a3
Cache concurrent ensurePage requests for the same page (#52360)
This should resolve part of the `MaxListenersExceededWarning` problem mentioned in #50909. When there are too many concurrent requests sent to the dev server, we only need to handle the first.

Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2023-07-07 23:08:55 +00:00
Wyatt Johnson
f45a7fce9a
Temporarily revert change to pages render (#52407)
This reverts the change to the pages render until a more substantial refactor can ensure that using the custom `app.render` method will attach a match to the request metadata.

- Fixes #52384
2023-07-07 17:58:36 +00:00
Yagiz Nizipli
d5f355adea
perf: improve URL validation performance (#52353)
The performance of the current implementation can be improved by using
`URL.canParse` which is pending for backport to Node 18 right now. This
pull request also reduces the usage of try/catch in the happy path.
2023-07-07 14:22:41 +02:00
vercel-release-bot
b2c6bc4572 v13.4.10-canary.0 2023-07-07 11:14:32 +00:00
Jiachi Liu
89bccd05de
Refactor metadata og and twitter title to be always presented (#52320)
Follow up for #52196 

The og title should be always resolved as `AbsoluteTemplate`. Move all the title resolving inside the og metadata resolving, so that it's aligned with type. And we don't have to check title everywhere, when og/twitter metadata is resolved, `title` is always presented as a property with `AbsoluteTemplate` type

Closes NEXT-1399
2023-07-07 11:07:52 +00:00
Tobias Koppers
a3d5a855eb
add incremental cache for node.js app rendering (#52172)
### What?

adds `incrementalCache` to app rendering to add support for
`unstable_cache`
2023-07-07 11:33:51 +02:00
Zack Tanner
412992ad6e
fix: prevent infinite dev refresh on nested parallel routes (#52362)
### What?
HMR causes infinite reloads for parallel routes when the corresponding page component is nested

### Why?
In 4900fa21b078fd1ec1adc5d570fcfb560be8aeb6, code was added to remove `/@children` from the page path (if present) but in 59b36349eb86427ac7b679ac62fa6628c9fc4886, `normalizeParallelKey` removes the @ prefix from children, so this doesn't seem to be catching the scenario it was intended to prevent

### How?
This updates the existing replace logic to consider `/children/page` rather than `/@children/page` -- it doesn't seem like `/@children` is a valid scenario given the `normalizeParallelKey` behavior

Fixes #52342 and addresses the concerns in https://github.com/vercel/next.js/pull/52061#issuecomment-1619145129
2023-07-07 07:41:21 +00:00
Yagiz Nizipli
eb3d748759
perf: simplify getShortDynamicParamType on app-render (#52355)
Removes the unnecessary switch case statement and provide a fast path for `optional-catchall` edge case.
2023-07-07 00:35:55 +00:00
Steven
27217146cf
fix: metadatabase warning message (#52363)
This PR is a small grammar change to the warning message since "fallbacks to" is not grammatically correct.
2023-07-07 00:08:10 +00:00
Yagiz Nizipli
4b2eef4600
perf: use fs.opendir for better resource usage (#52341)
This pull request replaces `fs.readdir` with `fs.opendir` for better memory usage. `fs.readdir` consumes the path and only returns value when the iteration is finished, but `fs.opendir` both returns `fs.Dirent` which is better, since we are calling an additional `fs.stat` for each iteration, but also streams the output, so that we don't store the whole array of inputs in the memory.
2023-07-06 23:11:09 +00:00
Yagiz Nizipli
1fbb5138c8
perf: use fs.readdirSync with withFileTypes (#52340)
There is no need to make a `fs.statSync` call for each file while reading a directory, since `fs.readdirSync` supports `withFileTypes` property that returns a `fs.Dirent` which includes the necessary information for detecting if the particular item is directory or not.
2023-07-06 21:39:22 +00:00
JJ Kasper
f0fc83b40c
Fix trailing slash with locale domain (#52343)
This ensures we normalize the trailing slash with a locale domain href
correctly.

Reproduction with patch can be seen here
https://reproduction-link-inconsistency-96cg0lqc9-vtest314-ijjk-testing.vercel.app/dynamic/alpha/

Fixes: https://github.com/vercel/next.js/issues/47661
2023-07-06 13:56:30 -07:00
vercel-release-bot
1045644655 v13.4.9 2023-07-06 20:50:37 +00:00
vercel-release-bot
21392cb4e0 v13.4.9-canary.3 2023-07-06 17:07:58 +00:00
doinki
c878caa3bc
Fix to use keep-alive in standalone mode (#50221)
You can specify keepAliveTimeout as an environment variable in
standalone mode, but there is a problem with it not being properly
applied.

#46052 

#### before
<img width="574" alt="2023-05-24 12 49 12"
src="https://github.com/vercel/next.js/assets/90969158/9014252e-dcac-4b32-805a-68e844e853b1">
<img width="574" alt="2023-05-24 12 49 20"
src="https://github.com/vercel/next.js/assets/90969158/8c5672b2-8af8-4751-aa0c-7347428c3cbb">

#### after

<img width="574" alt="2023-05-24 1 19 12"
src="https://github.com/vercel/next.js/assets/90969158/96a83b0d-1dd1-45b7-b053-e0103185dd47">
2023-07-06 09:59:59 -07:00
Andrew Clark
bb8cf5e3f2
Update eslint-plugin-react-hooks to 5.0.0-canary-7118f5dd7-20230705 (#52275)
*This is a resubmit of https://github.com/vercel/next.js/pull/52268
because I neglected to run `pnpm install` last time and it was
accidentally automerged before I could fix it.*

5.0.0-canary-7118f5dd7-20230705 includes a new lint error for hook calls
inside an async component, a common mistake when refactoring Server
Components to Client Components, or vice versa.

This updates the dependency in eslint-config-next.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

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


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-07-06 14:23:14 +02:00
Steven
6dafc4229d
chore(deps): bump react to 7118f5dd7 (#52282)
Fixes #49409

### React upstream changes

- https://github.com/facebook/react/pull/27045
- https://github.com/facebook/react/pull/27051
- https://github.com/facebook/react/pull/27032
- https://github.com/facebook/react/pull/27031
- https://github.com/facebook/react/pull/27029
- https://github.com/facebook/react/pull/27028
- https://github.com/facebook/react/pull/27027
- https://github.com/facebook/react/pull/27019
- https://github.com/facebook/react/pull/26954
- https://github.com/facebook/react/pull/26987
- https://github.com/facebook/react/pull/26985
- https://github.com/facebook/react/pull/26933
- https://github.com/facebook/react/pull/26625
- https://github.com/facebook/react/pull/27011
- https://github.com/facebook/react/pull/27008
- https://github.com/facebook/react/pull/26997
- https://github.com/facebook/react/pull/26989
- https://github.com/facebook/react/pull/26955
- https://github.com/facebook/react/pull/26963
- https://github.com/facebook/react/pull/26983
- https://github.com/facebook/react/pull/26914
- https://github.com/facebook/react/pull/26951
- https://github.com/facebook/react/pull/26977
- https://github.com/facebook/react/pull/26958
- https://github.com/facebook/react/pull/26940
- https://github.com/facebook/react/pull/26939
- https://github.com/facebook/react/pull/26887
- https://github.com/facebook/react/pull/26947
- https://github.com/facebook/react/pull/26945
- https://github.com/facebook/react/pull/26942
- https://github.com/facebook/react/pull/26938
- https://github.com/facebook/react/pull/26844
- https://github.com/facebook/react/pull/25510
- https://github.com/facebook/react/pull/26932
- https://github.com/facebook/react/pull/26896
- https://github.com/facebook/react/pull/26913
- https://github.com/facebook/react/pull/26888
- https://github.com/facebook/react/pull/26827
- https://github.com/facebook/react/pull/26889
- https://github.com/facebook/react/pull/26877
- https://github.com/facebook/react/pull/26873
- https://github.com/facebook/react/pull/26880
- https://github.com/facebook/react/pull/26842
- https://github.com/facebook/react/pull/26858
- https://github.com/facebook/react/pull/26754
- https://github.com/facebook/react/pull/26753
- https://github.com/facebook/react/pull/26881

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-07-06 14:04:21 +02:00
Shu Ding
37c40b79c5
Update checksum algorithm to SHA1 (#52102)
Update some of the hash we're using in the framework to use `sha1` instead. It's usually up to 20% faster than `sha256` and slightly faster than `md5`. All these places are only using the algorithm to generate a checksum, so there's no security concern to switch the algorithm.

- packages/next/src/build/index.ts: using the hash as the key to track the traced files
- packages/next/src/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts: CSS modules class name generation
- packages/next/src/build/webpack/loaders/next-flight-css-loader.ts: checksum for server imported CSS's file content
- packages/next/src/build/webpack/loaders/next-font-loader/index.ts: font asset hash
- packages/next/src/cli/next-dev.ts: instrumentation file hash
- packages/next/src/server/dev/hot-reloader.ts: module hash for HMR
2023-07-06 08:50:51 +00:00
Nourman Hajar
ea676960de
fix: correct modularizeImports for antd & ant-design/icons (#52169)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

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


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What? / Why?

A follow up of previous fix #52148.

This PR fixes the error `SyntaxError: Cannot use import statement
outside a module` when developing with antd on next canary. I suspect
this happens because ant doesn't have a `type: "module"` in their
`package.json` files, but the previous `modularizeImports` config uses
the `es` version of their lib.

This is also reported in comments
https://github.com/vercel/next.js/pull/52148#discussion_r1251408484 and
https://github.com/vercel/next.js/pull/52148#issuecomment-1619563059

### How?

Use the non-ES version. Instead of importing from `antd/es` dir, we use
`antd/lib` dir. and also change `@ant-design/icons/` into
`@ant-design/icons/lib/icons/`

This `modularizeImports` config has also been used in my company's
project.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-07-05 22:03:46 -07:00
Luba Kravchenko
8ed2b27553
Handle 409s in fetch cache (#51652)
### What?
Adds 409 response handling for fetch cache

### Why?
So we stop making data cache requests when it returns 409 for a
specified amount of time

### How?
Set a module scope variable `rateLimitedUntil` that we check against
before making a request. If we receive a 409 then set `rateLimitedUntil`
to now() + either a specified retry-after value returned from the api or
60s (can make this something else)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-07-05 19:01:27 -07:00
Jiachi Liu
927fc9e220
skip hot reload sync event for applying hmr updates (#52270)
### Issue

x-ref:
https://github.com/vercel/next.js/actions/runs/5469070005/jobs/9957658991?pr=52282#step:27:526
metadata tests are failing as flaky recently, then after digging into
it, noticed it as a hmr issue.

**Steps to repro with metadata test app**

The later (after the 1st one) visited page with client components
imports sometimes throw an full reload refresh warning
> Fast Refresh will perform a full reload when you edit a file that's
imported by modules
outside of the React rendering tree.

Turns out there's some unexpected hmr events when `"sync"` event is
triggered, and client tries to apply the updates but then failed. This
PR excludes the triggering by `"sync"` for RSC pages updates. `'sync'`
event with errors/warnings will still be handled and then `'built'`
event will be handled with hot reload updates

Possibly related to #40184
2023-07-05 17:06:11 -07:00
Jiachi Liu
f9a181342f
Remove the outdated error for find page dir (#52274)
Found this function is used by `nextra` and log unexpected warning sometimes

```
// node_modules/.pnpm/nextra@2.8.0_2yzqpfdqpxhuhtk2arnb2je2cq/node_modules/nextra/dist/index.js
// src/file-system.ts
var findPagesDirImport = __toESM(require("next/dist/lib/find-pages-dir.js"));
```
2023-07-05 23:31:59 +00:00
Shu Ding
267c2d29cd
Use 127.0.0.1 as the default host for the standalone server (#52283)
This helps getting rid of the

```
Error: connect ECONNREFUSED ::1:64696
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
  errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '::1',
  port: 64696
}
```

error for me when running the standalone server. cc @ijjk.

I'm not sure if it's related to https://github.com/http-party/node-http-proxy/issues/835.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-07-05 22:20:29 +00:00
JJ Kasper
8dc0b1be61
Fix app cache enabling case (#52278)
Ensures we don't attempt using the wrong cache handler during build. 

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1688549526316949)
2023-07-05 12:52:16 -07:00
JJ Kasper
5046ee13aa
Revert "Fix stream cancellation in RenderResult.pipe() and sendResponse()" (#52277)
The test here seems to be failing after merge 

x-ref:
https://github.com/vercel/next.js/actions/runs/5467319221/jobs/9953529745
x-ref:
https://github.com/vercel/next.js/actions/runs/5467152519/jobs/9953132439

Reverts vercel/next.js#52157
2023-07-05 11:12:39 -07:00
Justin Ridgewell
ff1f75a873
Fix stream cancellation in RenderResult.pipe() and sendResponse() (#52157)
### What?

I've found 2 more spots that didn't properly cancel the streaming response when the client disconnects. This fixes `RenderResult.pipe()` (called during dynamic render results) and `sendResponse()` (used during Route Handlers using `nodejs` runtime).

It also (finally) adds tests for all the cases I'm aware of.

### Why?

To allow disconnecting from an AI service when a client disconnects. $$$

### How?

Just checks for `response.closed`, which will be closed when the client's connection disconnects.
2023-07-05 17:15:48 +00:00
Shu Ding
a8d09d73c1
Fix small memory leaks (#52257)
Fix a few KBs (depending on the tree state size) of leaked memory caused by closures. All the marked objects below are caused by `serverActionDispatcher` which are not cleaned up after SSR:

![CleanShot 2023-07-05 at 15 15 17@2x](https://github.com/vercel/next.js/assets/3676859/d6731830-146e-4433-9ab7-19ea878472cf)
2023-07-05 15:40:12 +00:00
Jan Nicklas
394533ff88
next-flight-css-loader - fix !=! support (#51115)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

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



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

-->

### What?

- Use a `cssModules` option to configure the `next-flight-css-loader.ts`
based on the match resource.
- Added types
- Ran prettier

### Why?

NextJs supports css modules and global css files.
The `next-flight-css-loader.ts` is capable of dealing with both formats.

However under the hood the loader shares almost no code for css modules
and global css files.
To branch into the correct behaviour the `next-flight-css-loader.ts`
checks the extension of the file using
`this.resourcePath.match(/\.module\.(css|sass|scss)$/)`.

`this.resourcePath` does not include the information from webpacks `!=!`
import syntax.

One solution would be to use `this._module.matchResource` instead of
`this.resourcePath`.
But imho passing it from the webpack.config.js instead of duplicating
the css module file regexp felt cleaner.

### Further questions

- Should we update the loader banner comment?
- Can we drop `this.data.__checksum` in the pitch loader function for
css modules? (it would speed up css modules and for me it looks like it
isn't needed anymore for css modules because of
2eeb0c7f49
(4. April by @shuding)
- Should we split the loader into two loaders?

Fixes #52208

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-07-05 14:37:20 +02:00
Shu Ding
ef89890f56
Ensure Webpack isn't loaded in render workers (#52241)
There's no need to require the HotLoader module as well as Webpack in render workers, as we are not running compilation there. This reduces 10 MB memory in total and some time from `require`ing Webpack.

Before:

<img width="1639" alt="CleanShot 2023-07-05 at 11 33 39@2x" src="https://github.com/vercel/next.js/assets/3676859/48f31051-7a27-4cf6-94aa-1b2ddf313f20">

After:

<img width="1639" alt="CleanShot 2023-07-05 at 12 02 04@2x" src="https://github.com/vercel/next.js/assets/3676859/4c717d75-c0cd-458f-a6c9-6f967ae6df90">
2023-07-05 12:09:25 +00:00
Jiachi Liu
baf3d2fa8a
Fix title crashing while post processing metadata (#52196)
Fixes #52191

Resolved `twitter?.title` could be `null`, adding optional chain to access it
2023-07-05 11:05:33 +00:00
vercel-release-bot
0b470753b7 v13.4.9-canary.2 2023-07-05 10:26:56 +00:00
Tim Neutkens
b2bf446762
Optimize watch ignore (#52238)
## What?

Uses a pre-created regex instead of having webpack run path-to-regexp on the list of patterns. Saves a few milliseconds.
Adds `node_modules` to ignored in order to skip a lot of stat calls at the end of the compilation.

This will likely have a big impact on applications using Yarn PnP as each stat call causes a lookup through `.pnp.cjs`.
2023-07-05 10:18:13 +00:00
Jiachi Liu
003f7dd6f8
Remove zod from require-hook (#52197)
Remove the unnecessary added require hook
2023-07-05 04:22:28 +00:00
Tobias Koppers
fd508b086c
fix env reloading for turbopack (#52194)
### What?

fixes WEB-1258
2023-07-04 19:28:34 +00:00