Commit graph

11705 commits

Author SHA1 Message Date
vercel-release-bot
368e9aa9ae v14.2.0-canary.37 2024-03-21 23:51:55 +00:00
vercel-release-bot
d1248a7536 v14.2.0-canary.36 2024-03-21 23:23:03 +00:00
Jiachi Liu
053db6af8e
Remove the erroring on force-dynamic in static generation for app route (#63526)
### What
* Remove the erroring of force-dynamic is not able to use during static
generation
* Export the route segments properly in sitemap conventions

### Why

We discovered this error is showing up when users are using
force-dynamic with generating multi sitemaps.

When you have a dynamic `route /[id]/route.js` , and you have
generateSitemaps defined which is actually using `generateSitemaps`
under the hood , then you set the route to dynamic with `export dynamic
= 'force-dynamic'`.

We should keep the route still as dynamic. `generateStaticParams` is
only for generating the paths, which is static in build time. And the
`force-dynamic` is going to be applied to each generated path.

Closes NEXT-2881
2024-03-22 00:15:20 +01:00
Andrew Gadzik
4c467a2638
Improve experimental test proxy (#63567)
Followup on https://github.com/vercel/next.js/pull/52520 and
https://github.com/vercel/next.js/pull/54014

**Enhancements**
- Removes `--experimental-test-proxy` CLI argument from `next dev` and
`next start`
- Adds a new experimental config option `testProxy?: boolean`
- Instead of throwing an error, return the `originalFetch` response if
the current request context does not contain the `Next-Test-*` HTTP
headers

**Why?**
These changes allow us to write mixed Integration + E2E tests within the
same Playwright process.

```ts
// some-page.spec.ts

test.describe('/some-page', () => {
	test('some integration test', async ({ page, next }) => {
	  // by using the `next` fixture, playwright will send the `Next-Test-*` HTTP headers for 
	  // every request in this test's context.
	  next.onFetch(...);
	  
	  await page.goto(...);
	  await expect(...).toBe('some-mocked-value');
	});

	test('some e2e test', async ({ page }) => {
	  // by NOT using the `next` fixture, playwright does not send the `Next-Test-*` HTTP headers
	  await page.goto(...);
	  await expect(...).toBe('some-real-value');
	});
})
```

Now I can run `next dev` and locally develop my App Router pages AND run
my Playwright tests against instead of having to,
- run `next dev` to locally develop my change
- ctrl+c to kill server
- run `next dev --experimental-test-proxy` to locally run my integration
tests

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-21 21:31:29 +00:00
Maël Nison
7de7cbf283
Upgrades enhanced-resolve (#63499)
This PR upgrades `enhanced-resolve` to `5.16.0` so as to benefit from
https://github.com/webpack/enhanced-resolve/pull/301, recently merged.

Without this diff, importing dependencies from files from external PnP
projects would fail. It's a little niche, but I'm working on a
documentation website that leverages that to allow deploying multiple
websites from the same template.

Co-authored-by: Sam Ko <sam@vercel.com>
Co-authored-by: Steven <steven@ceriously.com>
2024-03-21 15:27:15 -04:00
vercel-release-bot
04f5781c1b v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
Tobias Koppers
7d95336779
Revert "feat(next-core): support unsupported module runtime error (#63491)" (#63575)
### What?

It's causing `__import_unsupported` is not defined in `instrumentation`
context
2024-03-21 18:43:58 +01:00
Steven
abe74a5211
fix: call instrumentationHook earlier for prod server (#63536)
This ensures that the instrumentation hook for Node.js will run
immediately during `next start` instead of waiting for the first request
like does it `next dev`.

However, if there is a separate instrumentation hook for Edge, that will
still be lazy evaluated and wait until the first request.

Fixes #59999 
Fixes NEXT-2738
2024-03-21 13:11:03 +00:00
OJ Kwon
976dd526ae
feat(custom-transform): middleware dynamic assert transform (#63538)
### What

This PR implements runtime warning for dynamic codes (`eval`,
`Function`...) in edge runtime. Webpack uses middleware plugin to
replace / wrap codes, in case of Turbopack we don't have equivalent, so
creating a new transform visitor and run it if the context is edge.
Since sandbox augments global fn (__next_*), transform simply wraps the
expr if it matches to the condition.

Closes PACK-2804
2024-03-21 06:12:28 +01:00
Will Binns-Smith
aeafed9405
Turbopack: Fail when module type is unhandled (#63535)
This causes Turbopack to fail and communicate when a file with an
unhandled or unregistered extension is built.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/hmr.test.ts`


Closes PACK-2803
2024-03-21 00:36:01 +00:00
vercel-release-bot
c0f9d246d1 v14.2.0-canary.34 2024-03-20 23:22:37 +00:00
Juan Settecase
e4cd547a50
feat: add support for localizations in sitemap generator (#53765)
### What?

Following up with [this
suggestion](https://github.com/vercel/next.js/discussions/53540) I went
ahead and implemented the proposal for the Next.js team to merge it if
they agree.

Things to keep in mind:
- Google has [three different
ways](https://developers.google.com/search/docs/specialty/international/localized-versions#methods-for-indicating-your-alternate-pages)
to do this. The three of them are equivalent
- Google seems to be the only search engine supporting this approach.
The rest of them should ignore it

### Why?

This is supported by
[Google](https://developers.google.com/search/docs/specialty/international/localized-versions#example_2)
to better understand the site when the same page is available in
multiple languages.

### How?

- I added a new key to the `MetadataRoute.Sitemap` type called
`alternates` which accepts just one sub key `languages` similar to the
current one in the
[Metadata](https://nextjs.org/docs/app/api-reference/functions/generate-metadata#alternates)
object
- I updated the `resolveSitemap` method to process the new key and
generate the expected sitemap
- I updated the related tests and documentation to reflect the new
syntax

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-20 17:00:20 +00:00
Tobias Koppers
1c998d86da
route/middleware/instrumentation use server assets instead of client assets (#62134)
### What?

route/middleware/instrumentation use server assets
server assets use full url rewrite

### Why?

### How?

https://github.com/vercel/turbo/pull/7750

Fixes PACK-2522

fixes PACK-2645
2024-03-20 12:06:29 +01:00
vercel-release-bot
833df606b2 v14.2.0-canary.33 2024-03-19 23:22:30 +00:00
Zack Tanner
3ed46abcda
Fix interception/detail routes being triggered by router refreshes (#63263)
### What
Actions that revalidate the router state by kicking off a refetch (such
as `router.refresh()` or dev fast refresh) would incorrectly trigger an
interception route if one matched the current URL, or in the case of
already being on an intercepted route, would trigger the full detail
page instead.

### Why
Interception rewrites use the `nextUrl` header to determine if the
requested path should be rewritten to a different path. We currently
forward that header indiscriminately, which means that if you were on a
non-intercepted route and called `router.refresh()`, the UI would change
to the intercepted content instead (since it would treat it the same as
a soft-navigation).

### How
This updates various reducers to only forward the `nextUrl` header if
there's an interception route present in the tree. If there is, we want
to refresh its data, rather than the data for the underlying page. The
reverse is also true: if we were on the "full" page, and triggered a
`router.refresh()`, we won't forward `nextUrl` meaning it won't fetch
the interception data.

In order to determine if an interception route is present in the tree, I
had to add a new segment type for dynamic interception routes, as by the
time they reach the client they are stripped of their interception
marker.

**Note: There are a series of bugs related to `router.refresh` with
parallel/interception routes, such as the previous page/slot content
disappearing when triggering a refresh. This does not address all of
those cases, but I'm working through them!**

Fixes #60844
Fixes #62470
Closes NEXT-2737
2024-03-19 15:42:41 -07:00
vercel-release-bot
ad4a7bf403 v14.2.0-canary.32 2024-03-19 22:10:11 +00:00
Ethan Arrowood
d2838ce31e
Simplify createRootLayoutValidatorStream (#63484)
This PR is a follow up to #63427 and simplifies the
`createRootLayoutValidatorStream` function to check each chunk
individually instead of combining all of them into one. This should
improve performance

Closes NEXT-2868
2024-03-19 14:46:39 -07:00
JJ Kasper
d4f5368f2c
Update RSC etag generation handling (#63336)
Currently when we generate payloads in app router, the order of RSC
chunks aren't deterministic even if the content stays the same. This
means that any caches that rely on etags for detecting changes in
content aren't able to reliably cache/and avoid invalidating properly.
To avoid this we can manually sort the content before generating the
etag. Eventually this can be fixed upstream in react although that is a
bigger lift so we are doing this for now to alleviate the issue.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1709937748240119?thread_ts=1709856182.174879&cid=C042LHPJ1NX)

Closes NEXT-2825
2024-03-19 21:45:21 +00:00
OJ Kwon
3689c03d60
feat(next-core): support unsupported module runtime error (#63491)
### What

Implement webpack's middleware plugin equivalent for webpack, to raise
unsupported error in runtime.

PR utilizes import map alias for the edge context, to resolve into
modulereplacer internally provides a virtualsource to call runtime error
logic. Since we already have globally augmented, the virtualsource only
need to take export those into module.

Closes PACK-2789
2024-03-19 13:52:06 -07:00
JJ Kasper
b2b5ab4aff
Update tags limit handling for max items (#63486)
Continuation of https://github.com/vercel/next.js/pull/55083 this
ensures we also properly warn when the max number of tags is hit and we
must filter them out so that users are aware of this. Related
documentation is also updated to reflect this limit.

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

Closes NEXT-2870

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-03-19 12:02:35 -07:00
Zack Tanner
7d20ba17b8
Fix instant loading states after invalidating prefetch cache (#63256)
In #61573, I updated the navigation reducer to request a new prefetch
entry if it's stale. But this has the unintended consequence of making
instant loading states effectively useless after 30s (when the prefetch
would have expired). Blocking navigation and then rendering the loading
state isn't ideal - if we have some loading data in a cache node, we
should re-use it.

Now that #62346 stores loading data in the `CacheNode`, we can copy over
`loading` during a navigation.

This PR repurposes `fillCacheWithDataProperty` which wasn't being used
anywhere, to instead be a utility we can use to programmatically trigger
a lazy fetch on a particular segment path by nulling out it's data while
copying over other properties. We could have used the existing util
as-is, but ideally we only have a single spot where lazy fetching can
happen, which currently is in `LayoutRouter`.

When a stale prefetch entry is detected, rather than applying the data
to the tree, this PR will copy over the `loading` nodes and will
"delete" the data so it can be refetched.

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

-->


Closes NEXT-2806
2024-03-19 12:02:12 -07:00
Tobias Koppers
14f16c7050
update turbopack (#63475)
* https://github.com/vercel/turbo/pull/7762 <!-- Tobias Koppers - avoid
panic -->
* https://github.com/vercel/turbo/pull/7750 <!-- Tobias Koppers - fix
ASSET_PREFIX -->
* https://github.com/vercel/turbo/pull/7761 <!-- Tobias Koppers -
process source maps from webpack loaders -->
2024-03-19 15:58:19 +01:00
vercel-release-bot
7943315cce v14.2.0-canary.31 2024-03-19 14:48:23 +00:00
Sam Ko
73b4bfbc20
chore(next/font): update @capsizecss/metrics package to the latest (#63440)
## Why?

-
https://github.com/seek-oss/capsize/releases/tag/%40capsizecss%2Fmetrics%402.2.0

Closes NEXT-2854
2024-03-19 00:22:17 +00:00
Zack Tanner
15e76ead7e
Update React from 6c3b8dbfe to 14898b6a9 (#63439)
Update React from 6c3b8dbfe to 14898b6a9.

### React upstream changes

- https://github.com/facebook/react/pull/28580

Closes NEXT-2853
2024-03-19 00:18:18 +00:00
Ethan Arrowood
229cb14834
Eliminate unnecessary decode operations in node-web-streams-helpers.ts (#63427)
This PR is strictly a performance improvement. It should not change
implementation behavior in anyway.

This PR replaces `decoder.decode()` operations by operating with the
encoded `Uint8Array` instances directly. I added some utility functions
to make things a bit easier to understand.

Ideally, this change also maintains a fair amount of code readability. 

Will measure estimate performance improvement shortly.

Closes NEXT-2848
2024-03-18 23:23:35 +00:00
vercel-release-bot
1439503b3b v14.2.0-canary.30 2024-03-18 23:21:43 +00:00
Will Binns-Smith
1f5d3179ac
Turbopack HMR: Reload when recovering from server-side errors (#63434)
Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/gssp-ssr-change-reloading/test/index.test.ts


Closes PACK-2767
2024-03-18 14:57:24 -07:00
OJ Kwon
e12535c706
build(cargo): bump up turbopack (#63429)
### What

fix test/development/acceptance-app/app-hmr-changes.test.ts.

Closes PACK-2765
2024-03-18 21:11:37 +00:00
Ethan Arrowood
b39a4d5971
fix x-forwarded-port header (#63303)
Follow up to https://github.com/vercel/next.js/issues/61133 that will
rely on `x-forwarded-proto` value if it exists in order to default the
`x-forwarded-port` value.

Closes NEXT-2820
2024-03-18 20:45:33 +00:00
OJ Kwon
4064c64024
fix(next-core): carry over original segment config to metadata route (#63419)
### What

Fixes to honor metadata route's segment config - turbopack replaces it
into route handler, then parsed segment config so original segment
config was ignored always.

Closes PACK-2762
2024-03-18 13:26:04 -07:00
vercel-release-bot
57da10beea v14.2.0-canary.29 2024-03-18 19:47:03 +00:00
OJ Kwon
2cd58bb091
build(package): pin typescript-eslint/parser for supported node.js (#63424)
### What

https://github.com/typescript-eslint/typescript-eslint/pull/8671
introduces a change to enforce node.js >= 18.18.0. This is technically
breaking changes, and affects us as we support 18.17.0 still
(https://github.com/vercel/next.js/blob/canary/package.json#L254).

As a workaround, pin dep version to avoid 7.3.0 - later when we lift our
engines, can remove those.

Closes PACK-2763
2024-03-18 15:43:34 -04:00
Karl Horky
51b878f5a3
Switch to postcss.config.mjs, add type (#63380)
<!-- 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?

Now that @phanect added support for ESM PostCSS config files in PR
#63109 (original issue #34448), PostCSS can use ESM config by default.

It needs to use an `.mjs` extension by default because `create-next-app`
scaffolds CommonJS apps by default.

This will also work with ESM projects which have added `"type":
"module"` in their `package.json`

### Why?

1. To convert one more file to ESM
2. To use the modern format
3. To follow other similar migrations that have taken place in the
Next.js codebase (eg. `next.config.mjs`)

### How?

- Change file extensions from `.cjs` to `.mjs` (change similar to PR
#58380)
- Change module format from CommonJS to ESM
- Add type for the config, for users who enable `checkJs: true` in
`tsconfig.json`

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-18 16:57:55 +00:00
Tim Neutkens
dd7b05897a
Add Bun lockfile to project root resolving heuristic (#63112)
## What?

Got a report from @juliusmarminge that running examples in the
[uploadthing monorepo](https://github.com/pingdotgg/uploadthing) would
result in resolving errors with Turbopack.
Turns out the monorepo root couldn't be resolved and the reason for that
is that they are using `bun install` as the package manager, which we
didn't account for in the `findRootLockFile` logic. This PR adds
`bun.lockb` to the existing list that already check npm/pnpm/yarn.

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

-->


Closes NEXT-2766
2024-03-18 17:44:18 +01:00
Jiachi Liu
e1a7de0d04
feat(error-overlay): handle script under html hydration error (#63403)
script tag cannot be placed under html directly, users reported a case
in #51242 that having `<Script>` under html will cause hydration error,
this will display the React hydration error related warning of bad usage
for it.

You will see this warning in dev overlay instead of displaying nothing
```
In HTML, <script> cannot be a child of <html>.
This will cause a hydration error.
```

Added two other react warnings detection patterns  as well
* `Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will
cause a hydration error.',`
* `Warning: In HTML, whitespace text nodes cann...`

But tested they're not generating hydration errors, only warnings in
console, so we don't need to have tests for them.

Closes NEXT-2835
2024-03-18 11:40:01 +01:00
vercel-release-bot
8b9e18503c v14.2.0-canary.28 2024-03-18 10:01:02 +00:00
Shu Ding
391925808b
Code refactor (#63391)
Two small changes. There's no need to check `payload === undefined` as
it will always be a string. At the other place we can reuse the global
`textEncoder` instance.

Closes NEXT-2830
2024-03-18 10:34:30 +01:00
Tim Neutkens
6380b81bff
Ensure all metadata files have missing default export errors in Turbopack (#63399)
## What?

Fixes the `"app dir - metadata dynamic routes should error if the
default export of dynamic image is missing",` test. The check was
missing in the output code for 2 metadata variations.

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

-->


Closes NEXT-2832
2024-03-18 10:30:45 +01:00
Tobias Koppers
46a5882223
New CSS chunking algorithm (#63157)
### What?

This fixes more CSS ordering issues with production and webpack dev.

* CSS Modules must not be side effect free as side effect free modules
are per definition order independent which is not true for CSS
* fix order of iterating module references
* disable splitChunks for CSS
* special chunking for CSS with loose and strict mode
* more test cases

Closes PACK-2709
2024-03-18 10:29:13 +01:00
Oliver Lassen
af5b31c238
bug: Fields truncated when submitting form using Server Actions (#59877)
When using Server Actions with a form the fields are getting truncated
at 1MB because of `busboy`'s default `fieldSize` limit of 1MB.

This PR tries to solve https://github.com/vercel/next.js/issues/59277
however there is a mismatch about `fieldSize` and `bodySize`. I have
tried creating a PR for `busboy`
https://github.com/mscdex/busboy/pull/351 to allow configuring a max
size for the entire body.

### TODO:

- [ ] Figure out if this is acceptable
- [ ] Throw error when `bodySizeLimit` is hit.

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

-->

Fixes #59277, closes #61462.

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-03-18 09:08:29 +00:00
Shu Ding
107cfbfec7
Use correct protocol and hostname for internal redirections in Server Actions (#63389)
Currently, we always fallback to https as the protocol for redirection
requests inside Server Actions even for the local server host, which can
be `0.0.0.0` and result in SSL errors.

Closes #63114, partially resolves
https://github.com/vercel/next.js/issues/62903#issuecomment-1984179180.

Closes NEXT-2829
2024-03-18 10:01:45 +01:00
vercel-release-bot
8d5e9178f9 v14.2.0-canary.27 2024-03-17 23:23:04 +00:00
vercel-release-bot
f1a999ee73 v14.2.0-canary.26 2024-03-16 22:31:13 +00:00
Tobias Koppers
76c43b7d6a
fix transform of files ending with d (#63367)
### What?

fixed `"use client"` in files ending with `d`...

### Why?

### How?


Closes PACK-2753
2024-03-16 23:27:02 +01:00
vercel-release-bot
3b6b04ae2c v14.2.0-canary.25 2024-03-16 20:06:26 +00:00
Tobias Koppers
43d911406b
add conditions for webpack loader rules (#63333)
### What?

* Allow to apply webpack loaders depending on "conditions".
* add a few next specific conditions depending on context type

### Why?

Some loaders need different behavior depending on context

### How?


Closes PACK-2748
2024-03-16 21:02:10 +01:00
Jiachi Liu
53c21881de
fix(error-overlay): matching html tag with brackets in hydration error (#63365)
### What

* The tags extracted from hydration errors could be "<div>" and "p", we
need to stripe the brackets "<>" for matching the tag name from
component stack
* Change the dimmed text color to lighter so you can see it better in
light mode

#### After vs Before

<img width="450"
src="https://github.com/vercel/next.js/assets/4800338/6caed5ac-c073-41cc-a699-eb29f3785d59">

<img width="450"
src="https://github.com/vercel/next.js/assets/4800338/926aa80f-2a49-4362-b77e-16b819955b0a">


Closes NEXT-2828
2024-03-16 19:24:54 +00:00
Jumpei Ogawa
dc2be6483f
Add JSM (ESM) support for next/lib/find-config (#63109)
Fixes #34448

Before this PR, next/lib/find-config fails to load \*.config.mjs files
and \*.config.js files when `"type": "module"` is set in package.json.
It expects CommonJS files although the \*.config.{js|mjs} files are
written in JS modules format (i.e. using `import` and `export`).
This PR fixes it so that it can load configs written in JS modules
format.

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-16 16:03:24 +00:00
Josh Story
6a6dd9cd2a
Fixes typo in Route handler static generation error handling (#63345)
Error had a typo in it. it should be `force-dynamic` not
`dynamic-error`.

Closes NEXT-2827
2024-03-16 11:25:46 +01:00
Will Binns-Smith
aa13705514
Turbopack HMR: Log when more errors cause full page reload (#63220)
Turbopack HMR: Log when more errors cause full page reload

Depends on vercel/turbo#7715

This adds messaging when HMR updates fail because:

- An HMR update could not be applied, such as updating an anonymous
function component
- An update follows a server-rendered error

Test Plan: See now passing tests in the manifest

Closes PACK-2728
2024-03-15 16:51:02 -07:00
vercel-release-bot
fd692b61e0 v14.2.0-canary.24 2024-03-15 23:22:11 +00:00
Jiachi Liu
955a81bf39
Polish the display color styles for component diff (#63342)
### What
In component diff view, dim the indirect components so that users can
focus on the adjacent ones, and can easily locate the bad tags in
visual.

We still have the `^^^` text for jest snapshots, but they'll not
visually displayed for users, as the red text is enough for users to
notice the incorrect one and `^^^` was more like a terminal text styles
that we don't need to bring them in the web UI.

#### After

<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/9a24f830-14b4-49a2-948a-5afbced8ec6f">

#### Before

<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/c3ee593a-956b-447e-bad2-88007159d00f">


Closes NEXT-2826
Closes NEXT-2771
2024-03-15 23:08:18 +01:00
Tim Neutkens
2417bf9b6f
Ensure changes in optimizePackageImports invalidate webpack cache (#63284)
## What?

Makes sure changes to `optimizePackageImports` apply when there is an
existing cache.

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

-->


Closes NEXT-2817
2024-03-15 14:35:59 +01:00
Donny/강동윤
8cf86bba25
fix(turbopack): Remove error overlay when pages/_app is fixed (#63306)
### What?

Apply same patch as https://github.com/vercel/next.js/pull/62983 for
`pages/_app.js`

### Why?

To make turbopack match behavior of webpack mode, and make the test
passs

### How?

Closes PACK-2407
2024-03-15 12:03:08 +09:00
Zack Tanner
5e3bac5c1e
Store loading data in CacheNode (#62346)
This changes how loading components are provided to `LayoutRouter` to instead be part of the `CacheNode`. This makes it so that we can copy it over/expire it in a similar way to the `data` property on a `CacheNode`. Consequently, this fixes a bug in PPR navigations, where 2 different loading states (the prefetched one, followed by the updated one) might be displayed upon navigating. 

Note: This disables a PPR test that asserts the loading data gets expired after 5 minutes. As implemented, the loading data will remain cached for a particular segment. 

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

-->


Closes NEXT-2557
2024-03-14 16:32:51 -07:00
vercel-release-bot
39a8429ac4 v14.2.0-canary.23 2024-03-14 23:21:31 +00:00
Ziya Fenn
94d69bb847
Fix URL displayed in Server Action bodysizelimit error (#63295)
<!-- 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 #

-->

Current URL points to a non-existing anchor. Updated url to point to
next-config options.
2024-03-14 18:08:08 +00:00
Jiachi Liu
6556a342b9
fix: hydration error display for text under tag case (#63288)
There's a type of hydration warning is mismatch `"text content"` under a
`<tag>`, such as `Did not expect server HTML to contain the text node
"bad text" in <div>.`, we need to treate them separately from the text
diff or bad neseting tags.

### After

![image](https://github.com/vercel/next.js/assets/4800338/4dabfeae-b42a-4232-ab55-1704db36f5ce)


### Before


![image](https://github.com/vercel/next.js/assets/4800338/1da14435-cb3a-4883-84c8-7f0ce4c83b21)


Closes NEXT-2819
2024-03-14 16:03:28 +01:00
vercel-release-bot
847b340180 v14.2.0-canary.22 2024-03-14 12:45:30 +00:00
Donny/강동윤
92fbd7802c
build: Update turbopack (#63273)
# Turbopack changes

* https://github.com/vercel/turbo/pull/7726 <!-- OJ Kwon - feat(node): augment webpack loader's logger context -->
* https://github.com/vercel/turbo/pull/7729 <!-- Donny/강동윤 - Update `swc_core` to `v0.90.22` -->
2024-03-14 08:53:14 +00:00
Tobias Koppers
efc5ae42a8
Turbopack: app externals test case improvements (#62871)
### What?

* rename test case
* improve error message and handle edge case for require resolving
* fix test case actually testing externals (webpack was silently
bundling, Turbopack showed error that helped to find the broken test
case)

### Why?

### How?


Closes PACK-2662
2024-03-14 07:22:40 +00:00
Dima Voytenko
82dc672af9
Disable cache in testmode (#63265)
Fixes #63127.
2024-03-14 00:20:54 -07:00
Donny/강동윤
6d45c3252c
fix(turbopack): Remove error overlay when issue is resolved (#62983)
### What?

Subscribe to changes of `_error` pages.

### Why?

To make the error overlay disappear when the error is fixed.

I tried skipping related entries by using `continue;` from
5f3b13584c/packages/next/src/server/dev/hot-reloader-turbopack.ts (L675-L684),
but it resulted in it page being rendered in the background while error
overlay does not disappear.

We need to remove the errors from `/_error` page to make the error
overlay disappear, so I tried removing them from the map and it worked.

### How?

Closes PACK-2405
Closes PACK-2644

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-03-14 04:31:37 +00:00
Sam Ko
0a697cf044
fix(route-handlers): make sure preflight has CORS headers (#63264)
## Why?

When we just have a POST route handler, it seems CORs is not working
properly. This is because we break out of the loop here
768a92b15b/packages/next/src/server/future/route-modules/app-route/helpers/auto-implement-methods.ts (L38)
when a `GET` isn't present before we add the correct headers and status
to the preflight `OPTION`.

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

Closes NEXT-2813

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-14 00:59:57 +00:00
vercel-release-bot
768a92b15b v14.2.0-canary.21 2024-03-13 23:21:44 +00:00
JJ Kasper
8f09bc44f7
Fix middleware catch-all rewrite case (#63254)
This ensures we properly set the matched header when applying a
middleware skip optimization so that the client router has enough
context to finish resolving the dynamic route params.

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

Closes NEXT-2803
2024-03-13 14:14:04 -07:00
Steven
02a06175e3
feat: add deploymentId config (#63198)
This PR stabilizes an experimental feature that was added in a previous
PR https://github.com/vercel/next.js/pull/50470

It allows the user to set `deploymentId` in `next.config.js`, which is a
unique identifier for a deployment that will be included in each
request's query string or header.

This PR is easier to review with whitespace hidden:
https://github.com/vercel/next.js/pull/63198/files?w=1

Closes NEXT-2789
2024-03-13 16:46:50 -04:00
OJ Kwon
49004e3e15
feat(turbopack): emit well known error into cli (#63218)
### What

This is stopgap substitution to webpack's wellknownerrorsplugin. When
webpack compilation hits known errors kind it emits compilation errors
into cli (and dev overlay both) while turbopack currently only emits
into error overlay. PR simply detects if given issue is well known, and
then logs into std.

Probably a long term there should be proper wiring instead; but for now
this allows to make few things work out of the box.

Closes PACK-2727
2024-03-13 13:38:38 -07:00
Ethan Arrowood
1ff10a03c6
enable optimizeServerReact by default (#62658)
Enable the `experimental#optimizeServerReact` configuration by default. 

Disable the `optimize_use_state` option for the optimization as this may
cause issues in React 19

Closes NEXT-2640
2024-03-13 13:44:47 -06:00
Donny/강동윤
2e19459c88
fix(turbopack): Do not report hmr timing twice (#63227)
### What?

Make turbopack not emit HMR timing report twice.

### Why?

We should not report HMR update twice.

### How?

Closes PACK-2581

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-13 17:30:06 +00:00
vercel-release-bot
9d601afb08 v14.2.0-canary.20 2024-03-13 17:25:13 +00:00
Donny/강동윤
013ba06810
chore: Update swc_core to v0.90.21 (#63031)
### What?

- Update `swc_core` to fix performance regression caused by the creation
of the `tokio` runtime.

This PR practically reverts
https://github.com/vercel/next.js/pull/62441.

 - Apply various minifier bug fixes.

   - https://github.com/swc-project/swc/pull/8730
   - https://github.com/swc-project/swc/pull/8733
   - https://github.com/swc-project/swc/pull/8725
   - https://github.com/swc-project/swc/pull/8726
   - https://github.com/swc-project/swc/pull/8727

- Apply https://github.com/swc-project/plugins/pull/271 (Closes
PACK-2714)


### Why?

Someone reported a performance regression. See
https://github.com/swc-project/swc/issues/8708

### How?

Closes PACK-2693

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-13 17:11:43 +00:00
Jiachi Liu
ed893fa0d3
Use SWC to valid client next/navigation hooks usage in server components (#63160)
### What

Use SWC to check invalid client hooks of `next/navigation` imports in
server components.
Follow up of #62456 

Remove the runtime error APIs for `next/navigation` rsc version.
Add `next/navigation` react-server version alias in turbopack.

This PR also refactored the invalid server layer APIs detection into a
map, where key is import path and value is an array of client APIs.
During the traversing we will get the import source easily, this makes
extending the logic much easier

### Why

Previously we're using the runtime error to check it, but it has to run
first then the error will be thrown. If we error first in build time
with this check it's much faster and we this align on both side between
webpack and turbopack.
2024-03-13 16:37:36 +01:00
Tim Neutkens
8ef121dff5
Implement new runtime_type for Turbopack (#63212)
## What?

Implementation of https://github.com/vercel/turbo/pull/7711

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

-->


Closes NEXT-2791

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-13 16:16:57 +01:00
Zack Tanner
500bc1fe1b
make CacheNode properties non-optional (#63219)
No behavior changes in this PR -- this is a refactor to remove the
optional types on `CacheNode` to be more explicit when we aren't copying
over a value and to help with monomorphization. There's still work to be
done to ensure consistent property order, which will come in a separate
PR.

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

-->


Closes NEXT-2794
2024-03-13 08:16:15 -07:00
Donny/강동윤
3e6720c364
build: Update turbopack (#63229)
# Turbopack

* https://github.com/vercel/turbo/pull/7719 <!-- Tobias Koppers - accept
css files outside of the project as virtual assets -->
* https://github.com/vercel/turbo/pull/7661 <!-- Tobias Koppers - more
efficient node.js process startup -->
* https://github.com/vercel/turbo/pull/7720 <!-- Tobias Koppers -
generate correct async module handling for side effects optimization -->
* https://github.com/vercel/turbo/pull/7718 <!-- Donny/강동윤 -
fix(turbopack): Fix CSS Modules class name for lightningcss mode -->

### What?

Update tests to make CSS Modules of `lightningcss` work with CSS grids.

### Why?

`lightningcss` enforces the class name to end with `[local]`.

See: https://lightningcss.dev/css-modules.html#css-grid


### How?

Closes PACK-2731
2024-03-13 10:13:56 +00:00
Balázs Orbán
9603b20900
fix: re-export internal path (#63222)
### What?

### Why?

### How?

[Slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1710283738235509)

Closes NEXT-2795
2024-03-13 09:55:23 +01:00
Balázs Orbán
55714b4163
fix(error-overlay): show Turbopack indicator for any staleness level (#63130) 2024-03-13 00:37:27 +01:00
vercel-release-bot
ca10b73cd5 v14.2.0-canary.19 2024-03-12 23:22:31 +00:00
Zack Tanner
0312d4a1a9
fix revalidation issue with route handlers (#63213)
### What
When a route handler uses an API that opts it into dynamic rendering
(such as `no-store` on a fetch), and also specifies a `revalidate` time,
the `revalidate` time is ignored and route is treated as fully static.

### Why
`revalidate: 0` and `revalidate: false` have different semantic
meanings: `false` essentially means cache forever, whereas `0` means
it's dynamic. Since `0` is also falsey, the code we have to fallback
with a default `revalidate` value for route handlers is incorrectly not
marking the route as dynamic, and as a result, caching the route without
an expiration time.

### How
This updates the fallback handling for app routes respect a revalidation
value of `0`, so that the page can properly be marked dynamic.

### Test Explanation
This adds 2 new routes handlers: both have a revalidation time specified
& use `no-store` on a fetch, but only one of them specifies `export
const dynamic = 'force-static'`. The one that doesn't specify
`force-static` is correctly omitted from the prerender manifest. The one
that is `force-static` is correctly in the prerender manifest with the
right expiration time. An additional test case was added to verify that
this data refreshes after the specified interval.

Closes NEXT-2764
2024-03-12 15:57:36 -07:00
Balázs Orbán
6464f677c3
fix(error-overlay): strip line+column from webpack internal frames (#63133)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-12 23:42:56 +01:00
Balázs Orbán
8ff1fd8f71
fix(log): improve error when dynamic code eval is disallowed (#62999) 2024-03-12 23:31:32 +01:00
Shu Ding
977f5ff72e
fix: Loose Server Actions runtime check (#63200)
Addresses some feedback in #62821. This will re-allow implementations
like:

```js
'use server'

export const f = wrapper(async () => {})
```

Where `wrapper` creates a sync function that returns a promise. Although
it will still be silently converted to an async function under the hood.

Closes NEXT-2790
2024-03-12 22:03:29 +00:00
Tobias Koppers
18547d5fd0
add support for assets in edge (#63209)
### What?

add support for `new URL(..., import.meta.url)` assets in edge. e. g.
needed for og-image.

### Why?

### Turbopack Changes

* https://github.com/vercel/turbo/pull/7712 <!-- Tobias Koppers - allow
to use full urls in browser runtime -->

Closes PACK-2725
2024-03-12 21:37:16 +00:00
OJ Kwon
11af8dd96f
build(cargo): bump up turbopack (#63205)
* https://github.com/vercel/turbo/pull/7696 <!-- Leah -
fix(turbopack-ecmascript): always create values from object
destructuring -->
* https://github.com/vercel/turbo/pull/7709 <!-- OJ Kwon - build(cargo):
bump up deps, resolve build failures

Resolves build failurs with recent transitive deps bump.



Closes PACK-2720
2024-03-12 21:50:10 +01:00
OJ Kwon
3c94875bf9
feat(next-core): apply invalid import assertion on the remaining contexts (#63146)
### What

This PR completes resolve plugin for the invalid import assertion, for
the server-only in client component + styld-jsx in server components.

Closes PACK-2707
2024-03-12 11:12:07 -07:00
vercel-release-bot
c1daa769f6 v14.2.0-canary.18 2024-03-12 17:31:06 +00:00
JJ Kasper
aa7ae420c6
Fix generateMetadata race condition (#63169)
This ensures we properly catch/handle `generateMetadata` errors during
eager evaluating of nested `generateMetadata` functions in the tree.
Previously if we eager evaluated a child metadata function that threw an
error e.g. `notFound()` and but the parent metadata function took longer
the thrown error would be an unhandled rejection causing the process to
crash depending on the environment.

Fixes: NEXT-2588


Closes NEXT-2786
2024-03-12 17:23:02 +00:00
Yuval Lotem
fb1190425c
fix: x-forwarded-port header is 'undefined' when no port in url (#60484)
### What?
See this issue - https://github.com/vercel/next.js/issues/61133

following this change https://github.com/vercel/next.js/pull/57815
`x-forwarded-port` header value is 'undefined' if the URL has no port

### Why?
x-forwarded-port 'undefined' makes other http-proxy throw 405 error for
the invalid header value

### How?
Give default 80 port if the URL has no port

---------

Co-authored-by: Ethan Arrowood <ethan@arrowood.dev>
2024-03-12 16:45:50 +00:00
vercel-release-bot
0e9baea77f v14.2.0-canary.17 2024-03-12 15:10:31 +00:00
Tim Neutkens
54adb71a8d
Ensure undefined values end up being replaced (#63138)
## What?

Follow-up to #63128

`JSON.stringify(undefined)` ends up with the value `undefined`. However
for Webpack/Turbopack to correctly inject `undefined` into the code it
has to be the string `'undefined'`. This change ensures the
serialization takes into account that case.

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

-->


Closes NEXT-2773
2024-03-12 16:04:50 +01:00
Tim Neutkens
7de0f478c6
Ensure PromiseLikeOfReactNode is not included in .d.ts files (#63185)
Fixes the compile error on all test runs currently:
https://github.com/vercel/next.js/actions/runs/8243077904/job/22543375810?pr=63167#step:27:345

The root cause is that `.d.ts` files automatically include inferred
return types automatically, in this case `tsc` included React class
component `render()` return types in the `.d.ts` for e.g.
error-boundary.tsx / redirect-boundary.tsx. This is a problem because
yesterday that return type was changed:
bf659aefa7 (diff-1d64e275d9755825ba)[…]520436dbd8e1f1fd9fc66a9
and that change also removes one of the previous types that the `.d.ts`
in Next.js automatically included.

This PR changes the `render()` return type to be explicit instead of
inferred, this makes sure that the `.d.ts` file includes only `:
React.ReactNode` instead of the many types of return values allowed.

The reason I went with the explicit type instead of e.g. upgrading
`@types/react` is that upgrading the types would cause existing
applications that use older versions of `@types/react` would break. The
current change ensures it works in both cases.

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

-->


Closes NEXT-2787
2024-03-12 12:51:35 +00:00
vercel-release-bot
d4069559f2 v14.2.0-canary.16 2024-03-11 23:23:31 +00:00
vercel-release-bot
6d0d1fe347 v14.2.0-canary.15 2024-03-11 22:00:55 +00:00
Zack Tanner
465109eab3
ensure mpa navigations to the same URL work after restoring from bfcache (#63155)
### What
When triggering an MPA navigation (also commonly referred to as a "hard
navigation"), and then restoring the previous page via the browser's
bfcache, subsequent requests to the same link wouldn't navigate until
reloading the page or performing a different navigation.

### Why
MPA navigations in app router are handled in a fairly unconventional
way: the router state is updated with an indication that an external URL
was clicked, and once the router sees the pending navigation, it kicks
off a `location.replace` or `location.push` with the specified URL **in
render**. The router then suspends indefinitely to prevent committing
the render. However, the router will only make the `replace`/`push`
request if there's not already a pending navigation to that same URL.

The pending check is needed to avoid continuously calling
`push`/`replace` when unrelated router state changes occur (for example,
if I hover over a link and trigger a prefetch action and the router
re-renders, it shouldn't make another `location.push` call to the same
URL that's pending)

However, the source of the bug is that the variable that holds this
pending state is also restored by the browser's cache, since it takes a
snapshot prior to exiting the page. This means that when clicking the
browser back button, `pendingMpaPath` would still be set to the URL we
just came from. When clicking the link again, it would see that the
requested URL is the same as the pending URL, and not perform any
history actions.

### How
This clears the pending value when the router is restored from bfcache.

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

-->

[slack
x-ref](https://vercel.slack.com/archives/C0676QZBWKS/p1710169967246929)

Closes NEXT-2781
Closes NEXT-2776
2024-03-11 14:55:04 -07:00
Karl Horky
dd536a51ec
Switch to .cjs PostCSS config (#58380)
<!-- 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?

Prevent confusing error messages when changing to `"type": "module"` in
`package.json`

```
./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./src/styles/index.css
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/my/repo/components/postcss.config.js from /path/to/my/repo/components/node_modules/next/dist/lib/find-config.js not supported.
Instead change the require of postcss.config.js in /path/to/my/repo/components/node_modules/next/dist/lib/find-config.js to a dynamic import() which is available in all CommonJS modules.
```

### Why?

Even though PostCSS itself [supports ESM and TypeScript configuration
files](https://github.com/postcss/postcss-load-config/issues/230),
Next.js itself does not (because of `next/lib/find-config`):

- https://github.com/vercel/next.js/issues/34448

### How?

By switching to `.cjs`, the config will stay recognized as CommonJS even
after switching to `"type": "module"` in `package.json`

cc @balazsorban44

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-11 14:19:50 -07:00
vercel-release-bot
da72b60e37 v14.2.0-canary.14 2024-03-11 20:51:37 +00:00
Apostolos Tsakpinis
a00458b5e9
fix typo in server/config.ts (#62795)
lager -> larger

---------

Co-authored-by: samcx <sam@vercel.com>
2024-03-11 19:12:00 +00:00
pacexy
0bad7143d7
Fix webpack HMR for pages on the edge runtime (#60881)
This fixes the issue that build error is not cleared correctly during
`next dev` even if the build succeeds, and we have to re-run `next dev`
to make it work.

It appears only when:

1. page runtime is `edge`
2. use webpack hot reloader
3. import components in the `edge` page

Reproduction:
https://github.com/pacexy/nextjs-edge-webpack-hmr-reproduction

I recorded a screenshot to make it easier to understand:


https://github.com/vercel/next.js/assets/32255488/0ddc21bf-2ea7-49ce-b682-c89dea757c61

Closes NEXT-2168

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-11 16:53:04 +01:00
RightHot
fedcafaba7
Remove unnecessary 'await' from writeSema.release() call (#63117)
### What?
This PR removes an unnecessary await keyword from the
writeSema.release() call. The release method does not return a promise,
hence awaiting it is not required.

### Why?
Awaiting on writeSema.release() which does not return a promise can lead
to confusion and potentially hinder performance. By removing the await
keyword, the code is simplified and aligns with the intended synchronous
nature of the release method.

### How?
Reviewed the writeSema.release() method implementation to confirm it
does not return a promise.
Removed the await keyword from the writeSema.release() call to ensure
the code correctly reflects the synchronous operation.

Co-authored-by: righthot <righthot@everon.co.kr>
Co-authored-by: Steven <steven@ceriously.com>
2024-03-11 15:44:48 +00:00
Wyatt Johnson
7057d1ebf5
[PPR] Support rewrites in middleware (#63071)
### What?

This fixes a special case where rewrites wouldn't work when resuming a
dynamic page.

### Why?

Previously, as routes would direct-match against entries in the cache,
this takes the `x-matched-path` as the source of truth for these
requests if the `x-now-route-matches` header is not present.
2024-03-11 09:05:26 -06:00
Tim Neutkens
76c9496027
Refactor define-env-plugin to have stricter types (#63128)
## What?

Working on some refactors to fix a bug with `undefined` handling for
Turbopack. This is the first step by making define-env-plugin.ts have
stricter types so that we can easily find which values are set to
`undefined`.

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

-->


Closes NEXT-2768
2024-03-11 14:34:47 +01:00
Tobias Koppers
b4b757c25d
ignore fully dynamic requests on server side (#62949)
### What?

make sure that we don't error for dynamic requests on server side.

It will throw at runtime when using a dynamic request.

### Why?

Not all packages are fully bundler compatible, but still work when only
using the parts that work. We don't want to block users from using them
by having an hard compile error.

### How?


Closes PACK-2675
2024-03-11 08:41:33 +00:00
Donny/강동윤
d55699d5f7
feat(turbopack): Enable lightningcss for turbopack by default (#62565)
# Turbopack

* https://github.com/vercel/turbo/pull/7682 <!-- Will Binns-Smith -
Turbopack HMR: url-encode sourceURLs -->
* https://github.com/vercel/turbo/pull/7524 <!-- Donny/강동윤 -
feat(turbopack): Enable lightningcss for turbopack by default -->


### What?

Enable lightningcss by default, for `--turbo` mode.

### Why?

It's time to do it 😄 

### How?

Turbopack counterpart: https://github.com/vercel/turbo/pull/7524


Closes PACK-2600
2024-03-11 06:49:43 +00:00
vercel-release-bot
6fee6b271b v14.2.0-canary.13 2024-03-10 23:23:45 +00:00
Balázs Orbán
1e26cceff4
refactor(error-overlay): unify Pages/App router error overlay source (#62939) 2024-03-10 22:34:30 +01:00
vercel-release-bot
fff9ddc204 v14.2.0-canary.12 2024-03-09 23:23:12 +00:00
mattddean
6da6388b62
Correctly deserialize undefined unstable_cache data (#59126)
<!-- 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 #

-->

The value `undefined` can be saved to the incremental cache as
`undefined` (`JSON.stringify(undefined)`) with no errors, but when
retrieving it, we attempt to parse it as JSON using
`JSON.parse(undefined)`. This throws an error. We should instead
deserialize `undefined` as `undefined` when retrieving.

relevant discussion: #59087

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-08 22:07:09 -08:00
Dima Voytenko
b8d63702f3
OTEL: add next.rsc attribute for RSC requests (#63074)
`next.rsc: boolean` attribute to indicate whether it's a RSC request
2024-03-08 21:58:00 -08:00
OJ Kwon
42b42a6498
build(cargo): bump up turbopack (#63073)
### What

* https://github.com/vercel/turbo/pull/7684 <!-- OJ Kwon -
feat(resolve): skip alias to d.ts -->



Closes PACK-2702
2024-03-09 01:29:21 +00:00
Will Binns-Smith
274c4b71db
Turbopack: Decode module component when tracing stack frames (#63070)
In addition to the file path, also url-decode the module name
(represented by the `id` query parameter).

Test Plan: Together with vercel/turbo#7682, this fixes `pnpm
testonly-dev test/development/basic/hmr.test.ts "should recover from
errors in the render function"`


Closes PACK-2700
2024-03-08 16:43:19 -08:00
vercel-release-bot
a2457c979b v14.2.0-canary.11 2024-03-08 23:24:43 +00:00
Jiachi Liu
664073e86f
Fix metadata url cases should not append with trailing slash (#63050)
### What

Exclude the cases like external urls and relative urls with query from
appending trailing slash when it's needed.

The process is:
- If it's a uncertain string path (relative url, could start with `'./'`
or `/`), convert to relative that starts with `/`;
- then we covert the url (string or URL) to string url
- We do the check if we need to append the trailing slash

### Why

In #62109 we added functionality that can only append trailing slash
when we appended trailing slash to some metadata url like `canonical`
url and open graph url when the config is enabled.
For urls with queries, the trailing slash can also be omitted.
For the external urls (different origin comparing to `metadataBase`) we
don't need to append trailing slash as they're not the same web app.

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

Closes NEXT-2762
Closes NEXT-2753
2024-03-08 21:16:16 +01:00
Wyatt Johnson
ea56c8f7ad
DX: add route context to dynamic errors for app routes (#62844)
Gives the users pathname context on routes that access Dynamic API's so
that if these errors are caught they can modify their code accordingly.
This is a followup to #61332.


Closes NEXT-2695
2024-03-08 11:35:24 -07:00
vercel-release-bot
5482940dd9 v14.2.0-canary.10 2024-03-08 15:19:20 +00:00
Tobias Koppers
72d88c1596
app layouts/pages depend on shared main files (#63042)
### What?

avoid duplication of next.js internals in app dir

For the example/hello-world:

Before:

```
Route (app)                                          Size     First Load JS
┌ ○ /                                                15 kB           184 kB
└ ○ /_not-found                                      15 kB           184 kB
+ First Load JS shared by all                        169 kB
  ├ chunks/[project]__929616._.js                    85.2 kB
  ├ chunks/[project]_packages_next_dist_0f911b._.js  83.2 kB
  └ other shared chunks (total)                      230 B
```

After:

```
Route (app)                                          Size     First Load JS
┌ ○ /                                                15 kB           104 kB
└ ○ /_not-found                                      15 kB           104 kB
+ First Load JS shared by all                        88.9 kB
  ├ chunks/[project]_packages_next_dist_0f911b._.js  83.2 kB
  └ other shared chunks (total)                      5.7 kB
```


Closes PACK-2695

### Turbopack changes

* https://github.com/vercel/turbo/pull/7617 <!-- OJ Kwon -
feat(turbopack): add missing webpack context property -->
* https://github.com/vercel/turbo/pull/7676 <!-- Tim Neutkens -
Implement minify for Turbopack runtime file -->
* https://github.com/vercel/turbo/pull/7677 <!-- Tobias Koppers - add
FullContextTransition -->
2024-03-08 16:12:33 +01:00
vercel-release-bot
af5b4db98a v14.2.0-canary.9 2024-03-08 08:29:26 +00:00
Tim Neutkens
36e401ecc5
Enable minification for Turbopack (#62994)
## What?

Implementation for https://github.com/vercel/turbo/pull/7660. Enables
minification of browser files.

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

-->


Closes NEXT-2742

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-08 08:11:50 +01:00
Will Binns-Smith
bd72f39ca8
Turbopack + pages router: recover from runtime errors by reloading (#63024)
An iteration of #62359, this uses the module-local flag instead of a
shared dedicated module for flagging runtime errors, correctly reloading
the page when these occur.

Test Plan: See now-passing tests in the manifest.


Closes PACK-2690
2024-03-07 17:24:50 -08:00
Jiachi Liu
25be9cafec
Fix the plugin state for async modules in webpack plugins (#62998)
### What

Use the plugin state directly in flight plugins to access the async
modules collection

### Why

This change is cherry-picked from #62349 , where I found the plugin
state didn't store the async modules reousces properly due to the clone
of the array in flight manifest plugin. So for flight manifestp plugin
itself, it's holding a different instance rather than the one from proxy
state.

Closes NEXT-2743
2024-03-08 00:25:32 +01:00
vercel-release-bot
ea5b23c870 v14.2.0-canary.8 2024-03-07 23:24:26 +00:00
vercel-release-bot
0b679a0fed v14.2.0-canary.7 2024-03-07 21:37:05 +00:00
OJ Kwon
710933b033
feat(next): fallback lightning if swc/wasm loaded (#62952)
### What?

Currently wasm binding cannot build lightningcss, until we can make it
work falls back to normal css if lightningcss is enabled + wasm bindings
are loaded.



Closes PACK-2678
2024-03-07 13:30:14 -08:00
OJ Kwon
862b1e0273
fix(next-core): do not apply ecma transforms for custom js rules (#62831)
### What

Looks like we allow d.ts to be included in `match_js_extension`, so if
custom rules have an ecmatransform it could raise an error with d.ts.

This doesn't make test passes yet, seems there are other issues need to
be resolved.

Closes PACK-2653
2024-03-07 13:19:27 -08:00
OJ Kwon
2a6199c2d9
fix(next-core): honor basepath for the metadata property (#62846)
### What?

When we write path for the og metadata, basePath was omitted regardless
of config. (Actual asset emission was correct, just writing the path in
the metadata route)

PR updates template code to use config's basePath if exists.

Closes PACK-2655
2024-03-07 13:19:15 -08:00
Donny/강동윤
03d89bc56d
Update turbopack (#62971)
# Turbopack

* https://github.com/vercel/turbo/pull/7625 <!-- Tobias Koppers -
generate calls of bindings correctly without this context -->
* https://github.com/vercel/turbo/pull/7621 <!-- Donny/강동윤 - fix: Fix
purity lint for CSS Modules in swc mode -->
* https://github.com/vercel/turbo/pull/7640 <!-- Tobias Koppers - very
dynamic requests will only lead to a warning -->
* https://github.com/vercel/turbo/pull/7639 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.90.17` -->


### What?

Update turbopack

### Why?

To keep in sync

### How?
2024-03-07 14:30:54 +01:00
Jiachi Liu
27ed7820a8
[error overlay] move missing tags error inside error overlay (#62993)
### What

* Move missing html tags error into error overlay, from outside we don't
have to manually determine when to render a dummy component with runtime
missing tag error or error overlay.
* Add brackets `<>` to the html tags in the error



![image](https://github.com/vercel/next.js/assets/4800338/cd3467b7-74c2-477e-8516-c31761adb064)


### Why

In #62815, we're having throwing an missing required error, this will
trigger another runtime error. Then when error overlay caught it through
error event listener, it will render it as an unhandled runtime error:

You will see the below message in the overlay.
```
Unhandled Runtime Error
Error: The following tas are missing...

[Error stack]
```

This error message will bring a message that the error is happened on
client during runtime, but actually we already know that is a user side
mistake which doesn't have a error trace. This couldn't hmr as you fix
the error as well.

This PR moves the rendering into error overlay that we're aware of the
errors and can render the correct html on client, with the `html` tag
attached with error id and `body` wrapping the error overlay. We tell
overlay that there're missing tags through props, let it handle
everything inside.

It can also hmr once you fix the error. One drawback is that when you
re-introduce the error, it might trigger react DOM updates exception
(`Failed to execute 'removeChild' on 'Node': The node to be removed is
not a child of this node.`) instead of the "missing tags" message again.
Besides that the HMR works properly.

Closes NEXT-2741
2024-03-07 14:24:00 +01:00
Balázs Orbán
5740ef3e1e
refactor(ts): type fastRefresh (#62848) 2024-03-07 12:21:17 +01:00
Donny/강동윤
5be869b667
build: Update swc_core to v0.90.17 (#62924)
### What?

Update SWC crates.

### Why?

To keep in sync.

### How?

Closes PACK-2670
2024-03-07 11:25:16 +09:00
Zack Tanner
b580b87269
Pass whole prefetch entry rather than status property (#62345)
No change in behavior -- this PR updates `applyFlightData` and its recursive functions to receive the prefetch entry rather than a boolean. We only use the actual prefetch entry in `fillLazyItemsTillLeafWithHead` but I found kept getting confused about what this argument was needed for when it was provided so far away from the part where we read the boolean. 

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

-->


Closes NEXT-2556
2024-03-06 17:14:14 -08:00
James Mikrut
a1e294b706
Remove Payload from server-external-packages.json (#62965)
Payload is moving to ESM, and we need to be removed from the default
list of `serverComponentsExternalPackages`.

This PR simply removes Payload from the default list. Developers can add
it back in if they are using older versions of Payload.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-06 15:52:40 -08:00
vercel-release-bot
dd6cfd9882 v14.2.0-canary.6 2024-03-06 23:22:59 +00:00
Sam Ko
ee273c42bc
chore(next-font): update @capsize/metrics package to the latest (#62896)
## Why?

We need to be up-to-date with this package so our `next/font` is working
optimally. → https://github.com/seek-oss/capsize/releases.

Unlikely related to the latest
[comment](https://github.com/vercel/next.js/issues/47115#issuecomment-1979248754),
but a good reminder I need to check this regularly (or we should
automate it, or have a better solution).

Closes NEXT-2715
2024-03-06 12:04:20 -08:00
vercel-release-bot
e28be5377f v14.2.0-canary.5 2024-03-06 19:57:27 +00:00
JJ Kasper
67eca23ae5
Upgrade to latest @edge-runtime packages (#62955)
This upgrades to the latest edge-runtime packages as it includes
exposing `performance`. This was reverted previously as our publishes
were failing with a specific change that has since been removed
upstream.

Closes NEXT-2730
2024-03-06 11:43:48 -08:00
JJ Kasper
83172a90db
Allow ppr only flag in test mode (#62911) 2024-03-06 18:20:20 +00:00
Ethan Arrowood
3c75ae7cf5
simplify streamToString method from node-web-streams.helper.ts (#62841)
The `encode-decode.ts` file is completely replaceable with the
[`TextDecoderStream`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoderStream)
api, but also we can simplify the `streamToString` function too.

Working on some benchmarks now - wanted to get CI running to see if this
breaks anything though.
2024-03-06 18:14:58 +00:00
Sukka
c206d89ec2
feat(eslint): enhance no-unwanted-polyfill w/ new endpoints (#62719)
The PR adds the new `polyfill.io` instance endpoint (from Fastly and
Cloudflare) to the `eslint-plugin-next`'s `no-unwanted-polyfillio`
rules, so these new endpoints can be detected by the rule.

---

`polyfill.io` was acquired by **a China-based CDN company** "Funnull",
see [the announcement from the `polyfill.io` domain owner's
Twitter](https://x.com/JakeDChampion/status/1761315227008643367) and
https://github.com/polyfillpolyfill/polyfill-service/issues/2834.
Despite Funnull's claims of operating in the United States, the
predominance of Simplified Chinese on its website suggests otherwise,
and it turns out that **"Funnull" is notorious for providing service for
the betting and pornography industries**.

[The original creator of the `polyfill.io` has voiced his concern on
Twitter](https://twitter.com/triblondon/status/1761852117579427975). And
since the acquisition, numerous issues have emerged
(https://github.com/polyfillpolyfill/polyfill-service/issues/2835,
https://github.com/polyfillpolyfill/polyfill-service/issues/2838,
https://github.com/alist-org/alist/issues/6100), rendering the
`polyfill.io` service **extremely unstable**. Since then, Fastly
([Announcement](https://community.fastly.com/t/new-options-for-polyfill-io-users/2540))
and Cloudflare
([Announcement](https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk))
has hosted their own instances of `polyfill.io` service.

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-03-06 16:42:53 +00:00
Donny/강동윤
3ed96f92cb
feat: Introduce lightningcss-loader for webpack users (#61327)
### What?

I'm recreating a PR because CI of
https://github.com/vercel/next.js/pull/58712 uses `lightningcss@1.14.0`
for an unknown reason.

Add an opt-in feature to use `lightningcss` instead of webpack
css-loader.

### Why?

In the name of performance.

### How?


This PR is largely based on https://github.com/fz6m/lightningcss-loader
by @fz6m.
(Thank you for nice work)

Closes PACK-1998
Closes PACK-2124

---------

Co-authored-by: OJ Kwon <1210596+kwonoj@users.noreply.github.com>
2024-03-06 17:07:53 +01:00
Balázs Orbán
0a73e89880
feat(error-overlay): version staleness in Pages Router (#62942) 2024-03-06 16:00:16 +00:00
Balázs Orbán
4c62c3002e
refactor(error-overlay): improve server code for webpack/Turbopack middleware (#62396) 2024-03-06 16:43:56 +01:00
vercel-release-bot
1ad3963d44 v14.2.0-canary.4 2024-03-06 12:03:01 +00:00
Tobias Koppers
ce92c450b2
fix graph update (#62933)
### What?

fixup for #62927 


Closes PACK-2672
2024-03-06 11:20:00 +00:00
Balázs Orbán
8f5107de16
feat(error-overlay): notify about missing html/body in root layout (#62815) 2024-03-06 10:59:53 +00:00
OJ Kwon
415cd74b9a
fix(next-api): correct font manifest generation (#62916)
### What

I noticed the font manifest generated by Turbopack was always empty.
Debugging showed that the path to the client_root was always incorrect
when calculating `get_font_paths_from_root`. And also fixed an issue
where for certain paths, the (`/index`) manifest key should contain the
original path.

Closes PACK-2666
2024-03-06 11:21:39 +01:00
vercel-release-bot
6e8a859bca v14.2.0-canary.3 2024-03-06 09:51:39 +00:00
Tobias Koppers
6194e49d77
fix merge css plugin to account for css order (#62927)
### What?

Merging css chunks need to account for css order when merging chunks

### Why?

Changing the order would break css


Closes PACK-2671
2024-03-06 10:43:30 +01:00
Will Binns-Smith
f9aec9005a
Turbopack: Trace edge runtime app render errors through source maps (#62901)
Similar to #62611, this implements error stack translation for edge
runtime app render errors.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/app-render-error-log/app-render-error-log.test.ts`

Closes PACK-2665
2024-03-05 20:40:26 -08:00
Jiachi Liu
ced7339aa6
Fix: missing crossorigin property on manifest link (#62873)
We didn't set the property of manifest before, this PR fixes the missing
prop

> If the manifest requires credentials to fetch, the crossorigin
attribute must be set to use-credentials, even if the manifest file is
in the same origin as the current page.
x-ref: https://developer.mozilla.org/en-US/docs/Web/Manifest


Fixes NEXT-2706
2024-03-06 02:04:28 +01:00
Sam Ko
bdfe247b5e
chore(cli): fix allowRetry when using port 3000 (#62840) 2024-03-05 16:19:21 -08:00
vercel-release-bot
6045048b26 v14.2.0-canary.2 2024-03-05 23:25:45 +00:00
vercel-release-bot
d0b30787e2 v14.2.0-canary.1 2024-03-05 20:48:05 +00:00
Jiwon Choi
9798ae52c5
refactor(next): fix spacing on auto-generated root layout (#62769)
![Screenshot 2024-03-03 at 5 28
23 AM](https://github.com/vercel/next.js/assets/120007119/282d65aa-71f0-410d-bd25-1352a244d2fb)

Added a space.

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-05 19:47:57 +00:00
monssef
8d8ec75912
bump @edge-runtime/cookies for Partitioned cookie support (#62889)
Bumps `@edge-runtime/cookies` to add support for `set-Cookie:
Partitioned` attribute

- https://github.com/vercel/edge-runtime/pull/825
-
https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
2024-03-05 19:34:35 +00:00
Jiachi Liu
02c4ce1acf
refactor: rename isAppDirEnabled to hasAppDir (#62837)
app dir is always "enabled", but not always exists. Rename to the proper
word to describe. Found this confusion while developing other fetaures

Closes NEXT-2691
2024-03-05 18:58:53 +01:00
Tobias Koppers
405933a0ea
update turbopack (#62884)
* https://github.com/vercel/turbo/pull/7622 <!-- Tobias Koppers - don't
apply alternatives if there is an exports field -->
2024-03-05 15:57:50 +00:00
Tobias Koppers
1d8b70411f
apply some transforms on foreign code too (#62827)
### What?

some transforms need to be applied on node_modules code too to work
correctly

### Why?

### How?


Closes PACK-2651
2024-03-05 16:03:35 +01:00
Thomas Danecker
6f5e0f3694
Don't emit crossorigin attributes for output: "export" by default (#61211)
In other output modes, link and script tags do not contain a crossorigin
attribute by default.

When using output: "export", it should also follow the other output
modes, to avoid unnecessary CORS issues, especially when hosting the
assets on a different domain (i.e. a CDN).

fixes #61210

Co-authored-by: Steven <steven@ceriously.com>
2024-03-05 14:33:37 +00:00
Almaz
473ef817a7
Update readme of @next/bundle-analyzer package (#62804)
Set actual information about output of bundle analyzer.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-05 05:18:22 +00:00
Shu Ding
135642b9df
Remove extra logic of Server Reference check for registering twice (#62486)
This isn't necessary as it has been landed in React already:
https://github.com/facebook/react/pull/28343.

Closes NEXT-2586
2024-03-05 03:42:46 +00:00
vercel-release-bot
07e5b60a03 v14.2.0-canary.0 2024-03-05 01:09:36 +00:00
Jacob Hummer
392507b023
fix "setBlocking is not a function" errors on StackBlitz (#62843)
To reproduce:
- go to https://next.new/
- run `next build`
- it breaks

```sh
~/projects/nextjs-pdjpmx
❯ npm install && npx next dev

added 328 packages in 6s

116 packages are looking for funding
  run `npm fund` for details
   ▲ Next.js 14.1.0
   - Local:        http://localhost:3000

   Downloading swc package @next/swc-wasm-nodejs...
 ✓ Ready in 5.7s
 ○ Compiling / ...
 ✓ Compiled / in 9.2s (510 modules)
 ✓ Compiled in 483ms (240 modules)
^C


~/projects/nextjs-pdjpmx 27s
❯ npx next build
   ▲ Next.js 14.1.0

   Creating an optimized production build ...

> Build error occurred
TypeError: process.stdout._handle.setBlocking is not a function
    at loadBindings (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/swc/index.js:231:32)
    at getBaseWebpackConfig (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-config.js:333:37)
    at eval (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-build/impl.js:140:40)
    at async Span.traceAsyncFn (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/trace/trace.js:151:20)
    at async webpackBuildImpl (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-build/impl.js:133:21)
    at async Object.workerMain (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-build/impl.js:313:20) {
  type: 'TypeError'
}
```

fixes #61848 

<!-- 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: JJ Kasper <jj@jjsweb.site>
2024-03-05 01:06:21 +00:00
JJ Kasper
eeb2369a5d
Update to latest version (#62850)
Updates our version to match the last backport for canaries.

Closes NEXT-2699
2024-03-04 16:04:21 -08:00
Jiwon Choi
882aa6d13c
fix(next-lint): do not pass absolute path to distDir (#62797)
This PR reverts part of #61877 passing an absolute path to the distDir
value when running `next lint`.

Fixes #62796

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-04 23:56:35 +00:00
vercel-release-bot
a1c9c3b9d4 v14.1.2-canary.7 2024-03-04 23:22:19 +00:00
Zack Tanner
9ac6c4abb2
remove reducer unit tests (#62766)
These tests were added back when the router would suspend in reducers,
primarily to test that things were working as expected during concurrent
rendering. Now that we don't suspend in reducers, most of these tests
aren't actually adding much value, and instead introduce friction
anytime we want to change the router state since they're currently
relying on snapshotting.

Before removing these tests, I verified that we have a corresponding e2e
test that covers the expected behaviors more explicitly. Specifically:

- `test/e2e/app-dir/actions` (server actions) 
- `test/e2e/app-dir/navigation` (navigation tests & router.refresh)
- `test/e2e/app-dir/app-client-cache` and
`test/e2e/app-dir/app-prefetch` (prefetch & router cache behavior)
- `test/e2e/app-dir/router-autoscroll` (navigation auto-scrolling
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(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 #

-->


Closes NEXT-2669
2024-03-04 14:42:00 -08:00
vercel-release-bot
91a84b3ee2 v14.1.2-canary.6 2024-03-04 21:47:40 +00:00
OJ Kwon
655227f4e1
Revert "refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc" (#62838)
Reverts vercel/next.js#61832

Closes PACK-2654
2024-03-04 21:43:56 +00:00
JJ Kasper
5717b9a14d
Revert "Add experimental config for navigation raf test (#62668)" (#62834)
Reverting this experimental flag as it should not be used and we are
going to investigate experimenting with this further upstream so that it
can be done properly.

This reverts commit 2bdcaa0fda.

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



Closes NEXT-2689
2024-03-04 12:39:41 -08:00
OJ Kwon
6e89226615
fix(next-core): throw on invalid metadata handler (#62829)
### What

Align with original route loader, explicitly throw on invalid handler
import.

This does not fixes test currently - other failures on the specific test
need to be solved.

Closes PACK-2652
2024-03-04 11:48:50 -08:00
Shu Ding
7b2b982343
fix: Add stricter check for "use server" exports (#62821)
As mentioned in the new-added error messages, and the [linked
resources](https://react.dev/reference/react/use-server#:~:text=Because%20the%20underlying%20network%20calls%20are%20always%20asynchronous%2C%20%27use%20server%27%20can%20only%20be%20used%20on%20async%20functions.):

> Because the underlying network calls are always asynchronous, 'use
server' can only be used on async functions.
> https://react.dev/reference/react/use-server

It's a requirement that only async functions are allowed to be exported
and annotated with `'use server'`. Currently, we already have compiler
check so this will already error:

```js
'use server'

export function foo () {} // missing async
```

However, since exported values can be very dynamic the compiler can't
catch all mistakes like that. We also have a runtime check for all
exports in a `'use server'` function, but it only covers `typeof value
=== 'function'`.

This PR adds a stricter check for "use server" annotated values to also
make sure they're async functions (`value.constructor.name ===
'AsyncFunction'`).

That said, there are still cases like synchronously returning a promise
to make a function "async", but it's still very different by definition.
For example:

```js
const f = async () => { throw 1; return 1 }
const g = () => { throw 1; return Promise.resolve(1) }
```

Where `g()` can be synchronously caught (`try { g() } catch {}`) but
`f()` can't even if they have the same types. If we allow `g` to be a
Server Action, this behavior is no longer always true but depending on
where it's called (server or client).

Closes #62727.
2024-03-04 18:50:19 +01:00
vercel-release-bot
b80d388032 v14.1.2-canary.5 2024-03-04 16:11:11 +00:00
OJ Kwon
372c74b620
refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc (#61832)
Reenabling https://github.com/vercel/next.js/pull/59300 with fixes for
the unsupported inputs.

Closes [PACK-2088](https://linear.app/vercel/issue/PACK-2088)

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-03-04 08:07:36 -08:00
vercel-release-bot
330b04ff55 v14.1.2-canary.4 2024-03-04 12:29:28 +00:00
Tobias Koppers
92eecbfdff
Turbopack: sass support (#62717)
### What?

* upgrades turbopack for `getResolve` in webpack loaders
* add missing resolve-url-loader to turbopack for full sass support

Closes PACK-2634
2024-03-04 11:56:55 +00:00
OJ Kwon
e9862a80f8
build(cargo): update turbopack (#62744)
### What

* https://github.com/vercel/turbo/pull/7544 <!-- Tobias Koppers -
extract a turbopack-resolve crate -->
* https://github.com/vercel/turbo/pull/7547 <!-- Tobias Koppers - only
register once -->
* https://github.com/vercel/turbo/pull/7447 <!-- Leah - fix(turbopack):
catch invalid source map paths -->
* https://github.com/vercel/turbo/pull/7503 <!-- Leah -
fix(turbopack-node): don't bundle postcss config -->
* https://github.com/vercel/turbo/pull/7445 <!-- Tobias Koppers - allow
to set a name on the virtual file system -->
* https://github.com/vercel/turbo/pull/7552 <!-- Tobias Koppers - add
default_files, prefer_relative and fully_specified resolve options -->
* https://github.com/vercel/turbo/pull/7560 <!-- Tobias Koppers - remove
unused code -->
* https://github.com/vercel/turbo/pull/7562 <!-- Tobias Koppers - add
getResolve to webpack loader context -->
* https://github.com/vercel/turbo/pull/7564 <!-- Tobias Koppers - fix
serde deserialization -->
* https://github.com/vercel/turbo/pull/7566 <!-- Tobias Koppers - Revert
"add getResolve to webpack loader context" -->
* https://github.com/vercel/turbo/pull/7565 <!-- Tobias Koppers - Ignore
circular aliasing with alias field -->
* https://github.com/vercel/turbo/pull/7320 <!-- OJ Kwon -
feat(turbo-tasks-fetch): allow specifying a proxy -->
* https://github.com/vercel/turbo/pull/7573 <!-- OJ Kwon - Revert
"Remove mopa dependency in turbo-tasks" -->
* https://github.com/vercel/turbo/pull/7526 <!-- Alexander Lyon - Handle
logging story better on daemon -->

Closes PACK-2639

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-04 11:33:21 +01:00
vercel-release-bot
9fb18e6739 v14.1.2-canary.3 2024-03-03 23:21:56 +00:00
vercel-release-bot
f2d4d04ff8 v14.1.2-canary.2 2024-03-02 23:21:32 +00:00
Will Binns-Smith
be87132327
Turbopack: Trace server app render errors through source maps (#62611)
Previously, errors shown in the error overlay, these stir were left
untraced through source maps.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/app-render-error-log/app-render-error-log.test.ts`

Closes PACK-2608
2024-03-01 16:31:02 -08:00
vercel-release-bot
d70a554032 v14.1.2-canary.1 2024-03-01 23:17:20 +00:00
Sam Ko
47f73cd8ec
refactor(cli): refactor cli to commander (#61877)
## Description
Refactor the [Next.js
CLI](https://nextjs.org/docs/app/api-reference/next-cli) to use
[commander](https://github.com/tj/commander.js) instead of
[arg](https://github.com/vercel/arg).

## Why?
- Auto-generated, properly formatted help command + output. With `arg`,
much of the help commands were manually added via a single
`console.log`, causing deviations over time.
- Ergonomic, ease of adding new subcommands and rules

## Breaking Changes
- Update the experimental `next experimental-compile` and `next
experimental-generate` build commands in favor of `next build
--experimental-build-mode=compile/generate`

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-01 23:12:47 +00:00
vercel-release-bot
2f7721a632 v14.1.2-canary.0 2024-03-01 21:49:46 +00:00
Zack Tanner
9529a874bd
Add a flag to disable MergeCssChunksPlugin (#62746)
This is currently on by default, but this adds a flag to allow disabling
it if it causes issues with your application's CSS.

Closes NEXT-2664
2024-03-01 21:44:28 +00:00
JJ Kasper
8562680f23
Update version from backport (#62745)
Ensures new canaries start from correct version as we did a backport for
`v14.1.1`

Closes NEXT-2663
2024-03-01 21:35:18 +00:00
Max Leiter
6ffbdc5db1
Route static render error message: remove duplicate word (#62738)
### What?
Removes an extra word from an error message

### Why?
It bothered me 

### How?
I opened it in VS Code and removed it

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-01 21:35:15 +00:00
Jiachi Liu
4d4b45ec2c
fix dev overlay pseudo html collapsing (#62728)
Dev overlay should show the full stack trace after clicking the
uncollase button to display the full component stack

Closes NEXT-2658
2024-03-01 19:13:57 +01:00
Tim Neutkens
8034042215
Add compiler error for conflicting App Router and Pages Router in Turbopack (#62531)
## What?

Working on fixing `test/e2e/conflicting-app-page-error`, this adds a
compiler error for the case where App Router routes conflict with Pages
Router routes. It's not 1:1 the same error as in webpack because in the
webpack version we hijacked the App Router resolving logic to assume
there's a certain set of paths, where Turbopack has the full route to
route tree resolving implementation which doesn't assume there's a
single page that can be resolved.

The tests are updated to reflect this change.


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

-->


Closes NEXT-2592
2024-03-01 17:39:39 +01:00
Tim Neutkens
d12693e779
Handle top level errors coming from Turbopack entrypoints subscription (#62528)
## What?

Adds handling for issues that are emitted during the entrypoints
subscription, before the changes in this PR any issue (i.e. compiler
errors) that was emitted during the collection of which entrypoints
exist in the application were ignored.

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

-->


Closes NEXT-2591
2024-03-01 14:47:41 +01:00
Balázs Orbán
7593039b4c
fix(error-overlay): improve a11y, minor refactors (#62723)
### What?

- Use `button` instead of `span` to allow keyboard navigation
- match tabindex with other items in the overlay to include it in the
natural focus sequence
- the style is kept, but we might need a better contrasting icon for the
dark background
- use same file conventions with existing files
  - match file casing
  - move icons to the `icons` folder
- Improve PseudoHtml internal docs
  - use code guards ``` for code snippets
- drop the `any` type (long-term, we really should disallow `any` types)

Closes NEXT-2657
2024-03-01 14:40:46 +01:00
Tobias Koppers
744d9f464e
Turbopack: remove node_modules error filter (#62586)
### What?

This isn't needed

### Why?

### How?


Closes PACK-2604
2024-03-01 10:26:08 +01:00
Vercel Release Bot
35aab7eee3
Update font data (#62704)
This auto-generated PR updates font data with latest available

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-01 01:17:52 +00:00
JJ Kasper
dc41d9c644
Add param to debug PPR skeleton in dev (#62703)
This adds an experimental query `__nextppronly` to allow debugging PPR
skeletons in development to avoid having to do numerous builds to be
able to debug this experience.

x-ref: [slack
thread](https://vercel.slack.com/archives/C05KYT5S9FF/p1709151588583179?thread_ts=1708474869.960689&cid=C05KYT5S9FF)
2024-02-29 16:30:56 -08:00
Jiachi Liu
7d8a923f8d
chore: remove unused helper (#62701)
This code is removed in #62585 , remove it and related imports

Closes NEXT-2652

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-29 23:41:52 +00:00
vercel-release-bot
c77454a02a v14.1.1-canary.82 2024-02-29 23:21:48 +00:00
JJ Kasper
41564fd5d1
Fix lint check (#62702)
x-ref:
https://github.com/vercel/next.js/actions/runs/8103553122/job/22149048179

Closes NEXT-2653
2024-02-29 15:16:16 -08:00
Jiachi Liu
ce422240e3
feat: display text diff for text mismatch hydration errors (#62684)
### What

Keep improving the hydration erros. Currently we divide the hydration
mismatch types into two categories, html tag mismatch and text mismatch.
We're displaying the mismatched text content between server and client
here since we have it in the component stack and warnings.

We've already made some improvements in #62590 , here we carry on
improving the highlited text into red and bold that is much easier for
you to spot on.

This updated a few long snapshots that we could collapse and show only
the text content difference instead of all the component stack.

### Screenshots

(Dark and light modes)

#### Mismatch html tags
<img width="360"
src="https://github.com/vercel/next.js/assets/4800338/f721b374-69cc-4600-a09d-bef87e885fab"><img
width="360"
src="https://github.com/vercel/next.js/assets/4800338/1abf2572-2be8-4359-a652-8ba39aaccfd3">


#### Mismatch text content
<img width="360"
src="https://github.com/vercel/next.js/assets/4800338/7f0d2215-8bc0-4fba-9c92-6c44efa29531"><img
width="360"
src="https://github.com/vercel/next.js/assets/4800338/656d1e1a-3157-4bcf-a239-74bb81fcb4c4">


#### Large content mismatch

### Why

I was intended to bring a html diff between server and client html
content but turns out the diff result could be giant and not ideal due
to few reasons. So we switched to the path of leveraging component stack
and mismatch contents.
React reordering the tags after hydration. For instance the `script` or
`link` tags could be hoist by React Float, so the lines of html is are
to preserved. so the diff is hard to be super accurate unless your
mismatch is small. If you're mismatch a component with rich html
content, it could be a pretty large diff.

Another case is if you have a bad nesting html like `<p> ...<span>...
<p>my text</p> ...</span>... <p>` where there're many span in between,
the final different could also be hudge as browser will close the first
`<p>` tag and the rest content will go into the diff. Hence we're going
with the component and text content diff.


Closes NEXT-2645
2024-02-29 23:36:38 +01:00
Jiachi Liu
28c2832405
Update precompiled for mini-css-extract-plugin (#62699)
Update precompiled related to below dependencies upgrades 

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

Closes NEXT-2649

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-29 22:36:23 +00:00
neomad1337
c6e865bf6f
Upgrade mini-css-extract-plugin (#62698)
## For Contributors

### What?
This PR upgrades the mini-css-extract-plugin dependency

### Why?
In this
[version](https://github.com/webpack-contrib/mini-css-extract-plugin/releases/tag/v2.4.4),
the bug related to content hash is fixed. This bug causes different
hashes of CSS chunks in the webpack chunk.

### How?

Closes
[NEXT-1146](https://linear.app/vercel/issue/NEXT-1146/hashes-are-different-between-multiple-servers-with-generatebuildid)
Fixes #49230

Co-authored-by: Madiyar Turkenov <tagwriter@mail.ru>
Co-authored-by: Sam Ko <sam@vercel.com>
2024-02-29 21:20:50 +00:00
OJ Kwon
ecec67d3f5
refactor(next-swc): remove unused features (#62696)
### What

Remove unused features for the turbopack.

Closes PACK-2628
2024-02-29 11:14:16 -08:00