Commit graph

18066 commits

Author SHA1 Message Date
JJ Kasper
003ec7a15b
Increase build-native CI job timeout (#57314)
This is currently timing out so this increases the timeout for Windows
specifically
2023-10-23 20:52:39 -07:00
Jimmy Lai
cb5d075758
misc: fix bundling of experimental (#57311)
this removes the call to experimental static react when not using the experimental build
2023-10-24 03:30:08 +00:00
Shu Ding
4eaefbab66
Optimize server bundle size (#57305)
These are not used by the Next.js server and can save up to 15% size of the base Edge worker by ignoring them.
2023-10-24 02:18:27 +00:00
Wyatt Johnson
69388a52fe
Partial Prerendering (#57287)
This PR introduces a build optimization to create a "partial prerender" of the page.

1. During compilation, we create a static shell for the page using your existing Suspense boundaries. Components that can be static will be included in this static shell, leaving holes for the dynamic components.
1. Using `<Suspense />`, we can define fallbacks to be included in the partial prerender, as well as the holes for the dynamic components to stream into.

This means Next.js can initially serve a static loading skeleton, kicking off the dynamic parts in parallel. Then, the dynamic components stream in on demand. Dynamic components can use `cookies()`, `headers()`, `'cache': 'no-store'`, or `unstable_noStore()` to opt-into dynamic rendering.

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-10-24 01:13:05 +00:00
Leah
679a398e49
fix(turbopack): write manifests for edge app pages and use proper edge entry (#56675)
### Description

- We previously didn't write to the shared `middleware-manifest.json` for edge app pages
- We also need to manually write to the `_ENTRIES` object in turbopack entries because it currently doesn't have a way to change the output type like webpack: https://webpack.js.org/configuration/output/#type-assign-properties
- Also need to write a bunch of manifests as JS files to be able to load them from the edge runtime.
- Some import map fixes were needed as well.

This only fixes dev, build will need more work.

Closes WEB-1698
2023-10-24 00:47:55 +00:00
vercel-release-bot
dc7b5d806e v13.5.7-canary.20 2023-10-24 00:35:28 +00:00
Shu Ding
78ffea42ee
Fix client reference proxies (#57301)
Each individual exported component should be a proxied reference. Not sure why it's been broken for so long and it didn't trigger any error.
2023-10-24 00:24:22 +00:00
Jimmy Lai
ce085b56dd
revert "React Aliases (#57283)" (#57299)
This reverts commit 9f512f1cca.

<!-- 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: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-23 16:59:55 -07:00
Zack Tanner
b1d1ed6087
only log export-no-custom-routes warning if unsupported (#57298)
This doesn't need to error, we can instead warn that the functionality will not work as expected out of the box. Support can be added for outside of Next for this to behave as expected. 

These are supported when deployed via the Nextjs builder ([x-ref](https://github.com/vercel/vercel/blob/main/packages/next/src/index.ts#L851-L855)).
2023-10-23 23:58:41 +00:00
Donny/강동윤
4bbf9b6c70
Add __nextjs_pure helper (#57286)
### What?

Safely drop `__nextjs_pure` from next internals in transform

```js
import {__nextjs_pure} from 'next/dist/build/swc/helpers'

__nextjs_pure(console.log("test!"))


```

becomes


```js
/*#__PURE__*/ console.log("test!");

```

so it will be dropped by the minifier - terser and swc minifier will
both work.

### Why?

Adding pure comments from JS world with swc transform is complex. This
would be a helper for the case if we want to create "pure" expressions.


### How?



Closes WEB-1829

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-10-23 16:44:44 -07:00
Jon Meyers
d0e92b19af
chore: Refactor with-supabase example to use ssr package (#57100)
### What?

[1] Refactors `with-supabase` example to use new `@supabase/ssr` package
[2] Makes landing page dynamic steps to connect Next.js to Supabase
[3] Fixes a range of small bugs

### Why?

[1] Simplifies creating a Supabase client
[2] People were not understanding how to connect this template to Supabase
[3] People don't like bugs

### How?

[1] Declares a separate `createClient` function for client and server. Client version is used in Client Components, server version is used every where else - Server Components, Route Handlers, Server Actions, Middleware
[2] Makes landing page a dynamic list of next steps to guide the user to success
[3] Writing code to squash the bugs!
2023-10-23 23:34:10 +00:00
vercel-release-bot
7c803a762e v13.5.7-canary.19 2023-10-23 23:24:21 +00:00
Shu Ding
661c598a21
Improve encryption of Server Actions bound values (#57297)
Removes the constant prefix and action ID from the IV value and makes it a fully random string. Then, we prefix the actual payload with the action ID to avoid submitting the payload from a different action, as well as using it as the checksum of the encryption data to ensure it's not damaged.
2023-10-23 23:18:49 +00:00
Andrew Clark
a77acd22ad
Update React from d803f519e to b8e47d988 (#57296)
React upstream changes:

- https://github.com/facebook/react/pull/27570
- https://github.com/facebook/react/pull/27569
- https://github.com/facebook/react/pull/27550
- https://github.com/facebook/react/pull/27559
- https://github.com/facebook/react/pull/27552
- https://github.com/facebook/react/pull/27504
- https://github.com/facebook/react/pull/27522




Co-authored-by: Josh Story <2716369+gnoff@users.noreply.github.com>
2023-10-23 22:58:50 +00:00
vercel-release-bot
8fb5c8517f v13.5.7-canary.18 2023-10-23 22:17:01 +00:00
Jimmy Lai
9e050fba94
perf: remove parse-body from the server runtime (#57280)
This PR removes the `raw-body` dependency from the server runtime. It
still is used in the pages runtime but at least if you're only using
app, you won't bundle your server function with it.

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

-->
2023-10-23 15:11:09 -07:00
JJ Kasper
7a1b01b85d
Skip i18n-ignore-rewrite-basepath-source irrelevant tests with turbopack (#57295)
Same as https://github.com/vercel/next.js/pull/57289 for another test
suite.
2023-10-23 15:01:24 -07:00
JJ Kasper
dc4138db0a
Update unrelated mdx tests with turbopack (#57294)
The non-mdxrs version of the plugin isn't expected to work with
turbopack so this skips it in that mode
2023-10-23 14:48:39 -07:00
JJ Kasper
639bc3af10
Increase concurrency for turbopack test run (#57290)
Aims to reduce run time by leveraging more concurrency

x-ref: https://github.com/vercel/next.js/actions/runs/6618039974/job/17975622987
2023-10-23 21:27:17 +00:00
JJ Kasper
1275cffe78
Skip i18n-ignore-rewrite-source irrelevant tests with turbopack (#57289)
These tests are expecting files to be written but this isn't the case
with turbopack for client files.
2023-10-23 14:13:49 -07:00
Wyatt Johnson
9f512f1cca
React Aliases (#57283)
This adds aliases to the new react packages being used by Next.js.
2023-10-23 21:04:26 +00:00
Wyatt Johnson
4661764621
Enhance Buffered Transform Stream (#57267)
This adds some better handling around the buffered transform streams to handle error cases a bit better.
2023-10-23 20:05:57 +00:00
Wyatt Johnson
f154bb8313
Revalidate Header Updates (#57162)
Update the revalidate handling to perform the revalidate option coalescing in the render function closer to the render result output. This helps reduce the amount of scope leak from the render.
2023-10-23 19:37:46 +00:00
Jiachi Liu
cc4cceb4f0
Polish compiling and turbopack logging (#57270)
## Make server info log faster

Change to display the server info earlier before server handler is ready

## Make "compiling" message less laggy.

Change to log the compiling logs as previous timer which trying to skip the logging short-time compiling message makes it bit laggy, so we're removing it for now. Reduce the timer from 3s to 500ms

<img width="360" alt="image" src="https://github.com/vercel/next.js/assets/4800338/19afb2d6-ec42-4a67-b664-60f8c36b5287">


## Remove the turbopack

### Now
<img width="398" alt="image" src="https://github.com/vercel/next.js/assets/4800338/fb24d83f-66d0-4383-a42b-fdeff4fe223a">

### Before

<img width="398" alt="image" src="https://github.com/vercel/next.js/assets/4800338/59d6a6f2-32d6-41d1-a80d-12c599165e6a">
2023-10-23 19:28:36 +00:00
JJ Kasper
191faf392c
Import turbo daily integration test workflows (#57083)
As discussed this imports our daily turbo integration tests workflow
into the Next.js repo
2023-10-23 11:48:38 -07:00
Jiachi Liu
4e1429182f
Move logging option to stable (#56791)
We introduced a data fetching logging before, and the control option was under experimental. After a bit experiments turns out users really loves it. We decide to move it to a stable option.

### Changes
We're going to move the `logging` option outside of `experimental`, and scope the `fetches` related config under `logging.fetches`.

```js
// next.config.js
logging?: {
    fetches?: {
      fullUrl?: boolean
    }
}
```
2023-10-23 18:45:00 +00:00
Wyatt Johnson
b3845460f8
Update Pathname Normalizers (#57161)
This collects some of the request pathname normalization code into some helpers.

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-10-23 18:25:49 +00:00
vercel-release-bot
799e6ca65a v13.5.7-canary.17 2023-10-23 18:13:11 +00:00
Shu Ding
a255e02879
Simplify iv prefixing of Server Actions encryption (#57274)
Since we have a fixed length of the random bytes prefixed to the iv,
there's no need to split by `:`.
2023-10-23 11:06:59 -07:00
Steven
ab9bada7b7
chore(export)!: remove next export in favor of output: export in next.config.js (#57085)
BREAKING CHANGE

Since `next export` has been printing a deprecation warning since https://github.com/vercel/next.js/pull/47376, its safe to remove in semver-major.

The upgrade path is to simply add `output: 'export'` in `next.config.js` - everything will continue to work the same.

This config greatly improves the `next dev` experience today. And in the future, it will improve performance of `next build` because we no longer need to do two passes (build then export).
2023-10-23 18:03:58 +00:00
Jimmy Lai
7208535786
perf: fix memory leaks in the edge runtime in dev (#57235)
This PR fixes a memory leak when using `next dev` where on HMR, we would always retain the memory associated with the old VM instance, leading to pretty egregious usage of RAM after only a few edits.

The leak itself comes from methods like `setTimeout` and `setInterval` capturing the context in which they were called and somehow never releasing, even if the timeout happened, when running in a Node.js `vm`. This is probably a Node.js bug.

The fix consists of taking ownership of all timeouts and clearing them ourselves manually at the end of each VM lifecycle.

Tested manually:
- hello world Next.js app with edge runtime
- triggered hmr 10 times
- memory usage
  - base: 400MB
  -  before: 800MB
  - after: 400MB
2023-10-23 17:51:06 +00:00
Shu Ding
eb4b41e513
Fix unmatched WebSocket upgrade requests being closed (#57245)
We should not close unmatched sockets as it might be handled by user's server.

Fixes #56996
Fixes #49334
Fixes #55299
2023-10-23 17:23:34 +00:00
Ahmed Abdelbaset
4a37c2d1a1
chore: fix a typo (#57272) 2023-10-23 17:10:35 +00:00
Shu Ding
67415750f3
Improve encryption of Server Actions closure arguments (#57227)
This change makes sure that the iv of AES-GCM encryption is cryptographically random on each request. Also added a constant prefix as some kind of checksum to ensure the data is not damaged (e.g. wrong key is being used).
2023-10-23 16:53:15 +00:00
Jiachi Liu
b0e3a67edb
Fix relative metadata url resolving on windows (#57265)
x-ref: https://dev.azure.com/nextjs/next.js/_build/results?buildId=71544&view=logs&j=8af7cf9c-43a1-584d-6f5c-57bad8880974&t=7ae70e63-3625-50f4-6764-5b3e72b4bd7a

We need to use poxis join for url pathname

```
- Expected  - 1
+ Received  + 1
  Object {
    "itunes": Object {
-     "appArgument": "http://test.com/base/test/native/app",
+     "appArgument": "d:\\test\\native\\app",
    },
    "metadataBase": "http://test.com/base",
  }
  210 |       ]
  211 |       const metadata = await accumulateMetadata(metadataItems)
> 212 |       expect(mapUrlsToStrings(metadata)).toMatchObject(
      |                                          ^
  213 |         mapUrlsToStrings({
  214 |           metadataBase: new URL('http://test.com/base'),
  215 |           itunes: {

```
2023-10-23 16:38:51 +00:00
Tim Neutkens
e6b103b85b
Simplify options passed to createWebpackAliases (#57239)
Reducing the options so it becomes easier to call it outside of
webpack-config.ts, which would be needed to pass it to Turbopack.

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

-->
2023-10-23 09:04:05 -07:00
Tobias Koppers
c2ba7e6a16
Turbopack: fix over-invalidation of node.js assets (#57240)
### What?

* no need to clear require cache when assets where not used previously
* make build status reporting more consistent
* report build status to client side for build indicator

### Why?

### How?


Closes WEB-1826
2023-10-23 17:56:47 +02:00
Tim Neutkens
6adb9716c5
Add CompilerAliases Type (#57237)
Ensures all functions in create-compiler-aliases.ts have the same return type.
2023-10-23 15:52:43 +00:00
Tim Neutkens
a65e5c07a8
Remove reactServerCondition property as it is not used (#57236)
Removes the unused properties from createRSCAliases.
2023-10-23 03:23:05 +00:00
vercel-release-bot
dc88b413f8 v13.5.7-canary.16 2023-10-23 03:07:00 +00:00
Donny/강동윤
652a553a13
Update swc_core to v0.86.10 (#57121)
### What?

Update SWC crates. This PR fixes a regression of `swc_core`.
The important PR: https://github.com/swc-project/swc/pull/8153

### Why?

There was a regression in `swc_core`.

### How?

-  Fixes #56408

Closes WEB-1811

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-23 05:01:31 +02:00
Jiachi Liu
c5207751a2
Polish turbopack start logging (#57203)
Bring a tiny util to get a `(turbo)` label after next.js info for turbopack dev-server logging and also remove the disclaimer of "thank you for trying".

### After

<img width="597" alt="image" src="https://github.com/vercel/next.js/assets/4800338/c3658775-3ce6-48fc-8128-7baebe9f104b">


### Before

<img width="597" alt="image" src="https://github.com/vercel/next.js/assets/4800338/d008dd0b-4c58-4612-b1c4-d5e97e041c1b">


* Fixes the bad dim color
* Colorize the `Next.js (turbo)` label
* Move the learning link down after start message
* Use Log util to format logs
* Remove "v13" related text
2023-10-23 02:53:40 +00:00
Jiachi Liu
ac00e86452
test: stablize the metadata url tests (#57204)
x-ref: https://dev.azure.com/nextjs/next.js/_build/results?buildId=71307&view=logs&j=8af7cf9c-43a1-584d-6f5c-57bad8880974&t=7ae70e63-3625-50f4-6764-5b3e72b4bd7a
2023-10-23 02:18:43 +00:00
Tim Neutkens
823fe7ffa4
Remove scheduler/tracing alias as the file no longer exists (#57234)
This file has been removed from React for a long time, it's no longer relevant.
2023-10-23 02:07:48 +00:00
Tim Neutkens
87c8e01679
Move webpack aliases into separate file (#57233)
Refactoring the webpack-config.ts file to no longer have all aliases defined, instead they are in a separate file which should make refactoring these to use them in Turbopack simpler.
2023-10-23 01:26:46 +00:00
Tobias Koppers
b64c0426bc
update turbopack (#57176)
* https://github.com/vercel/turbo/pull/6241 <!-- Tobias Koppers - make
the daily ci faster -->
* https://github.com/vercel/turbo/pull/6242 <!-- Justin Ridgewell - Add
caching to `chunk_content`'s graph walking -->
* https://github.com/vercel/turbo/pull/6228 <!-- Tobias Koppers - Reduce
resolve and resolving tasks -->
* https://github.com/vercel/turbo/pull/6244 <!-- Tobias Koppers - avoid
cloning list -->
* https://github.com/vercel/turbo/pull/6246 <!-- Tobias Koppers - fix
symlink handling -->

Closes WEB-1819
2023-10-23 02:42:29 +02:00
Jimmy Lai
1836998e52
perf: memory usage tweaks (#57163)
This PR does two things:
- bring back the logic to restart the dev server when approaching 80% of
the heap limits
- add some logic to increase the default Node.js memory usage to 50% of
the available RAM

Tested manually

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

-->
2023-10-22 17:26:48 -07:00
vercel-release-bot
2762511796 v13.5.7-canary.15 2023-10-22 23:22:41 +00:00
Tim Neutkens
8074fc171f
Leverage defineEnv for all environment variables in Turbopack (#57196)
This ensures all `process.env` replacement comes from define-env in
Next.js, instead of also applying it partially on the Rust side.
<!-- 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 #

-->
2023-10-22 15:37:48 -07:00
OJ Kwon
85c3ea8e5b
fix(next-core): align edge chunking context's asset root (#57022)
### What?

If there's a static asset with edge runtime config, turbopack will bail with

```
 ⨯ ModuleBuildError: Code generation for chunk item errored
An error occurred while generating the chunk item [project]/test/e2e/app-dir/metadata/app/icon.svg (static, edge rsc)

    Caused by:
    - expected output_root to contain asset path

    Debug info:
    - An error occurred while generating the chunk item [project]/test/e2e/app-dir/metadata/app/icon.svg (static, edge rsc)
    - Execution of <DevChunkingContext as ChunkingContext>::asset_url failed
    - expected output_root to contain asset path
```

Since we creates chunking context for the edge with different output_root and asset_root, by using asset_root to be client_root. The other places creating context with  `DevChunkingContext` don't do this, PR simply adjusting root to be output_root.

For the server's chunking context it actually accepts client_root and set the asseturl with client root instead. However not sure if that's what we want with devchunkingcontext.

This is part of metadata fixes for the test; however edge rendering still doesn't work so test doesn't pass yet.

Closes WEB-1798
2023-10-22 19:15:09 +00:00