Commit graph

1173 commits

Author SHA1 Message Date
Shu Ding
4c3f59f88d
Implement server entry creation in client layer (#47127
In short, this PR adds a 3rd layer to the server compiler. This extra
layer is for marking the modules when re-entering the server layer from
a client component. It is almost identical to the existing server layer
and it should have all the same bundling and runtime behaviors, but it's
still special because it's not allowed to enter the client layer again
from there.

Because of that, we create the extra entry for that new layer when the
client layer compilation finishes in the `finishModules` phase. The new
entry is handled normally as it's in the server layer. But the original
module in the client layer will be compiled specially as special no-op
exports, and will then be connected via the `callServer` wrapper.

fix NEXT-809 ([link](https://linear.app/vercel/issue/NEXT-809)).
2023-03-15 23:58:18 +01:00
Justin Ridgewell
02125cf3b1
Implement custom Turbopack Next transformers (#47137)
Builds on https://github.com/vercel/turbo/pull/4202 to implement custom Next.js Transformers in Turbopack.

This is the final piece to moving the `next-*` crates to Next. While we've _technically_ moved everything, Turbopack didn't support running custom transformers. So we're actually stuck on the last version we cut before deleting the next crates, running the transformers that exist in the turbopack repo. With the new support, we're almost back to the tip of main branch (there's still some snafu with `swc_core` upgrading that I'm working on).

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-03-15 19:10:59 +00:00
Shu Ding
4824d96fab
Fix RenderOpts type import (#47167)
Something missed in #47128.
2023-03-15 18:07:16 +00:00
Tim Neutkens
e6f33ec3a1 v13.2.5-canary.4 2023-03-15 11:55:55 +01:00
Tobias Koppers
c27b546908
re-enable next-dev-tests (#47087)
### What?

enables the next-dev-tests crate integration tests from trubopack

### Why?

to unblock the move PR we temporarily disabled the tests

### How?

Fix the new location and fix the expect dependency

Fixes WEB-708

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-03-14 16:05:19 +01:00
JJ Kasper
6706a2a6ba
v13.2.5-canary.3 2023-03-13 21:46:07 -07:00
Shu Ding
b21c85bcea
Detect common invalid cases for the server directive (#47069)
It will be crucial to detect these common problems and abort compilation, because it's intended to be using a server boundary but these problems might cause it ending up in the client.

Fixes NEXT-762.
2023-03-13 19:20:10 +00:00
JJ Kasper
0b3e357808
v13.2.5-canary.2 2023-03-13 11:46:11 -07:00
Shu Ding
b146da6037
Refactor renderers and RenderResult (#46955)
This PR does two major changes:

1. Make sure both pages renderer and app renderer return `RenderResult`,
no more `null`. This was achieved with a new `null` type in the
constructor `new RenderResult(null)`, and a `.isNull()` method.
2. Remove all mutations of the `renderOpts` object inside renderers. To
pass extra information out, they need to be attached to the
`RenderResult` now. This also requires 1) to be done.

These changes are the initial steps to the isolated rendering worker
architecture. Besides those there're also some type improvements.

Fixes NEXT-807.

---------
2023-03-13 10:53:43 -07:00
Justin Ridgewell
8ae2df0f10 Integrate next-* crates from Turbopack (#47019)
Update workspace cargo deps
Update cargo deps to point to local workspace
Ignore too-many-arguments warnings
Fix clippy errors
Update pnpm workspaces
exclude integration tests from unit tests CI
rust-analyzer settings
add rust flags and env vars
2023-03-13 14:33:17 +01:00
Tobias Koppers
b98469c86b Merge df38582da of vercel/turbo into canary 2023-03-13 14:23:56 +01:00
LongYinan
cbd3c2983a
Cleanup remove directive logic to reduce allocate (#47055)
Reduce `unwrap` and `clone` usages
2023-03-13 10:25:04 +00:00
Shu Ding
25aa8693ad
Rewrite action transform in SWC (#47049)
This is almost a rewrite of the transform to simply some logic. For a `"use server"` file we now simply annotate every exported identifier and will later do runtime checks. This is because that we can't statically know the source of exported values.

This rewrite also makes it possible to annotate anonymous arrow functions.

Thanks to @kdy1 for some of the suggestions here.

Closes NEXT-708, closes NEXT-421.
2023-03-13 06:59:21 +00:00
Tim Neutkens
287ad83399 v13.2.5-canary.1 2023-03-11 20:41:30 +01:00
Tobias Koppers
2e51690143 avoid sending modules in parent for dynamic imports (vercel/turbo#4056)
### Description

Keeps track of available modules when importing new chunk groups. Omits
assets that are already available in the parent chunk group(s) when
determining assets to be included in chunks.

### Testing Instructions

Dynamic imports should not include modules that are already in the
parent chunks

<!--
  When the below is checked (default) our PR bot will automatically
  assign labels to your PR based on the content to help the team
  organize and review it faster.
-->

- [x] Auto label
fixes WEB-599
2023-03-10 19:42:22 +00:00
OJ Kwon
4bea437c7d feat(ecmascript): transform ts input with runtime flags (vercel/turbo#4142)
### Description

Another attempt to close WEB-659.

The crux is same as previous PR, but attempt to change the location
where it read config / bubble down the config values to the actual
transform stage. Mainly, `enable_typescript_transform` is now accepting
an option instead of boolean flag to down to
`EcmaInputTransform::Typescript`, and `get_*_module_context()` reads the
config value as needed.
2023-03-10 18:23:29 +00:00
Tim Neutkens
7d48edfe8e v13.2.5-canary.0 2023-03-10 18:06:16 +01:00
Tobias Koppers
7e5881b72a
update turbopack (#46994)
# Bugfixes

* https://github.com/vercel/turbo/pull/4149
* https://github.com/vercel/turbo/pull/4151

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-10 17:59:48 +01:00
Shu Ding
d200e5fa1d
Support default arrow function export in server boundary (#46977
This PR adds basic support for default export of an async arrow
function:

```js
export default async (a, b) => { console.log(a, b) }
```

In upcoming PRs I'll refactor named export handling and inlined
declarations.
2023-03-10 14:38:51 +01:00
Tobias Koppers
01f2524392 fix pathname for data requests (vercel/turbo#4149)
### Description

| input file         | HTML pathname | Data pathname    |
| ------------------ | ------------- | ---------------- |
| index.tsx          | /             | .../index.json   |
| blog.tsx           | /blog         | .../blog.json    |
| pricing/index.tsx  | /pricing      | .../pricing.json |
2023-03-10 08:40:43 +00:00
JJ Kasper
05f6de1086
v13.2.4 2023-03-09 16:41:28 -08:00
JJ Kasper
1ce3b36179
v13.2.4-canary.9 2023-03-09 14:46:45 -08:00
Justin Ridgewell
8e14b672cc
Update Turbopack to 230309.2 (#46971)
# New Features
- https://github.com/vercel/turbo/pull/3975

# Bug Fixes
- https://github.com/vercel/turbo/pull/4129
- https://github.com/vercel/turbo/pull/4134
- https://github.com/vercel/turbo/pull/4062

# Performance
- https://github.com/vercel/turbo/pull/4093
2023-03-09 13:24:24 -08:00
Tobias Koppers
511b244f4a improve introspection (vercel/turbo#4135)
### Description

Add more details to introspection and make it more robust to errors
during introspection

### Testing Instructions

go to http://localhost:3000/__turbopack__/
2023-03-09 16:08:03 +00:00
Tobias Koppers
42fa76a3f7 fix app dir with latest next.js (vercel/turbo#4134)
### Description

* [fix manifest for
__ssr_module_mapping__](4abd87312d)
* [add missing styled-jsx
alias](d9b4a4df7f)

### Testing Instructions

layout-playground
2023-03-09 16:05:29 +00:00
Alex Kirszenberg
2ffcc59ea7 Merge EcmascriptChunkUpdates before sending them to the client (vercel/turbo#3975)
This diff:
* introduces the `VersionedContentMerger` trait, which allows for
merging the updates of versioned contents within the same chunk group;
* implements this for `EcmascriptChunkContent`/`EcmascriptChunkUpdate`,
turning them into
`EcmascriptMergedChunkContent`/`EcmascriptMergedChunkUpdate`;
* creates a new `ChunkList` asset which is capable of merging chunk
updates of chunks within the same chunk group, and create such an asset
for dynamic chunks (through manifest/loader_item.rs) and chunk group
files assets.

This fixes a bunch of edge cases related to HMR:
* HMR of dynamic imports now works;
* Chunks getting added/deleted/renamed now also works with HMR, since
we're listening to updates at the chunk group level;
* CSS chunks get reloaded in the right order, with respect for
precedence.

There are still known edge cases with HMR:
* CSS chunks added through HMR are not inserted at the right position to
respect precedence (WEB-652).
* Update aggregation is disabled because we don't want a critical issue
to stop all HMR (WEB-582) . This would be fixed by applying aggregated
updates when dismissing the error modal, but there are some edge cases
with this too (e.g. what happens when an HMR update also causes an error
on top of an existing error).
2023-03-09 11:13:04 +00:00
JJ Kasper
715f96fb49
v13.2.4-canary.8 2023-03-08 16:06:57 -08:00
Shu Ding
ddff41a908
Support re-exporting unnamed function expression (#46936)
Add support for cases like:

```js
const foo = async function () {}
export default foo

const bar = async function() {}
export { bar }
```

Also fix a bug where nested async function declarations are mistakenly
counted as actions.

Fixes NEXT-800.
2023-03-08 15:07:31 -08:00
Tobias Koppers
e6103ae6dd update next.js version (vercel/turbo#4130) 2023-03-08 22:34:04 +00:00
JJ Kasper
f99ae5af97
v13.2.4-canary.7 2023-03-08 11:52:58 -08:00
Justin Ridgewell
612d578188
Update Turbopack to 230308.3 (#46935)
# Bug Fixes
- https://github.com/vercel/turbo/pull/4121
- https://github.com/vercel/turbo/pull/4111
2023-03-08 11:25:23 -08:00
Will Binns-Smith
074630e7ce WEB-415: next/font/google: Use next's bundled font-data.json (vercel/turbo#4111)
This removes the duplicated (and possibly mismatching) font data file in
favor of loading the copy bundled with next, using `load_next_json`
introduced in vercel/turbo#4086. It also removes the associated workflow and
generation script.
2023-03-08 08:25:22 -08:00
Shu Ding
8ca0233d08
Support default export expression for variables (#46896)
Similar to #46888, this PR adds support for the case:

```js
async function foo () {}
export default foo
```

...where you export an ident as a default export expression.

Closes NEXT-770

~Should be landed after #46881.~
2023-03-08 14:45:32 +00:00
Donny/강동윤
37b0349731
Update turbopack to 230308.1 (#46909)
## Bugfixes

 - https://github.com/vercel/turbo/pull/3526
 - https://github.com/vercel/turbo/pull/4084
 - https://github.com/vercel/turbo/pull/4083
 - https://github.com/vercel/turbo/pull/4067
 - https://github.com/vercel/turbo/pull/3959
 - https://github.com/vercel/turbo/pull/4060
 - https://github.com/vercel/turbo/pull/4081
 - https://github.com/vercel/turbo/pull/4103
 - https://github.com/vercel/turbo/pull/4100
 - https://github.com/vercel/turbo/pull/4108
 - https://github.com/vercel/turbo/pull/4101
 - https://github.com/vercel/turbo/pull/4112
 - https://github.com/vercel/turbo/pull/3956
 - https://github.com/vercel/turbo/pull/4118
 - https://github.com/vercel/turbo/pull/4117

## Feature

 - https://github.com/vercel/turbo/pull/4058
  - https://github.com/vercel/turbo/pull/4013
  - https://github.com/vercel/turbo/pull/4005
  - https://github.com/vercel/turbo/pull/4001
  - https://github.com/vercel/turbo/pull/3839
  - https://github.com/vercel/turbo/pull/4017
  - https://github.com/vercel/turbo/pull/4086
  - https://github.com/vercel/turbo/pull/4067

## Performance

  - https://github.com/vercel/turbo/pull/4040
  - https://github.com/vercel/turbo/pull/4110

## Refactor

 - https://github.com/vercel/turbo/pull/4098
2023-03-08 13:51:28 +00:00
Shu Ding
2dea520ae2 fix(turbopack): Update app-renderer (vercel/turbo#4102)
### Description

This PR mirrors some related manifest changes in Next.js:
https://github.com/vercel/next.js/pull/46881.

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-03-08 05:47:50 +00:00
Tobias Koppers
db5e2ea401 fix assert alias (vercel/turbo#4114)
### Description

typo, causing resolve failure
2023-03-08 03:32:21 +00:00
Tobias Koppers
c4b64405fd disable issue_path again (vercel/turbo#4118)
### Description

Performance is just too bad
2023-03-08 02:18:31 +01:00
JJ Kasper
85ec94ffd7
v13.2.4-canary.6 2023-03-07 14:10:34 -08:00
Shu Ding
7e933a094c
Revert "Revert "Update vendored React"" (#46881)
Reverts vercel/next.js#46861. This requires
https://github.com/vercel/turbo/pull/4102 to be released and bindings to
be updated first.

~Also depends on #46896 to be merged first, and conflicts to be
resolved.~
2023-03-07 13:04:08 -08:00
Will Binns-Smith
c19e0f3075 next/font: Generate fallback fonts (vercel/turbo#4086)
This:
* Generates and uses definitions for fallback system fonts to use in
place of user fonts, or as they are loading.
* Reads the font metrics file from the `next` package directly relative
to the user's app.
* Fixes a bug where `adjust_font_fallback` defaulted to `false` instead
of `true`.
* Begins to refactor next/font code to be more modular in anticipation
of `next/font/local` support.
* Changes `handle_resolve_error` to take an origin `FileSystemPathVc`
instead of a `ResolveOriginVc` as this is all it used, and a resolve
origin isn't always available.
2023-03-07 12:00:38 -08:00
Shu Ding
4b8240b842
Support unnamed default export expression (#46888
This PR adds the support for unnamed default export expression support
`export default async function () {}` in a "use server" entry, with
corresponding test.

Also fixed an existing bug that the default exported action's name
should be aligned with the export name, which is `"default"`.

Closes NEXT-769.
2023-03-07 19:16:45 +01:00
Tobias Koppers
8c9ae939c9 revert workspace dependency to allow building correctly (vercel/turbo#4103)
### Description

Cargo always uses default features for workspace dependencies, so we
can't use that here. See also comment.

### Testing Instructions

```
$ cargo tree -p next-binding -i openssl --target x86_64-unknown-linux-gnu -e features
error: package ID specification `openssl` did not match any packages
```
2023-03-07 10:41:00 -07:00
Tobias Koppers
951568c4c7 improve and enable issue path handling (vercel/turbo#4017)
### Description

adds the issue trace again, adds some basic descriptions e. g. to pages

### Testing Instructions

snapshot issues

[X] Auto label
2023-03-07 17:10:05 +00:00
Tobias Koppers
e01578032f place all pages in the same intermediate output directory (vercel/turbo#4081)
### Description

The isolation is unnecessary and we can reuse files when we share
directories

### Testing Instructions

Open multiple pages without client-side navigation in multiple tabs
concurrently.
2023-03-07 16:26:41 +00:00
JJ Kasper
a5a13fe930
v13.2.4-canary.5 2023-03-06 23:30:31 -08:00
JJ Kasper
0f621cb133
Revert "Update vendored React" (#46861)
Reverting temporarily as this breaks turbopack support for app dir 

x-ref:
https://github.com/vercel/next.js/actions/runs/4349458918/jobs/7600147372
x-ref:
https://github.com/vercel/next.js/actions/runs/4349607013/jobs/7600148420

Reverts vercel/next.js#46826
2023-03-06 21:17:15 -08:00
Shu Ding
003b3af700
Update vendored React (#46826)
This PR updates vendored React to the latest `@next` version, as well as
corresponding changes to the manifest and module reference generation
code.

The new React version includes the following upstream changes:

- 49f741046 Fix: Infinite act loop caused by wrong shouldYield (#26317)
(Andrew Clark)
-  106ea1c58 Support Iterables in Flight (#26313) (Sebastian Markbåge)
- f905da227 [Flight] Send server reference error chunks to the client
(#26293) (Hendrik Liebau)
- e0241b660 Simplify Webpack References by encoding file path + export
name as single id (#26300) (Sebastian Markbåge)
- 25685d8a9 Codemod tests to waitFor pattern (9/?) (#26309) (Andrew
Clark)
- 64dde7082 Codemod tests to waitFor pattern (8/?) (#26308) (Andrew
Clark)
- 3cb5afb82 Codemod tests to waitFor pattern (7/?) (#26307) (Andrew
Clark)
- e98695db9 Codemod tests to waitFor pattern (6/?) (#26305) (Andrew
Clark)
- 9a52cc8bc Convert ReactLazy-test to waitFor pattern (#26304) (Andrew
Clark)
- 03462cfc7 [Fizz] External runtime: fix bug in processing existing
elements (#26303) (mofeiZ)
- faacefb4d Codemod tests to waitFor pattern (4/?) (#26302) (Andrew
Clark)
- 06460b6fb Remove unnecessary (and incorrect) code for compatibility
with Paper in the Fabric version of GlobalResponderHandler (#26290)
(Rubén Norte)
- e64a8f403 Codemod tests to waitFor pattern (3/?) (#26299) (Andrew
Clark)
- ce8a72fd4 Codemod tests to waitFor pattern (2/?) (#26296) (Andrew
Clark)
- 1f1f8eb55 [Float][Fizz][Fiber]: Refactor <style> Resource
implementation to group on flush (#26280) (Josh Story)
- 5c633a48f Add back accidentally deleted test comments (#26294) (Andrew
Clark)
- b073104c2 [DevTools] improve troubleshooting in README (#26235)
(Mengdi Chen)
- fcf218791 [DevTools] Remove renderer.js from extension build (#26234)
(Mengdi Chen)
- b72ed698f Fixed incorrect value returned as public instance from
reconciler (#26283) (Rubén Norte)
- 25a8b9735 Codemod tests to waitFor pattern (1/?) (#26288) (Andrew
Clark)
- e52446733 New internal testing helpers: waitFor, waitForAll,
waitForPaint (#26285) (Andrew Clark)
- d49e0e0be Removed unused imperative events implementation from React
Native renderer (#26282) (Rubén Norte)

---------
2023-03-06 16:51:10 -08:00
Tobias Koppers
59c86bfdd6 fix module options in middleware (vercel/turbo#4083)
### Description

allows to use jsx in middleware
2023-03-06 19:19:35 +00:00
OJ Kwon
2d4d758a9a ci(workflow): fix build errors (vercel/turbo#4082)
### Description

Minor fix for the daily next.js test runs.
2023-03-06 10:03:27 -08:00
Shu Ding
440b95e289
Refactor SWC transform to support named default export (#46778)
Since the default export syntax is not `fnDecl` but `fnExpr` I added two new methods to abstract out all the transform logic and made both `visit_mut_fn_decl` and `visit_mut_fn_expr` use that.

Next step is to support default exports without an ident (`export default async function () {}`).

Fixes NEXT-768.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-06 11:53:13 +00:00