Commit Graph
213 Commits
Author SHA1 Message Date
Sebastian "Sebbie" SilbermannandGitHub b9d65b8afe [test] Assert on all errors in Redbox matchers (#77907) 2025-04-10 10:00:42 +02:00
Tim NeutkensandGitHub 6e51845ac4 Rename process.env.TURBOPACK to process.env.IS_TURBOPACK_TEST for tests (#77892)
Preparation for removing `process.env.TURBOPACK` being added to
Turbopack tests. That way we can properly test `next start` without
`process.env.TURBOPACK` being set.

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

-->
2025-04-07 14:07:55 +02:00
Sebastian "Sebbie" SilbermannandGitHub b7543a2f7f [test] Get rid of unrelated "Invalid hook call" error from tests using styled-components (#77736) 2025-04-03 10:08:01 +02:00
Zack TannerandGitHub 948d59faed exclude images and static media from dev origin check (#77417)
Excludes `/_next/image` and `/_next/static/media` as they don't contain sensitive information and prevents complications loading them in cases where they are inlined in CSS, as they'll be requested with `sec-fetch-mode: no-cors`. 

x-ref: https://github.com/vercel/next.js/issues/77344
2025-03-22 18:11:34 -07:00
Zack TannerandGitHub 74ff4f68a4 ensure /__next middleware URLs are included in the origin check (#77416)
We have special development endpoints that are also prefixed under `/__nextjs`. This updates the origin checking logic to account for those in addition to `/_next`, and adds a test.
2025-03-22 17:51:39 -07:00
Zack TannerandGitHub cdb9a8c3b3 switch development origin verification to be opt-in rather than opt-out (#77395)
To avoid breaking local development proxies and more complex setups,
this ensures that we only block cross-origin development requests when
opting into the configuration. In a future major release, this will not
be opt-in, and will require explicitly providing the allowed origins
that can access the special `/_next` endpoints.

This adds a warning when a cross origin request is detected that would
be blocked without explicit configuration.

Fixes #77073
Fixes #77253
Fixes #77344
2025-03-21 17:08:25 -07:00
JJ KasperandGitHub d928709b74 Add handling of origin in dev mode (#76880)
This ensures we don't allow cross-origin requests to be made to `/_next`
resources in dev mode. This matches existing handling that
webpack-dev-middleware does as well.
2025-03-06 22:35:58 +00:00
Sebastian "Sebbie" SilbermannandGitHub c9d93c45d2 [test] Use new Redbox matchers in pages/ gssp-ssr-change-reloading (#76788) 2025-03-04 13:46:31 +01:00
Will Binns-SmithandGitHub ad4977a757 Update error-recovery test snapshots for alternative bundler (#76299)
Passes an additional 4 tests for Rspack. Rspack error messages included
trailing whitespace when written to the DOM, so these are stripped out.
2025-02-22 22:42:11 +00:00
Jiachi LiuandGitHub 8e9f92b649 [dev-overlay] pick up build error message (#76290) 2025-02-21 14:10:39 +01:00
Jiwon ChoiandGitHub a89d55c011 [dev-overlay] Remove old Dev Overlay (#76256)
This PR removed the old overlay including the deprecated `buildActivity`
and `appIsrStatus` options.

Closes NDX-785
Closes NDX-855
Closes NDX-865
Closes NDX-866
Closes NDX-867
Closes NDX-868
2025-02-20 19:43:14 +09:00
1c85b755b5 [DevOverlay]: enable by default (#75882)
- `newDevOverlay: true` by default (enables experimental React builds on
canary until owner stacks progress further)
- `run-tests` now sets the env var for tests that were relying on it for
forking behavior
- PPR runners now run with the flag disabled to help catch regressions
in the old overlay until we remove it
- Fixed a number of tests that had outdated snapshots or missed forking
behavior because they weren't running in CI
- Disabled a test that was failing in Turbopack + Experimental React
that is unrelated to the overlay (see:
https://github.com/vercel/next.js/pull/75989)

---------

Co-authored-by: devjiwonchoi <[email protected]>
2025-02-13 10:57:32 -08:00
07e6680ddf Restore --no-mangling CLI option for next build (#75921)
The `--no-mangling` CLI option for `next build` was originally
introduced in #42633. However, we lost this feature during our migration
from Terser to SWC. As part of broader improvements for debugging
dynamic accesses with Dynamic I/O enabled, I needed this functionality
back, so I restored it for Webpack and also added it to Turbopack.

fixes #67037
fixes #50208

---------

Co-authored-by: Benjamin Woodruff <[email protected]>
2025-02-12 11:08:03 +00:00
Will Binns-SmithandGitHub f4177614a0 Split entrypoint/route handling into separate dev and prod versions (#75169)
Currently, for `handleEntrypoints`, `handlePagesErrorRoute`,
`handleRouteType`, etc, both dev and prod use cases are combined into
the same functions. This leads to a lot of branching, use-case-specific
arguments, etc. for minimal opportunity for shared code.

In a following PR, entrypoint writing for prod will be done through a
single napi call to rust, further branching the two versions.

This splits them formally, at the cost of duplicating a handful of lines
in each case. Perhaps in the future we can develop a better system for
sharing code, but this makes things far clearer and easier to maintain
in this moment.

Test Plan: CI
2025-01-23 14:25:27 +01:00
Jude GaoandGitHub 5c49eecba1 refactor: generic dev build indicator (#74615)
- Decoupled pages router specific logic from the dev build indicator to
extract a generic version
- Created a pages router specific initialize function for dev build
indicator to be called on pages router hydration
- This prepares for upcoming work on the dev build indicator for App
router
- Covered by [e2e
test](https://github.com/vercel/next.js/blob/jude/refactor-dev-build-indicator/test/integration/build-indicator/test/index.test.js)
2025-01-07 17:54:35 -05:00
Niklas MischkulnigandGitHub d3529bad5d Turbopack: next/dynamic use transitions instead of AST analysis (#73627)
- Before, there was a separate AST traversal that collected `next-dynamic` imports
- Now, we use transitions (which are inserted by the existing next-custom-transform) to tell Turbopack about the next-dynamic imports
	- Unlike Webpack (where the react-loadable identifiers are `path/to/parent-module -> ./imported-client`), Turbopack just uses the module id: `[project]/path/to/imported-client.js [app-client] (ecmascript, next/dynamic entry)`
	- the `next-dynamic` transition only inserts the marker module (i.e. for the SSR `import()`) 
	- the `next-dynamic-client` transition inserts the marker module and changes the module context (used to get the client module name)
- Now, we use the correct `AvailabilityInfo` for the next/dynamic chunks to preload, and they are not explicitly emitted. If they are for some reason not the same chunks that are actually emitted for the dynamic import, you get a hard error. (Previously, they didn't use the same `AvailabilityInfo` as the real async chunks, so they usually bundled another copy of React, and also had a different chunk name hash)
- For Turbopack, react-loadable manifests are now scoped per page instead of globally
2024-12-19 12:34:25 +01:00
Jiwon ChoiandGitHub ed267869c5 test: move HMR basic test to a separate file (#73612)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:41:15 +09:00
Jiwon ChoiandGitHub 02d5294cbe test: move HMR main test to a separate file (#73611)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:28:12 +09:00
Jiwon ChoiandGitHub abe7310747 test: move HMR Error Recovery test to a separate file (#73592)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:16:02 +09:00
Jiwon ChoiandGitHub 8f6dd894b2 test: move HMR Full Reload test to a separate file (#73591)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:05:50 +09:00
Jiwon ChoiandGitHub 3fbb2a6dd6 test: replace check to retry in hmr.test.ts (#73590)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

The test util `check` is deprecated internally, recommended to replace
to `retry`.
2024-12-07 04:29:46 +09:00
Tobias KoppersandGitHub 43c13f4e28 [Turbopack] add telemetry for persistent caching usage (#73554)
### What?

Report persistent caching as feature
2024-12-06 14:50:52 +01:00
Jude GaoandGitHub d6dd69f210 (e2e) module-level patchFileDelay flag (#72439) 2024-11-12 06:29:03 -05:00
Benjamin WoodruffandGitHub 80384ac110 Revert "feat(turbopack): Add an env var to debug-print the fast refresh invalidation reason (#72296)" (#72421)
Not sure why this is happening, but @kdy1 bisected this commit to a null pointer assertion error in napi: https://vercel.slack.com/archives/C03EWR7LGEN/p1730901839682439?thread_ts=1730899709.760659&cid=C03EWR7LGEN

Reverting until I can repro and root cause.

Closes PACK-3402
2024-11-06 11:10:18 -08:00
Benjamin WoodruffandGitHub 8abe1fd55b feat(turbopack): Add an env var to debug-print the fast refresh invalidation reason (#72296)
Setting the environment variable when building (`next dev`)

```
NEXT_TURBOPACK_INCLUDE_UPDATE_REASONS=1
```

causes `[Update Reasons]` messages to be logged to the terminal console (not in the browser) when a file is changed:

![Screenshot 2024-11-04 at 4.31.16 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/1af5a4f0-cfba-4ca8-b188-d6be2064b0dc.png)

These messages will not appear if no reason was recorded when the invalidation happened, so this provided on a best-effort basis.

**Why?** The hope is that this can help debug cases where users get stuck in a fast refresh update loop: https://vercel.slack.com/archives/C03S8ED1DKM/p1730737898652749

Closes PACK-3374
2024-11-05 10:49:41 -08:00
Tobias KoppersandGitHub 3b9889e1d8 [Turbopack] add new backend (#69667)
### What?

Add a new turbo-tasks backend that stores data normalized and is
prepared for persistent caching.

No longer keeps state in task locals, but all state is stored
immediately. This is required for persistent caching since it could
store and resume at any point and we always need to be in a valid state.

Tasks stay dirty until recomputed. (Previously dirty was changed to
scheduled)

### Why?

* Reduced memory usage
* preparation for persistent caching
2024-10-04 09:57:55 +02:00
hrmnyandGitHub 35a053a91a feat(turbopack): add support for polling file watcher (#69684)
### What?
The normal file watcher doesn't work inside a docker container, the
workaround is to enable a polling file watcher, which was supported in
webpack but not turbopack so far.

This PR adds support for a polling file watcher to turbopack and a
`next.config.js` option to configure the polling file watcher for both
webpack and turbopack.


Unfortunately, the rust file watcher seems to be a lot slower than the
poll interval.

Closes PACK-3206
Fixes #68255
2024-10-01 19:48:05 +02:00
Sebastian "Sebbie" SilbermannandGitHub 1cb6faaee1 Extend support of Pages router to React 18 (#70219) 2024-09-25 19:08:13 +02:00
Sebastian "Sebbie" SilbermannandGitHub 16ffa0323c Add extensive hydration error test suite for Pages router (#70342) 2024-09-24 17:25:39 +02:00
hrmnyandGitHub 0539477e7c types: improve napi binding typing using generated types (#69680)
### Why?

All the `any` and `unknown` types kept bothering me.

I've also removed some unused napi functions
2024-09-24 16:39:19 +02:00
Zack TannerandGitHub 12e5863c8f add missing node modules to externals (#70382)
We should not attempt to bundle builtin node modules on the server. This
adds modules provided by Node.js to our externals list (along with some
missing internal ones in Turbopack. These were copied from
[here](https://github.com/vercel/next.js/blob/a675bde6c738318264573144663e38819aeb2661/crates/next-custom-transforms/src/transforms/warn_for_edge_runtime.rs#L77-L89)).

Fixes #70262
Closes NDX-314
2024-09-23 19:51:30 -07:00
Tim NeutkensandGitHub 69f07b680c Revert "Support React 18 in Pages Router" (#69911)
Reverts vercel/next.js#69484
2024-09-10 10:20:27 +02:00
0f2845d2d8 Support React 18 in Pages Router (#69484)
Pages router (`/pages`) will continue to support React 18 not the React
19 RC. Current thinking is that we'll add support for React 19 in Pages
Router once 19 is stable.

This does not affect App Router (`/app`) which continues to use the
latest React Canary (i.e. React 19).

https://github.com/vercel/next.js/pull/65058 is required reading to
understand the changes in this PR

---------

Co-authored-by: Zack Tanner <[email protected]>
2024-09-09 15:26:08 -07:00
Tim NeutkensandGitHub ab493f1583 Turbopack dev/build: Initial browserslist passing (#69781)
## What?

This implements passing the browerslist config from Next.js to
Turbopack. Initially I implemented passing the user browserslist config
in this PR as well but found that when this is lowered it causes test
failures, those need to be investigated separately but shouldn't block
these changes landing.

<!-- 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-09-09 12:11:33 +02:00
Benjamin WoodruffandGitHub a7c56a5b6b fix(turbopack-ecmascript-plugins): Accept a partial object for StyledComponentsTransformConfig (#69474)
`StyledComponentsTransformConfig` should've used `#[serde(default)]` to
allow the user to provide a partial object with only some of the fields.

https://serde.rs/container-attrs.html#default

> When deserializing, any missing fields should be filled in from the
struct's implementation of `Default`. Only allowed on structs.

Without that, when serde tries to deserialize, it is expecting that the
object has all of it's fields filled in, and breaks because you've only
got two of them. The test suite only ever tested `styledComponents:
true` (not using an object), so it missed this.

## Test Plan

```
pnpm swc-build-native
TURBOPACK=1 TURBOPACK_DEV=1 pnpm test test/development/basic/styled-components
```
2024-08-29 16:41:31 -07:00
Wyatt JohnsonandGitHub f4c1a406e4 Partial Fallback Prerendering (#68958)
This work introduces the new concept of **Partial Fallback Prerendering
(PFPR)**.

Traditionally, when a dynamic page needed to be routed to that wasn't
pregenerated, it required a render to generate even the first few bytes
of the static page itself. This resulted in slow page loads for pages
not frequently visited and a reduced Time to First Byte (TTFB) score on
Core Web Vitals (CWV).

PFPR takes advantage of the new systems of Partial Prerendering (PPR)
that allows the application to suspend at different points mid-render,
and resume it later. We mark any unknown parameter access as dynamic
access, and suspend the rendering up to the next suspense boundaries at
those points. Under ideal conditions (correctly placed `<Suspense />`
boundaries or `loading.jsx` files) this generates a static shell that
can be served to users as soon as the request hits Next.js, right out of
the static cache. This minimizes the TTFB for all requests, dynamic or
not for those pages that enable PPR. For example, the following page
would create a usable shell:

```jsx
// /app/users/[userID]/page.jsx
import { Suspense } from 'react'

function Profile({ params }) {
  const { userID } = params
  return <div>Hello {userID}!</div>
}

export default function ProfilePage({ params }) {
  return (
    <div>
      <h1>User Profile</h1>
      <Suspense fallback="Loading...">
        <Profile params={params} />
      </Suspense>
    </div>
  )
}
```

Due to the way that suspense works within React components, access of
params within the root page component would cause the whole page to
suspend. Thankfully, that's where the `loading.jsx` comes in handy.
Adding a `loading.jsx` at a segment will automatically wrap the
`page.jsx` with a suspense boundary, setting the contents of the root
`loading.jsx` as the fallback component to use for it. This lets you
maintain your existing style of accessing parameters at the root of the
components while also taking advantage of PFPR.

To enable this feature, you first need to enable both PPR and PFPR:

```js
module.exports = {
  experimental: {
    ppr: true,
    pprFallbacks: true,
  }
}
```

Once PFPR has stabilized with hosting providers, the experimental flag
will go away and it will become the default with the PPR flag.
2024-08-27 22:31:18 -07:00
Mark KnichelandGitHub d2cfaf4a04 Fix issue with afterFiles rewrites not working when prefixed with assetPrefix (#68694)
This PR fixes two issues with the use of `assetPrefix`:

#1: https://github.com/vercel/next.js/issues/64710
`assetPrefix` needs to be handled in `dev`, `deploy`, and `start`. In
the current approach, only `dev` and `start` were handled, but a quirk
of the implementation caused rewrites for non-asset paths to not be able
to be used in `afterFiles` rewrites.

#2: When deploying Next.js (such as on Vercel), you need to add your own
`beforeFiles` rewrite for `/${assetPrefix}/_next/...` requests or
otherwise they would 404.

This PR creates an automatically added `rewrite` to `beforeFiles` that
handles the case for `dev`, `start`, and `deploy`, removes the existing
logic in `filesystem.ts`, and adds more tests to check the behavior.
2024-08-15 09:51:58 -07:00
be10d2a528 Turbopack HMR: Reload the page when server session changes (#68630)
It’s possible to the following scenario to occur:

- Browser loads a page and establishes HMR connection
- User quits the server, makes changes, and restarts the server
- The browser reloads, the user makes more changes, and the two reach an
inconsistent state

To avoid this, reload the browser when the server changes. This already
happened with webpack, so implement it for Turbopack.

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

---------

Co-authored-by: Tobias Koppers <[email protected]>
2024-08-07 18:41:24 -07:00
JJ KasperandGitHub 0130859845 Update flakey HMR test with turbopack (#68495)
x-ref:
https://github.com/vercel/next.js/actions/runs/10228171055/job/28301119519
x-ref:
https://github.com/vercel/next.js/actions/runs/10231169480/job/28307004087
x-ref:
https://github.com/vercel/next.js/actions/runs/10230841136/job/28306121160
2024-08-05 08:46:44 -07:00
509c7909c2 Remove legacy next/link prefetch={true} warning (#68326)
## What?

Removes the warning shown in Pages Router when you use the `prefetch`
prop on `next/link`. In App Router using `prefetch={true}` opts in to
full page prefetching even when the route is dynamically rendered.

When you're working on an application that uses both pages router and
app router where the components are shared using `<Link prefetch>` would
then cause this warning in Pages Router but not in App Router.

With this change there won't be a warning in Pages Router.

<!-- 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 <[email protected]>
2024-07-30 16:36:00 +00:00
c18fcf28fe Fix hmr assetPrefix escaping and reuse logic from other files (#67983)
<!-- 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 #

-->

### Fixing a bug

fixes #63820
fixes #55320
fixes #52931

In one of the issues, there was a suggestion to delete `assetPrefix`
from `next.config`. It helps if you have `assetPrefix: '/'`. Otherwise,
you probably won't face this problem.

**Explanation:**

The problem lies where the browser tries to connect and where websocket
is available on the server.

Adjust the condition for `prefix` in `get-socket-url` as it can return
`''` which will lead to `//` in the url.

The browser wants to connect to `ws://localhost:3000/_next/webpack-hmr`
While internally next exposes the web socket under
`ws://localhost:3000//_next/webpack-hmr` - you can connect to it via
wscat, postman or whatever.
As the path is different it does not handle HMR requests in the browser.

In addition to that - Reuse logic and extract separate files as a helper
in shared/lib.

| Before | After |
| ------ | ------- |
| ![before - latest canary
branch](https://github.com/user-attachments/assets/c26c8b20-1352-49c6-a099-101394438ba0)
before - latest canary branch - we can't establish a connection to HMR
ws |
![after](https://github.com/user-attachments/assets/26500e68-bc4d-44ca-b418-f9bda6bc9aa6)
same example with local changes - connected to ws |

---------

Co-authored-by: Jiwon Choi <[email protected]>
Co-authored-by: JJ Kasper <[email protected]>
2024-07-29 18:36:43 -07:00
Donny/강동윤andGitHub 8063a51ea8 Update swc_core to v0.96.9 (#67378)
# Turbopack
* https://github.com/vercel/turbo/pull/8686 <!-- Tobias Koppers -
improve performance of the graph aggregation -->
* https://github.com/vercel/turbo/pull/8694 <!-- Benjamin Woodruff -
Replace `unreachable` with `bail` in `finalize_css` -->
* https://github.com/vercel/turbo/pull/8661 <!-- Benjamin Woodruff -
Create a minimum viable `ResolvedVc` type -->
* https://github.com/vercel/turbo/pull/8662 <!-- Benjamin Woodruff - Add
a minimum viable ResolvedValue marker trait -->
* https://github.com/vercel/turbo/pull/8678 <!-- Benjamin Woodruff - Add
derive macro for ResolvedValue -->
* https://github.com/vercel/turbo/pull/8715 <!-- Benjamin Woodruff -
Switch RcStr from std::sync::Arc to triomphe::Arc -->
* https://github.com/vercel/turbo/pull/8699 <!-- Donny/강동윤 - perf: Merge
multiple `EsmBinding` -->
* https://github.com/vercel/turbo/pull/8720 <!-- Benjamin Woodruff - Add
support for `#[turbo_tasks::value(resolved)]` and
`#[turbo_tasks::value_trait(resolved)]` -->
* https://github.com/vercel/turbo/pull/8706 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.96.9` -->

### What?

Update SWC crates to
https://github.com/swc-project/swc/commit/226617e73edb2070ea1d4be2da93239b3f3ebc88
and
https://github.com/swc-project/plugins/commit/b7658c3153b1f1e3c941bc0f6bdae6856f5d278c

### Why?

To keep in sync

### How?

 - Closes https://github.com/vercel/next.js/issues/64890
 - Closes https://github.com/vercel/next.js/issues/63104
2024-07-12 07:39:29 +00:00
Will Binns-SmithandGitHub 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
Sebastian SilbermannandGitHub 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
Hendrik LiebauandGitHub 994d8ee2c3 Fix broken BrowserInterface type (#66461) 2024-06-03 12:56:49 +00:00
Jiachi LiuandGitHub 47769d14bc Remove swc minify related code branches (#65690)
### What

Remove `swcMinify` related branches as the option is deprecated and it's
always enabled

* Remove the related branches for checking `config.swcMinify`
* Remove the related telemetry about `swcMinify`
2024-05-13 23:37:37 +02:00
hrmnyandGitHub 64b718c661 chore: update prettier to 3.2.5 (#65092) 2024-05-08 21:47:14 +02:00
dcff078936 Re-land build(edge): extract buildId into environment (#65426)
### What

* Extract `buildId` and server action encryption key into environment
variables for edge to make code more deterministic
* Fixed the legacy bad env names from #64108
* Always sort `routes` in prerender manifest for consistent output
* Change `environments` to `env` in middleware manifest, confirmed with
@javivelasco this is a fine change without need to bumping the version

### Why

Dynamic variants like `buildId`, SA `encryptionKey` and preview props
are different per build, which results to the non determinstic edge
bundles. Once we extracted them into env vars then the bundles become
deterministic which give us more space for optimization


Closes NEXT-3117

Reverts vercel/next.js#65425

Co-authored-by: Jiachi Liu <[email protected]>
2024-05-08 10:40:15 +02:00
2c31c79ac8 Support React 19 in App and Pages router (#65058)
Closes NEXT-3218

---------

Co-authored-by: Jiachi Liu <[email protected]>
2024-05-07 18:18:32 +02:00
JJ KasperandGitHub 85a874a35b Revert "build(edge): extract buildId into environment" (#65425)
Needs to hold until upstream roll-out

Reverts vercel/next.js#64521
2024-05-06 16:54:23 -07:00