Commit graph

5821 commits

Author SHA1 Message Date
Jiachi Liu
1268f99e9e
Dedupe double logged server errors (#67464)
### What

Only call error log in SSR renderer, instead of calling it in all RSC
and SSR renderers.

Fixes #67352 
Close NEXT-3579

### Why

The RSC rendered generated result will be rendered by SSR renderer
again, at there we can get the actual error. So when there's a RSC error
happening, only logging once in SSR rendering layer is enough.
2024-07-05 16:22:54 +02:00
Sung Ye In
0dbe761e52
fix(next): add cross origin in react dom preload (#67423)
Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
2024-07-05 15:13:00 +02:00
Tobias Koppers
3f11815b02
avoid merging global css in a way that leaks into other chunk groups (#67373)
### What?

This disallows merging of global css with styles that appear on other
pages/chunk groups.

### Why?

Before we made the assumption that all CSS is written in a way that it
only affects the elements it should really affect.

In general writing CSS in that way is recommended. In App Router styles
are only added and never removed. This means when a user uses
client-side navigations to navigate the application, styles from all
previous pages are still active on the current page. To avoid visual
artefacts one need to write CSS in a way that it only affects certain
elements. Usually this can be archived by using class names. CSS Modules
even enforce this recommendation.

Assuming that all styles are written this way allows to optimize CSS
loading as request count can be reduced when (small) styles are merged
together.

But turns out that some applications are written differently. They use
global styles that are not scoped to a class name (e. g. to `body`
directly instead) and use them in different sections of the application.
They are structured in a way that doesn't allow client-side navigations
between these sections. This should be valid too, which makes our
assumption not always holding true.

This PR changes the algorithm so we only make that assumption for CSS
Modules, but not for global CSS. While this affects the ability to
optimize, applications usually do not use too much global CSS files, so
that can be accepted.

fixes #64773
2024-07-05 03:33:02 -07:00
Sebastian Silbermann
5bdffad843
Bump minimum Node.js version to 18.18 (up from 18.17) (#67274) 2024-07-05 09:21:57 +00:00
Steven
28fc89448f
fix(next/image): handle invalid url (#67465) 2024-07-04 21:55:32 +02:00
Will Binns-Smith
a6631d994f
Turbopack + Relay: correctly implement artifact_directory to fix multi-project test (#67403)
Previously, if `artifact_directory` were set, artifacts would be
resolved at a fixed location relative to each file. This correctly
resolves them from the project root.

Test Plan: `TURBOPACK_BUILD=1 TURBOPACK=1 pnpm test-dev
test/integration/relay-graphql-swc-multi-project/test/index.test.js`

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-07-04 14:52:45 +00:00
Jiachi Liu
b369ccfcf4
Transpile geist by default (#67402)
### What

Transpile `geist` package by default. Currently users need to add
`geist` into `transpilePackages` to make it work with pages router as
it's external packages but require transform. This PR will resolve that
issue. cc @JohnPhamous

### Why

geist package is using `next/font` which requires to work with SWC
transform. But so far only ESM syntax can be captured by SWC since CJS
is pretty difficult to cover as the package import is not statically
analyzable.

We introduced a new list that it could be transpiled and include geist
package into bundle. Add it in both `next/jest` side and
webpack/turbopack bundling side

---------

Co-authored-by: 강동윤 (Donny) <kdy1997.dev@gmail.com>
2024-07-04 14:04:57 +02:00
Zack Tanner
1337c7a3e5
fix dynamic param extraction for interception routes (#67400)
### What
When using `generateStaticParams` with interception routes, the
interception would never occur, and instead an MPA navigation would take
place to the targeted link.

### Why
For interception rewrites, we use a `__NEXT_EMPTY_PARAM__` marker (in
place of the actual param slot, eg `:locale`) for any params that are
discovered prior to the interception marker. This is because during
route resolution, the `params` for the interception route might not
contain the same `params` for the page that triggered the interception.
The dynamic params are then extracted from `FlightRouterState` at render
time. However, when `generateStaticParams` is present, the
`FlightRouterState` header is stripped from the request, so it isn't
able to extract the dynamic params and so the router thinks the new tree
is a new root layout, hence the MPA navigation.

### How
This removes the `__NEXT_EMPTY_PARAM__` hack and several spots where we
were forcing interception routes to be dynamic as a workaround to the
above bug. Now when resolving the route, if the request was to an
interception route, we extract the dynamic params from the request
before constructing the final rewritten URL. This will ensure that the
params from the "current" route are available in addition to the params
from the interception route without needing to defer until render.

Fixes #65192
Fixes #52880
2024-07-03 11:21:07 -07:00
hrmny
a22858d6e7
test: add test for parallel routes hmr (#67392)
### What?

A test for #67222
2024-07-02 15:07:16 +00:00
Zack Tanner
2fbdac6f82
fix prefetch bailout detection for nested loading segments (#67358)
### What
When PPR is off, app router prefetches will render the component tree up
until it encounters a `loading` segment, at which point it'll just
return some metadata about the segment and won't do any further
rendering. This is an optimization to ensure prefetches are lightweight
and don't potentially invoke expensive dynamic subtrees. However,
there's a bug in this logic that is causing it to bail unexpectedly if a
segment deeper in the tree contained a `loading.js` file.

This would mean the loading state wouldn't be triggered until the second
request for the full RSC data is initiated, resulting in an unintended
delta between when a link is clicked and the loading state is shown.

### Why
The `shouldSkipComponentTree` flag was incorrectly being set to `true`
even if the `loading.js` segment appeared deeper in the tree. Prefetch
requests from the client will always contain `FlightRouterState`, so the
logic to check for loading deeper in the tree will always be missed.


### How
This removes the `flightRouterState` check as it doesn't make sense:
prefetches will currently _always_ include the `flightRouterState`,
causing this to always short-circuit. I believe that this check is
vestigial from when we were generating static `prefetch.rsc` outputs
which is no longer the case.

This mirrors a [similar
check](b87d8fc499/packages/next/src/server/app-render/create-component-tree.tsx (L393))
when determining if parallel route(s) should be rendered.
2024-07-01 16:11:09 -07:00
Hendrik Liebau
7523f327e0
Ensure required-server-files test can exit cleanly (#66765)
When running `pnpm test-start
test/production/standalone-mode/required-server-files/required-server-files.test.ts`
locally, Jest hangs and prevents the process from exiting. In the CI,
the issue is masked because `run-tests.js` uses `--forceExit`.

The reason for the hanging process is that there are two server
instances started, and only the last one is killed. By starting and
killing the server for each test we can not only fix this, but also
prevent the `should run middleware correctly (without minimalMode, with
wasm)` test from affecting the other tests when flipping the
`minimalMode` flag in `server.js`.

I also reverted the darwin-specific overwrites of `appPort` that were
added in #65722 and #66724. I don't think those are needed because after
#65722 was created we did land #66285 which sets the hostname to be
compatible with ipv4 and ipv6. If there's still a need to keep this then
let me know, and I will restore it.
2024-07-02 00:05:28 +02:00
Zack Tanner
aa832c3b2d
use fetch priority for app prefetches (#67356)
This leverages [fetch
priority](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#priority)
to ensure automatic prefetching as a result of visiting a page is sent
with "low" priority, to signal to the browser it can prioritize more
important work necessary for rendering the page.

A "temporary" prefetch (ie one that is created when there wasn't an
existing prefetch cache entry on navigation) will use a "high" priority
because it's critical to the navigation event.

All other cases will be "auto" which is the current default.
2024-07-01 14:47:56 -07:00
Steven
73b552a9a5
fix(next/image): undo tight coupling between priority=true and fetchPriority=high (#67351)
## History

When we added `priority` prop to `next/image`, there was no
`fetchPriority` so we instead used this to preload the image in the
head.

Then when browsers added support `fetchPriority`, we automatically added
`fetchPriority=high` when `priority={true}` to signal to the browser
that this was a high priority image. This priority is added to the img
and the preload.

However, we saw cases where images are blocking critical css. Per
@gnoff:

> React currently prioritizes font preloads then high priority images,
then css in the initial page load

Due to these changes in React (aka Float), we should no longer set
`fetchPriority=high`, although the user can still manually add that prop
if needed.
2024-07-01 14:42:42 -04:00
Jiachi Liu
0e6e83c33d
Add warn and telemetry for customized esmExternals (#67339)
### What

* Warn with next.js when users customized `experimental.esmExternals`
value
* Add telemetry tracking on the customization usage for that flag. 0 for
no customization, 1 for used non-default customized value


### Why

`esmExternals` ideally can just remain as default value `true` which
Next.js can handle the customization properly. Since next.js app router
also supports it on canary now we're adding a warning to users that
don't modify `esmExternals` option as it could affect module resolution
on ESM packages.
2024-07-01 18:28:11 +02:00
Jiwon Choi
f702a14acf
chore: throw when three dot character is detected in segment (#67348)
### Why?

It could be confusing between `...` and `…`, which the later is actually
a single character.

### How?

We throw if we detect `…` instead of `...`.
2024-07-02 00:53:45 +09:00
Steven
78dc2db916
fix(next/image): improve query string validation for integers (#67293)
The Image Optimization API currently uses `parseInt()` for `w` and `q`
query string parameters.

This doesn't handle floats as you might expect and instead coerces, for
example `parseInt('99.9') === 99`.

This PR changes the runtime to match the build time validation and only
accept integers for `w` and `q`.
2024-07-01 08:10:35 -07:00
Sam Ko
e6983b911b
chore: update pnpm to 9.4.0 (#64945)
## Why?

Notable change of v9 is Corepack is enabled by default.  
So we can ensure all package manage/resolved exact same version of pnpm.

- [**v9.0.0**](https://github.com/pnpm/pnpm/releases/tag/v9.0.0):
Discontinued support for Node.js v16 and introduced Corepack
compatibility checks. New configuration updates include enabling
`dedupe-injected-deps` and changing the lockfile to version 9, with
better readability and resistance to Git conflicts.

...

- [**v9.4.0**](https://github.com/pnpm/pnpm/releases/tag/v9.4.0)

- Kudos to @ryota-murakami for the original :pr:! →
https://github.com/vercel/next.js/pull/64854

## Changes

- https://pnpm.io/npmrc#link-workspace-packages defaults to `false` now,
so setting it to `true`

Closes NEXT-3211
2024-06-28 04:41:35 -07:00
Zack Tanner
87e45521d2
reject actions with invalid RSC responses (#67059)
When a server action responds with something other than an RSC response,
we currently silently ignore the error and it doesn't get propagated to
any rejection handlers.

This adjusts the handling so that if the server action response is a
non-successful status code, we reject the server action promise. If the
error is `text/plain`, we'll automatically propagate the text content as
the error text. Otherwise, the promise is rejected with a fallback
message.
2024-06-28 11:18:52 +02:00
Wyatt Johnson
3c6936cfbd
[ppr] Test fixes for deployment tests (#67256)
Fixes some possible race conditions by adding a few delays to the
navigation test to ensure that we wait for hydration to occur and
prefetches to finish.
2024-06-28 00:32:56 +02:00
Josh Goldberg ✨
72a64081b4
feat: enable @typescript-eslint/recommended in create-next-app --typescript (#52845)
Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
2024-06-27 09:37:01 +00:00
hrmny
18b13e04f5
fix(turbopack): add no-op resolveAbsolutePath to browser runtime (#67215)
### What?

The turbopack browser runtime was throwing an error when trying to
access `import.meta.url`.


Closes PACK-3095
Fixes https://github.com/vercel/next.js/issues/66005
2024-06-26 19:18:33 +00:00
Will Binns-Smith
c8e9e65de1
Test that nonlatin characters don’t cause hard reloads in hmr (#67077)
This test case covers https://github.com/vercel/next.js/issues/65117.

Fixes #65117
2024-06-26 11:05:26 -07:00
Wyatt Johnson
08793dd911
[ppr] Handle corrupted postponed state (#67021)
Previously, when the provided postponed state was corrupted, the render
failed which resulted in a hydration error. Instead, when the postponed
state is corrupted, we send the resume stream just for the hydration
where it'll attempt to render client side with the data that's already
available.
2024-06-26 06:52:49 -07:00
Tim Neutkens
5999c78a4b
Upgrade Turbopack (#67209)
* https://github.com/vercel/turbo/pull/8546 <!-- Benjamin Woodruff -
Decrease default scope_stress test size, add env var config -->
* https://github.com/vercel/turbo/pull/8563 <!-- Donny/강동윤 - Update
`swc_core` to `v0.95.4` -->
* https://github.com/vercel/turbo/pull/8556 <!-- Tobias Koppers - avoid
cloning the source code -->
* https://github.com/vercel/turbo/pull/8562 <!-- Will Binns-Smith - HMR:
handle non-Latin characters in text through base64-encoded sourcemaps
-->
* https://github.com/vercel/turbo/pull/8530 <!-- Benjamin Woodruff -
Support turbo tasks inside of `mod` blocks -->
* https://github.com/vercel/turbo/pull/8542 <!-- Benjamin Woodruff -
Handle `#[cfg(...)]` attributes on turbo tasks -->
* https://github.com/vercel/turbo/pull/8529 <!-- Benjamin Woodruff -
Deduplicate persistent task get_function_name logic -->
* https://github.com/vercel/turbo/pull/8547 <!-- Benjamin Woodruff - Add
new ExitHandler API as an alternative to ExitGuard -->
* https://github.com/vercel/turbo/pull/8604 <!-- Benjamin Woodruff -
Delete unused TASK_ID_MAPPING support -->
* https://github.com/vercel/turbo/pull/8605 <!-- Benjamin Woodruff -
Remove nohash-hasher dependency -->
* https://github.com/vercel/turbo/pull/8559 <!-- Tobias Koppers - move
stateful flag into Done state -->
* https://github.com/vercel/turbo/pull/8598 <!-- Tim Neutkens - MDX
support: Ensure development transform is only used in development -->
* https://github.com/vercel/turbo/pull/8557 <!-- Tobias Koppers - reduce
size of task output struct -->
* https://github.com/vercel/turbo/pull/8558 <!-- Tobias Koppers - remove
prepared task type -->


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

-->
2024-06-26 14:11:23 +02:00
Joseph
c839d589ab
fix: Narrow down from string | undefined to string (#65248)
Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
2024-06-26 12:42:55 +02:00
Zack Tanner
a4431a9126
skip provide-paths test when deployed (#67203)
This test cannot be run in `test-deploy` because it inspects the
contents of the `.next` folder.
2024-06-26 10:22:06 +02:00
Jiachi Liu
1a04d94aae
Remove extra suspense boundary for default next/dynamic (#67014)
### What

Reland #64716 

Removing the Suspense boundary on top of `next/dynamic` by default, make
it as `React.lazy` component with preloading CSS feature.

* Remove `suspense` option in `next/dynamic` since it's already
deprecated for a while
* Remove the default loading in app router implmentation of
`next/dynamic`

### Why

Extra Suspense boundary is causing extra useless rendering. For SSR, it
shouldn't render `loading` by default

Related: #64060
Related: #64687
Closes
[NEXT-3074](https://linear.app/vercel/issue/NEXT-3074/app-router-content-flickering-with-reactcreatecontext-and-nextdynamic)

This is sort of a breaking change, since removing the Suspense boundary
on top of `next/dynamic` by default. If there's error happening in side
the dynamic component you need to wrap an extra Suspense boundary on top
of it
2024-06-25 20:40:09 +02:00
Sebastian Silbermann
63908fcd2f
Test lint config after first-time setup (#67146) 2024-06-25 16:13:56 +02:00
Jiwon Choi
ebc2c68c4c
chore: upgrade ts to 5.4 (#67171)
Stepping stone before #67113

Closes NEXT-3136

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-06-25 23:12:28 +09:00
Hendrik Liebau
0c615f9c6e
Do not skip react-owner-stacks-svgr test for turbopack build (#67184) 2024-06-25 16:06:33 +02:00
Hendrik Liebau
d824059439
Create React aliases for SVG components (#67104) 2024-06-25 14:29:32 +02:00
Jiachi Liu
7f72971039
Fix server action edge redirect with middleware rewrite (#67148)
### What

Add isEdgeRendering check condition for rewrite logic in edge adpator 

Fixes #66837 
Closes NEXT-3545

### Why

From headers `x-middleware-rewrite`, it's still relative url `/rewrite`,
reconstructing the url will lead to crash as it doesn't contain host.
2024-06-24 13:17:44 +00:00
Jiachi Liu
fc7f62dc4e
Fix noindex is missing on static not-found page (#67135)
### What

Render noindex into a flight data and rsc payload when page path is
`/404`

### Why

When it's static generation, noindex is not rendered due to the
statusCode from mock request is 200, but we can relying on the pagePath
as `/404` page should always contain `nonidex`

We were missing the noindex before for flight generation, now we'll
render it when it's 404 page.
2024-06-23 21:56:08 +02:00
JJ Kasper
16cf88e569
Add experimental flag for providing entry paths (#67134)
Adds a flag for experimentally building on specifically provided entry
paths. This should not be relied on as it is NOT a public facing API.
2024-06-23 10:21:10 +00:00
Jiachi Liu
b68caaf85f
dx: add pagePath info to missing component error (#66916)
### What 

Show the full `pagePath` information for missing default component app
router convention files.

Move runtime error tests from `rsc-build-errors.test.ts` to the new test
`test/development/acceptance-app/undefined-default-export.test.ts`

### Why

Previously we only log `segment` which could be `[slug]` that is not
enough useful for users to locate the bad defined component
2024-06-23 09:25:03 +00:00
Zack Tanner
eaa4431f3d
fix deploy test manifest for metadata navigation test (#67132)
This test got moved in a recent PR, so this updates the deploy test
manifest with the new location.
2024-06-23 10:37:45 +02:00
Steven
f5d616b77e
chore: add detection for image more types (#67112)
These image types aren't optimized but we can still detect them to
bypass optimization earlier.
2024-06-23 01:04:46 -07:00
Zack Tanner
d3edfe1763
tweak import-conditions test (#67116)
This test was failing when deployed with _"Unsupported URL Type
"link:"._

This tweaks the linking behavior when deployed. I wasn't able to get
this test to pass when changing both `start` and deploy to use `link`.
2024-06-22 18:28:11 +00:00
Zack Tanner
891ca7a054
ensure accessing search params mark dynamic usage (#67105)
When accessing search params, we only track dynamic access during static
generation. This has implications on fetch caching, because the fetch
cache relies on hints set during render that it's in a dynamic scope. In
15, this would signal that it should not attempt to cache the fetch at
all. In 14, this could impact the heuristic that bails from fetch cache
if dynamic access came before certain requests types, e.g. POSTs.
2024-06-22 12:56:50 +02:00
Tim Neutkens
98100135f0
Skip webpack specific test for Turbopack build (#67067)
Skips a test suite that depends on running webpack loaders / plugins
that aren't supported.

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

-->
2024-06-21 12:08:19 +02:00
Vercel Release Bot
77a6e37441
Update Turbopack development test manifest (#67093)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-06-21 10:27:34 +02:00
Vercel Release Bot
ffe36594c5
Update Turbopack production test manifest (#67094)
This auto-generated PR updates the production integration test manifest
used when testing Turbopack.
2024-06-21 10:23:35 +02:00
Tim Neutkens
6bebacb220
Ensure Turbopack build runs when experimental-compile option is used (#67049)
Currently webpack would be incorrectly used when some of the
experimental options for builds were enabled. For example
`parallelServerCompiles` and `parallelServerBuildTraces`. This ensures
Turbopack is always used when it's specified to be used.

Fixes around 100 Turbopack build tests

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

-->
2024-06-20 17:41:24 +02:00
Jiachi Liu
3a17d4d2cd
fix: bad script tag in layout hydration error (#66998) 2024-06-20 14:09:19 +00:00
Sebastian Silbermann
cbeb109892
Improve hydration error overlay coverage (#67022)
Revealed some bugs that. One of them we're fixing in
https://github.com/vercel/next.js/pull/66998.
2024-06-20 11:39:26 +02:00
Sebastian Silbermann
fe8d953e2d
Replace hasRedbox() (#67025)
...with `assertHasRedbox` and `assertNoRedbox`.

`hasRedbox()` has a hardcoded timeout of 5s that is only required for
the negative assertion.
Instead, we now have dedicated assertions for the positive
(`assertHasRedbox`) and negative case (`assertNoRedbox`).
The negative assertion still has the hardcoded timeout.
But the positive assertion just retries until we find the Redbox.

This speeds up tests using the positive assertion.
Removing `hasRedbox` also uncovered some unused expressions e.g. `await
hasRedbox(browser)`.
These expressions probably wanted to use `expect(await
hasRedbox(browser)).toBe(true)
2024-06-20 10:37:32 +02:00
Jiachi Liu
0c6dac466a
Fix esm property def in flight loader (#66990) 2024-06-19 18:26:43 +02:00
Joost
50b9966ba9
Add sassOption implementation to support sass-embedded (#64577)
## What?
This PR adds an option to use `sass-embedded`.

## Why?
For large projects sass-embedded improves SCSS compilation time by over
50%.
See also https://github.com/vercel/next.js/discussions/36160

## How?
Added a sassOption `implementation` to configure the sass-loader which
Sass implementation to use.
See also https://www.npmjs.com/package/sass-loader#implementation

I think this a similar approach to what is done for `additionalData`.

## Additional notes
In order to support `sass-embedded`, `sass-loader` is upgraded to
12.6.0.

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-06-19 14:50:21 +00:00
hrmny
d02dfc6e05
feat(turbopack): add support for esm externals in app dir (#64918)
### What?
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
2024-06-19 14:49:48 +00:00
Jiachi Liu
54f54423d8
test: break down metadata test suite into smaller ones (#67018)
### What

app-dir `metadata.test.ts` is pretty big and includes a lot of erroring
tests and navigation tests. Breaking them into smaller suites to avoid
the erroring on effect on others.

- metadata
- metadata-navigation
- metadata-thrown

Moved the metadata testing utils into `next-test-utils` for sharing
purpose.
Moved the hmr test to the bottom to avoid flakyness.
2024-06-19 14:46:21 +02:00