Commit graph

1465 commits

Author SHA1 Message Date
Tobias Koppers
4c2ad81ea7
Add initial tree shaking refactorings (#47559)
### What?

Changes for https://github.com/vercel/turbo/pull/3338
2023-03-27 15:18:04 +00:00
Tobias Koppers
2eee4aad95
remove unused turbo dependencies (#47557)
### What?

These dependencies are not used

### Why?

Automatically updating them fails as they are unused
2023-03-27 09:56:31 +00:00
Donny/강동윤
688d8253da
refactor(relay): Use transform from swc/plugins repository (#47441)
Previously `next-swc` had relay transform inline, but it makes
maintenance harder. So this PR patches next-swc to use relay plugin from
`swc-project/plugins` repository.

Closes WEB-782
Fixes #47239

fix NEXT-883 ([link](https://linear.app/vercel/issue/NEXT-883))
2023-03-27 09:34:09 +02:00
JJ Kasper
53bcdea01c v13.2.5-canary.19 2023-03-27 07:05:28 +00:00
Tim Neutkens
257872e49c
Rename app-render/index.tsx to app-render/app-render.tsx (#47285)
Ensures `app-render` shows the right file given that there's also a
`app-renderer.tsx` in 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 or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

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



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-26 22:47:27 -07:00
Tim Neutkens
266fd1cd67 v13.2.5-canary.18 2023-03-25 20:39:25 +01:00
Tobias Koppers
6ec94141f5 v13.2.5-canary.17 2023-03-25 13:49:36 +00:00
Leah
88a3087561
restore dynamic directory embedding (#47260)
depends on https://github.com/vercel/turbo/pull/4249
2023-03-24 17:43:22 -07:00
Tobias Koppers
df228500f1
fix error handling and hanging problems (#47457)
### What?

see https://github.com/vercel/turbo/pull/4324
2023-03-24 23:37:32 +00:00
Shu Ding
9fff7e321c
Finalize HOC support with server entries and add encodeReply & decodeReply (#47438)
Revert some code in #47379 and finalize HOC support. We should require
the HOC to return a "use server" function, so there's no need to compile
the function call specially now.

To make that wrapping logic work, we need to allow passing a server
reference to another server reference. This usually happens in the
function closure in the HOC case, but ideally it's also allowed to
directly pass it as an argument. This requires adding React server DOM's
`encodeReply` and `decodeReply` and other corresponding changes,
including adding `busboy` (can probably be vendored?) as we need to
parse the multipart body now.

fix NEXT-808 ([link](https://linear.app/vercel/issue/NEXT-808))
([link](https://linear.app/vercel/issue/NEXT-808))
2023-03-24 13:01:10 +01:00
JJ Kasper
be14eb1373 v13.2.5-canary.16 2023-03-24 06:24:45 +00:00
JJ Kasper
7d8310512f
v13.2.5-canary.15 2023-03-23 12:46:01 -07:00
Shu Ding
394bff5fd0
Fix closure and rest params handling in SWC transform (#47401)
This PR addresses two bugs:

- The parameters of arrow functions were not being tracked in `closure_idents` due to not being visited via `visit_mut_param`. They are stored as `Vec<Pat>` instead so we need to handle these as a special case.
- The rest parameter could not be transformed into `...r = closure[1]`, so we changed that case to `r = closure.slice(1)`.

fix NEXT-874 ([link](https://linear.app/vercel/issue/NEXT-874))
2023-03-23 13:55:22 +00:00
Tobias Koppers
3b1aaa2686
improve source mapping of console output and errors (#47388)
### What?

* see https://github.com/vercel/turbo/pull/4284
* also adds a test case
* fixes some bugs with app dir (e. g. fixes https://github.com/vercel/turbo/issues/2496)

### Why?

* Stack traces pointing to generated code are not very useful

### How?

* Source Maps
* Code context
* Replacing magic identifiers

fixes WEB-745
2023-03-23 12:43:22 +00:00
Jimmy Lai
0416bd559d v13.2.5-canary.14 2023-03-23 10:15:46 +01:00
Justin Ridgewell
a5dfe46cca
turbopack: Implement streamed middleware (#47264)
Fun! This depends on https://github.com/vercel/turbo/pull/4251 to
implement streamed Node evaluations, giving us the ability to support
streamed middleware responses.

This is just the first step to supporting RSC streaming in Turbopack. I
chose to start with this because it requires all the same base logic,
and I understand the full router->middleware->HTTP server code path, so
it's a lot easier to work on.

Fixes WEB-738
2023-03-22 21:04:33 -07:00
JJ Kasper
95322649ff
v13.2.5-canary.13 2023-03-22 15:55:34 -07:00
Shu Ding
e6a3bab489
Support HOC cases in server entries (#47379)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-22 15:15:08 +01:00
Alex Kirszenberg
8195e1947b
Refactor ES chunk evaluate logic into a Runtime trait (#47116)
This is the Next.js side of https://github.com/vercel/turbo/pull/4141
2023-03-22 10:28:49 +00:00
JJ Kasper
2e7dfca362
v13.2.5-canary.12 2023-03-21 16:23:51 -07:00
JJ Kasper
fed3ffa865
Skip extra swc builds (#47378)
This removes some extra swc builds which are rarely if ever used and are
also prone to breaking fairly often due to the extra configuration
required to build them.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04KC8A53T7/p1679434160981059)
2023-03-21 16:09:52 -07:00
Shu Ding
250160f4a9
Ensure all server entry exports are functions (#47364)Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
When using a "use server" module, only exporting async functions is
permitted. However, since we cannot perform static analysis on all
exported value types (e.g., `export const foo = condition ? A : B`), we
have added a runtime ensure function to validate that these are indeed
valid functions.

By implementing this, we can prevent any strange errors like "Can't
access $$typeof of undefined or null" that may arise when exporting
`undefined` or `null` from a server entry. Moreover, this measure helps
avoid any potential mistakes that may occur.

fix NEXT-865 ([link](https://linear.app/vercel/issue/NEXT-865))

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-21 21:17:15 +01:00
JJ Kasper
4ffaf5067f
v13.2.5-canary.11 2023-03-21 12:17:30 -07:00
Alex Kirszenberg
ed539c5dca
Update Turbopack to turbopack-230321.1 (#47342)
Updates Turbopack to latest nightly and fix build errors.

# New features

* https://github.com/vercel/turbo/pull/4198

# Bug Fixes

* https://github.com/vercel/turbo/pull/4241

# Misc.

* https://github.com/vercel/turbo/pull/4249

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-21 11:48:48 +00:00
LongYinan
509ed00fc1
Calling turbopack from the next build CLI (#46602)
Close WEB-661
2023-03-21 10:25:08 +00:00
JJ Kasper
17e1cc7a7b
v13.2.5-canary.10 2023-03-20 18:20:45 -07:00
Tim Neutkens
5d9b166eba v13.2.5-canary.9 2023-03-20 22:06:42 +01:00
Will Binns-Smith
40cb797a34
next/font/local prep: compartmentalize next/font/google (#47213)
This PR is largely preparation work for next/font/local by
compartmentalizing and modularizing existing pieces of next/font/google.
It:

* Renames the top level directory to `next_font`
* Places next/font/google-specific code into `next_font/google`
* Extracts common structures and methods into top-level
`font_fallback.rs`, `stylesheet.rs`, `util.rs`, etc.
* Updates visibility of structures and functions to use `pub(super)`
within `next/font/google`

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-20 08:49:23 -07:00
JJ Kasper
1467be886a
v13.2.5-canary.8 2023-03-17 16:13:40 -07:00
Tim Neutkens
7a104a673b v13.2.5-canary.7 2023-03-17 13:31:21 +01:00
Tobias Koppers
d760c00961
print reason for compilation (#47190)
### What?

add reason of compilation to the `updated in` message.


![image](https://user-images.githubusercontent.com/1365881/225526729-7ada5e84-78a0-4518-ad9c-48178fd4e7cb.png)

### Why?

the general update in message is confusing and didn't show what is
happening.

Sometimes people are confused why turbopack compiles something. The new
messages explain that turbopack timings measure request handing duration
in addition to pure compilation time.

### How?

depends on https://github.com/vercel/turbo/pull/4208

fixes WEB-722
2023-03-17 13:22:25 +01:00
Tim Neutkens
6aa8c3768e v13.2.5-canary.6 2023-03-17 10:10:26 +01:00
Tobias Koppers
6eb33b7e68
update turbopack (#47205)
## Features

* https://github.com/vercel/turbo/pull/4208

## Testing

* https://github.com/vercel/turbo/pull/4211


Co-authored-by: Justin Ridgewell <112982+jridgewell@users.noreply.github.com>
2023-03-17 08:41:32 +00:00
Justin Ridgewell
875ddea183
next-swc: Switch to testing::fixture (#47183)
The old `test_generator::test_resources` could only find resources relative to the project root, and not relative to the test file. Because of the new nextpack directory structure, this causes all kinds of headaches between running in nextpack and running in turbo (`next.js/packages/next-swc` vs `nextpack/next.js/packages/next-swc`).
2023-03-17 06:18:25 +00:00
Shu Ding
922b5de06f
Support passing both closure arguments and parameters (#47212)
When calling the server (via `callServer`), we concat all closure values
(`$$bound`) and arguments of the function call into one array on the
client. Hence on the server, we will have to compile the function
differently to support that.

With this change, the compiled function will have a `$$with_bound` flag
to indicate that if it accepts closure values. If so, the only argument
passed will be an array like `[...bound_values, ...fn_args]`, and we
compile the function parameters to `(closure, arg1 = closure[N], arg2 =
closure[N + 1], ...)` where `N` is the number of the closure
identifiers. This way we can still fill these arguments by only pass an
"bound + args" array. If it doesn't accept closure values, it will be
directly called with `...fn_args` so no compilation change needed.

The reason that we use `arg1 = closure[N]` is that this can support
complex patterns in parameters such as `f(closure, {a} = closure[1], [b]
= closure[2])`.

fix NEXT-487 ([link](https://linear.app/vercel/issue/NEXT-487))
2023-03-16 19:11:13 -07:00
Shu Ding
45fe26f596
Fix missing option in createFromFetch (#47216)
This PR makes sure that `callServer` is specified in all Flight response creation calls. Added a test to cover HMR.

https://vercel.slack.com/archives/C03KAR5DCKC/p1678997184339409
2023-03-17 00:46:21 +00:00
Tim Neutkens
4e96e044d2 v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
Leah
dbdf47cf61
fix build issue and future incompatibility (#47176)
It was complaining about having 2 versions of sentry for some reason
2023-03-16 19:29:24 +00:00
Jiachi Liu
1255e19965
Reorganize client references manifest (#46777)
* Rename client reference plugins from `Flight*` to `ClientReference*`
* Rename `serverComponentManifest` to `clientReferenceManifest`
* Group the key/value in client reference manifest
* Update turbopack crates
2023-03-16 18:10:32 +00:00
Will Binns-Smith
67aceea72b
Align on next-transform-font (#47179)
fix NEXT-827 ([link](https://linear.app/vercel/issue/NEXT-827))

This aligns use of the next/font transform across the workspace under a
single crate, now called `next-transform-font`.
2023-03-16 16:33:04 +01:00
Tobias Koppers
588bf8ee20
improve turbopack error overlay (#47132)
### What?

Improve the UX of the error overlay

### Why?

* error overlay doesn't reopen when closed, but new error appear
* error overlay shows non-actionable warnings in node_modules
* error overlay shows unrelevant errors in node_modules

### How?

* low priority for errors in node_modules
* hide node_modules warnings
* open error overlay on new error
* Also updated the files I touched to the next.js prettier format


fixes WEB-712
fixes WEB-713
fixes WEB-714
fixes WEB-727

Co-authored-by: Leah <8845940+ForsakenHarmony@users.noreply.github.com>
2023-03-16 14:45:46 +00:00
Shu Ding
26a17fac6d
Adjust transpiler to support inlined server functions with annotations (#47186)
This PR makes sure that we are not appending statements after the function or arrow expression, if they're actions. Instead we put all them in a `ParenExpr` so the entire thing can be defined inline.
fix NEXT-813 ([link](https://linear.app/vercel/issue/NEXT-813))
2023-03-16 13:01:42 +00:00
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
Tim Neutkens
6babc5ec43 Make in next.config.js optional (vercel/turbo#4080)
### Description

Ensures `target` is optional to match vercel/turbo#46801 which removes the option.

<!--
  ✍️ Write a short summary of your work.
  If necessary, include relevant screenshots.
-->

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
2023-03-06 08:59:03 +00:00
Justin Ridgewell
5619c03f4c Remove graceful failure handling in routing (vercel/turbo#3959)
The graceful failures mean it's easy to accidentally break the router
without noticing.
2023-03-06 08:48:29 +00:00
JJ Kasper
a0c5a630f9
v13.2.4-canary.4 2023-03-05 10:26:29 -08:00
JJ Kasper
8d9b0b111f
v13.2.4-canary.3 2023-03-04 14:41:44 -08:00
Tobias Koppers
f0ee0426ae inject swc helpers (vercel/turbo#4060)
### Description

This fixed the `_extends` is not defined issue.
2023-03-04 06:51:31 +00:00
JJ Kasper
f2989f747f
v13.2.4-canary.2 2023-03-03 17:36:25 -08:00
Will Binns-Smith
5f76b5d9e4 next/font: Align with Next.js integration test suite (vercel/turbo#4039)
This:
* Adds a compile-time feature, `__internal_nextjs_integration_test`,
which is set when building Turbopack for the Next.js integration test
suite.
* When built with `__internal_nextjs_integration_test`, expects the
environment variable `NEXT_FONT_GOOGLE_MOCKED_RESPONSES` to be set with
an absolute path to a JavaScript file exporting a mapping of urls to
stylesheet text. This is used in place of making real requests to Google
Fonts.
* Addresses some small bugs in next/font/google to bring the
implementation in line with the urls generated by Next.js without
Turbopack.
* Changes classnames generated by next/font to use 6 character hashes,
bringing it in alignment with Next.js without Turbopack.

Test Plan:
* Adjusted existing unit tests
* In Next.js, `node run-tests.js -c 1 test/e2e/next-font/index.test.ts`

### Description

<!--
  ✍️ Write a short summary of your work.
  If necessary, include relevant screenshots.
-->

### Testing Instructions

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

<!--
  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
2023-03-03 16:12:36 -08:00
overlookmotel
dda9be09f0
Failing test for SWC shakeExports and JSX (#35735)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order 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 that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [X] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Failing test for #35734.
2023-03-03 17:06:27 +00:00
Leah
ad12551513 move common dependencies to workspace root (vercel/turbo#3890) 2023-03-03 16:34:05 +00:00
Shu Ding
9acbf6e6ac
Disallow wildcard export in server entries (#46710)
Similar to client entry files, we don't allow `export *` in server entries as well because we can't statically analyze all the export types in SWC.

Fixes NEXT-490

## 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-03 03:37:08 +00:00
JJ Kasper
f7bfaff83b
v13.2.4-canary.1 2023-03-02 18:35:39 -08:00
Will Binns-Smith
857e02d700 webpack loaders: implement emitError and emitWarning (vercel/turbo#3983)
This implements webpack loader context api for `emitError` and
`emitWarning`, each of which emit Turbopack issues at the appropriate
error level. As with webpack’s implementation, `emitError` does _not_
cause builds to fail [0].

This uses next-dev issue snapshots (vercel/turbo#3774) to test that issues are
emitted.

[0] https://webpack.js.org/api/loaders/#thisemiterror

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-03-02 13:59:43 -08:00
Leah
cdbc0eae56 handle data paths for pages with getStaticPaths (vercel/turbo#4013) 2023-03-02 18:00:47 +00:00
Leah
5ba463e89b add env to spawned processes (vercel/turbo#4005)
Fixes WEB-517
Fixes vercel/turbo#3876
2023-03-02 17:36:09 +00:00
Alex Kirszenberg
111ef3951c
build(cargo): update turbopack (#46685)
# New Features
*  https://github.com/vercel/turbo/pull/4011

# Performance Improvements
* https://github.com/vercel/turbo/pull/3955
* https://github.com/vercel/turbo/pull/4018

# Bug Fixes
* https://github.com/vercel/turbo/pull/4037
* https://github.com/vercel/turbo/pull/4028

# Other
* https://github.com/vercel/turbo/pull/3974
* https://github.com/vercel/turbo/pull/4015
* https://github.com/vercel/turbo/pull/3999
* https://github.com/vercel/turbo/pull/4026
* https://github.com/vercel/turbo/pull/4053
* https://github.com/vercel/turbo/pull/3891

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-02 09:08:12 -08:00
Leah
6d4fcae5be Separate tabs for Errors and Warnings in error overlay (vercel/turbo#4001) 2023-03-02 16:58:24 +00:00
Tobias Koppers
22fb29e4ce Only handle issues in dev server (vercel/turbo#3891)
All issues from `source` are already handled here:
48d9918806/crates/turbopack-dev-server/src/lib.rs (L168)

So no need to handle them multiple times
2023-03-02 11:14:47 +00:00
Tobias Koppers
7f7b2c1041 avoid bundling and execution of modules just of watching (vercel/turbo#4053)
### Description

* use completions to signal additional invalidations for evaluation
* avoid adding these modules as runtime entries, since that will
unnecessarily code generate, bundle and execute these modules
* gets rid of the watch_files_hack

### Testing Instructions

* change postcss.config, next.config.js, etc. -> changes will be
reflected by the app and process restarts
2023-03-02 12:02:06 +01:00
Tobias Koppers
60f5289b0d follow up changes from review (vercel/turbo#4051)
### Description

Follow-up changes for https://github.com/vercel/turbo/pull/4018

<!--
  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
2023-03-02 10:51:37 +00:00
Tobias Koppers
5c9bdd7a34 Capture console statements as one unit including stack trace (vercel/turbo#4028)
### Description

fixes the deduplication issue with multiple output
2023-03-02 11:48:46 +01:00
Tobias Koppers
7dc8f02ebd refactor internal modules (vercel/turbo#4018)
### Description

* get rid of attached filesystem for our embedded modules
* get rid of import "." in favor of inner assets

depends on vercel/turbo#3999

### Testing Instructions

existing tests

<!--
  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
2023-03-02 08:23:41 +01:00
OJ Kwon
b920d343a3 fix(route_matcher): do not include empty segment (vercel/turbo#4037)
### Description

Closes WEB-674

if a matcher tries to split path have a slash like `/x/y`, split gives a
redundant empty segment `["", 'x', 'y']`.
2023-03-02 06:03:53 +00:00
JJ Kasper
262501eb68
v13.2.4-canary.0 2023-03-01 19:38:37 -08:00
Shu Ding
844776ef95
Support named exports for server references (#46558)
NEXT-424

Note that this change also prepares for upcoming PRs to support arrow functions.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] 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-01 15:30:40 +00:00
Tobias Koppers
752794f638 refactor asset identification (vercel/turbo#3999)
* add Asset::ident() as unique identifier of an Asset
* add ChunkItem::ident() instead of ChunkItem::to_string()
(ValueToString)
* base `chunk_path` on AssetIdent instead of path only

Motivation:

We want to get rid of the `import "."` in favor of inner assets. When
doing this we no longer need to place virtual assets below the actual
file path and they can stay in their original path. But placing virtual
assets below the actual asset also made the `Asset::path` unique, which
would no longer be the case after using inner assets. Some parts of the
code base relied on `Asset::path` being unique (e. g. module ids and
chunk paths). But actually we never guaranteed that to be unique.
After this PR `Asset::ident` is intended to be unique and allow to carry
more information than only the path:
* Query string (`module?query`)
* Fragment (`module#fragment`)
* Asset (additional wrapped assets by key value pairs)
* Modifiers (additional transformations applied on the module, e. g.
`chunks`, `client chunks`)
* In future: Part (select a subpart of the module, e. g. only export
abc, or the module evaluation, or some internal part)
2023-03-01 11:11:27 +01:00
JJ Kasper
7f0b9e262b
v13.2.3 2023-03-01 00:46:27 -08:00
JJ Kasper
419ade23b6
v13.2.3-canary.1 2023-03-01 00:26:46 -08:00
JJ Kasper
cccf4f2a29
v13.2.3-canary.0 2023-02-28 22:40:40 -08:00
Justin Ridgewell
9b6ede295c
build(cargo): update turbopack (#46581)
# New Features
- https://github.com/vercel/turbo/pull/3930

# Misc Changes
- https://github.com/vercel/turbo/pull/3944
- https://github.com/vercel/turbo/pull/3774
2023-02-28 21:36:17 -08:00
JJ Kasper
5d48d7e6ed
v13.2.2 2023-02-28 17:48:09 -08:00
OJ Kwon
fc10d02366 feat(overlay): apply data-* header for the error desc (vercel/turbo#4015)
Partially resolves WEB-671.

There are some test cases use `data-nextjs-dialog-header` to lookup its
inner text to verify error output. Due to differences of error overlay
layout between turbopack / next-dev, those 2 have different inner texts.

PR applies a workaround, by introducing new data tag
`data-nextjs-turbo-dialog-body`. Next.js upstream will need following
update to utilize this tag in its test suites.
2023-02-28 17:27:30 -08:00
JJ Kasper
250a2f59b3
v13.2.2-canary.5 2023-02-28 16:31:35 -08:00
JJ Kasper
89a9bd9f74
v13.2.2-canary.4 2023-02-28 12:36:40 -08:00
Tim Neutkens
3609bdbffe v13.2.2-canary.3 2023-02-28 10:15:03 +01:00
Justin Ridgewell
7e2d931ffa Update Middleware Routing (vercel/turbo#3930)
This accomplishes 2 things:
- Moves the creation of the edge info onto the Next.js side
- Extracts the middleware's `export const config = {}`, so that we can know what matchers are needed before invoking the edge function definition.

After this, an update to the Next.js side will enable middleware.

Fixes WEB-623
2023-02-28 02:09:54 +00:00
JJ Kasper
6b276042ee
v13.2.2-canary.2 2023-02-27 17:17:33 -08:00
Will Binns-Smith
77283326e1 Snapshot issues in next-dev-tests (vercel/turbo#3774)
This:
* Adds issue snapshot support to next-dev-tests. This will allow us to
assert that certain issues are raised in tests that require next-dev.
* Extracts common snapshot code into a new crates,
`turbopack-test-utils`, which is shared between snapshot tests and
next-dev-tests.
* Implements an issue reporter that emits issues in a channel to the the
integration test code, where they are snapshotted.
* Fixes an issue where next-dev tests that were not Next.js apps would
emit non-fatal issues for a missing `pages/` directory.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-02-27 10:04:06 -08:00
Shu Ding
16d7ffdd11
Fix SWC's auto_cjs handling (#46448)
Closes #43732.

We currently detect if a module is CJS by look through all string tokens to see if any contains `"__esModule"`. That causes `console.log('__esModule')` being detected as CJS accidentally. This PR changes to detect these cases:
- `module.exports`
- `exports.__esModule` (e.g. `exports.__esModule = true`)
- `Object.defineProperty(exports, "__esModule", ...)` 

Although this solution isn't perfect, it's much more reliable that the current one already.

Note that this also fixes a bug for `@vercel/og` that although `satori`'s ESM module is imported, it still has the `__esModule` string inside, introduced by bundling its vendors.

## 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-02-27 16:56:05 +00:00
Will Binns-Smith
819d46a606 Automatic babel-loader followup (vercel/turbo#3944)
This:
* Addresses feedback from https://github.com/vercel/turbo/pull/3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-02-27 08:14:24 -08:00
JJ Kasper
ff4e06afd1
v13.2.2-canary.1 2023-02-25 12:51:34 -08:00
Shu Ding
516bc83296
Fix SWC error wrongly formatted (#46412)
We currently use the `NEXT_RSC_ERR_INVALID_API` error code for metadata API conflicts which is wrong. The format should be `NEXT_RSC_ERR_INVALID_API: foo` and then the formatter transforms it into `foo isn't supported in app/`.

This PR adds a new `NEXT_RSC_ERR_CONFLICT_METADATA_EXPORT` error code and improves the message. Closes #46406.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] 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-02-25 14:00:06 +00:00
Shu Ding
2988be2a05
Update server reference syntax and tests (#46389) 2023-02-25 12:34:56 +01:00
Kevin Wang
b942a6f494
chore: improve error when exporting metadata from client component (#46334)
<!--
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:
-->

This improves the ambiguous error seen when exporting `metadata` or
`generateMetadata` from a component marked with the `"use client";`
directive.

Example output from tests (`pnpm test-dev
test/development/acceptance-app/rsc-build-errors.test`)

```console
File path:
  app/client-with-errors/metadata-export/page.js
  console.log
    browser log: ./app/client-with-errors/metadata-export/page.js
    ReactServerComponentsError:
    
    You are attempting to export "generateMetadata" from a component marked with "use client", which is disallowed. Either remove the export, or the "use client" directive. Read more: https://beta.nextjs.org/docs/api-reference/metadata
    
       ,-[6:1]
     6 | 
     7 | // export const metadata = { title: 'client-metadata' }
     8 | 
     9 | export async function generateMetadata() { return { title: 'client-metadata' } }
       :                       ^^^^^^^^^^^^^^^^
       `----
    
    File path:
      app/client-with-errors/metadata-export/page.js
```

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] 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

- [x] 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)

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-02-24 21:23:32 -08:00
JJ Kasper
e0e81ea049
v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
github-actions[bot]
c568a97ad6 Update Google font-data.json (2023-02-24) (vercel/turbo#3942)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: wbinnssmith <wbinnssmith@users.noreply.github.com>
2023-02-24 09:14:21 +01:00
JJ Kasper
8d83d85e53
v13.2.1 2023-02-23 17:56:27 -08:00
JJ Kasper
10ada08332
v13.2.1-canary.0 2023-02-23 17:29:49 -08:00
JJ Kasper
cf8ca960c4
v13.2.0 2023-02-23 10:10:30 -08:00
Jimmy Lai
c4a3846821 v13.1.7-canary.32 2023-02-23 18:38:15 +01:00
Tim Neutkens
0d0a980415 v13.1.7-canary.30 2023-02-23 16:01:03 +01:00
Tim Neutkens
884dacc6b1 v13.1.7-canary.29 2023-02-23 15:11:19 +01:00
Tobias Koppers
d070b02601
update turbopack (#46297)
# Features

* https://github.com/vercel/turbo/pull/3923

# Bug Fixes

* https://github.com/vercel/turbo/pull/3931
* https://github.com/vercel/turbo/pull/3933
2023-02-23 13:31:08 +00:00
Tobias Koppers
00d842a652 disable bloom filter for now (vercel/turbo#3933)
it currently breaks because it imports `crypto` in edge environment
which isn't allowed.

We need to fix this properly eventually...
2023-02-23 13:23:55 +01:00
Tobias Koppers
71e6425c3e update to 13.1.7-canary.28 (vercel/turbo#3931)
* add `@opentelemetry/api` alias
* fix some renamed imports
2023-02-23 11:36:59 +01:00
Tobias Koppers
9b39e23ca4 implement route.js support (vercel/turbo#3923)
https://beta.nextjs.org/docs/routing/route-handlers
2023-02-23 11:36:17 +01:00
Tim Neutkens
2882eb4ebd v13.1.7-canary.28 2023-02-23 09:27:43 +01:00
Will Binns-Smith
7c5aa66a92
Update Turbopack to turbopack-230222.3 (#46278)
Update Turbopack to turbopack-230222.3

## Features
*
01a004e3f6

## Performance Improvements
*
e575eb95a2

## Misc
*
a6f92743c3
2023-02-22 17:50:59 -08:00
Tobias Koppers
112411678e improve startup performance (vercel/turbo#3927)
lazy parse page config from pages
this avoids to need to transform and parse all pages
2023-02-22 23:46:30 +01:00
JJ Kasper
0302576239
v13.1.7-canary.27 2023-02-22 13:47:53 -08:00
Tobias Koppers
3d73366ad9
update turbopack (#46253
# Features

* https://github.com/vercel/turbo/pull/3897
* https://github.com/vercel/turbo/pull/3670

# Bug Fixes

* https://github.com/vercel/turbo/pull/3894
* https://github.com/vercel/turbo/pull/3910
* https://github.com/vercel/turbo/pull/3895
* https://github.com/vercel/turbo/pull/3912
* https://github.com/vercel/turbo/pull/3805

# Performance Improvements

* https://github.com/vercel/turbo/pull/3836
2023-02-22 10:43:50 -08:00
Will Binns-Smith
1b8bacece6 Automatically apply babel-loader for apps with babel configs (vercel/turbo#3862)
This will automatically apply `babel-loader` to Next.js apps that
include a babel configuration file alongside `next.config.js`. It
requires the app to provide `babel-loader` itself.

Test Plan: Added an integration test.
2023-02-22 10:07:34 -08:00
Justin Ridgewell
3a30fc8850 Support NeedData responses in SourceMap/SourceMapTrace ContentSources (vercel/turbo#3907)
This implements a new `ContentSourceProcessor` trait and
`WrappedContentSource` struct that allows our `ContentSource`s to
register some processor to transform the eventual `ContentSourceContent`
that an inner `ContentSource` returns. Yah, it's a bit of a mouthful
with lots of very similar sounding names.

Essentially, the old `SourceMapContentSource` and
`NextSourceMapTraceContentSource` wrapped some inner `ContentSource`,
and would request content from them, and process that content into a
source map JSON or trace JSON. But, they didn't implement the `NeedData`
response, so it only supported very primitive inner content sources.

This PR extracts that knowledge into a single `WrappedContentSource`,
which will recursively wrap every `ContentSourceResult` until we land on
a fully resolved `ContentSourceResult::Result`. At that point, it hands
off the work to a `WrappedGetContentSource`, which performs the
processing on whatever content is returned by the inner
`GetContentSourceContent`. If you can't tell yet, I'm making the
description intentionally verbose to highlight just how similar our
struct/trait names are.

Fixes WEB-614
2023-02-22 11:48:46 -05:00
Alex Kirszenberg
b2a414f376 Make chunk_content_internal parallel (vercel/turbo#3836)
This switches the `chunk_content_internal` function from a sequential
BFS to a parallel BFS (+ reverse topological sort at the end).

I expected this to make some difference in performance, as traversing
references in parallel can lead to better CPU usage (see vercel/turbo#3771), but in
practice our benchmarks show no significant difference.

Real apps might be a different story, but I didn't notice any particular
performance improvement on vercel.com either.

This implementation is not perfect (we're making more calls to
`get_children` than strictly necessary), but I think it's enough to
measure a potential performance improvement.

Marking this as a draft for now as it's more complicated than the
current implementation and there's no clear win to adopting this.
2023-02-22 17:37:00 +01:00
Leah
22e3bacbf0 fix: allow HMR to recover from hydration errors (vercel/turbo#3805)
We now store react errors in the error overlay (hydration errors) and if
the error overlay receives the "build ok" message after that it will
hard reload the page to recover
2023-02-22 16:30:35 +00:00
Tobias Koppers
3d6c32933b add process.env.NODE_ENV support (vercel/turbo#3670)
define process.env.NODE_ENV to development for next-dev

define and set `process.turbopack`

---------

Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
2023-02-22 17:19:43 +01:00
Tobias Koppers
a093e313db separate app and pages structure extraction from source generation (vercel/turbo#3912)
We need to invalidate router node.js process when routes change for correctness

In future we can pass the routes list to next.js instead of only invalidating @jridgewell 

We also need the separated structure for next build @alexkirsz
2023-02-22 16:05:44 +00:00
Jimmy Lai
bd8cf3a4b7 v13.1.7-canary.26 2023-02-22 16:15:07 +01:00
Tobias Koppers
1d767db511 update next.js to 13.1.7-canary.25 (vercel/turbo#3895) 2023-02-22 14:51:00 +01:00
Alex Kirszenberg
36aca516db Include chunk path in WithClientChunks (vercel/turbo#3910)
`WithClientChunksChunkItem` currently only includes paths to chunks' references, but not chunks themselves.

Fixes WEB-621.
2023-02-22 12:39:54 +00:00
Tim Neutkens
1567f42c2e v13.1.7-canary.25 2023-02-22 10:36:00 +01:00
github-actions[bot]
f87dc8e6e9 Update Google font-data.json (2023-02-22) (vercel/turbo#3905)
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

Co-authored-by: Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
2023-02-22 09:21:16 +00:00
JJ Kasper
1dc7694218
v13.1.7-canary.24 2023-02-21 23:48:09 -08:00
JJ Kasper
d548318b28
v13.1.7-canary.23 2023-02-21 18:01:56 -08:00
Justin Ridgewell
d05101622e Implement Rewrite Headers support during routing (vercel/turbo#3897) 2023-02-21 19:40:50 -05:00
Will Binns-Smith
4bfb923c46
Update Turbopack to turbopack-230221.3 (#46209
# Performance Improvements:
* https://github.com/vercel/turbo/pull/3849
* https://github.com/vercel/turbo/pull/3878
* https://github.com/vercel/turbo/pull/3864

# Misc:
* https://github.com/vercel/turbo/pull/3847
* https://github.com/vercel/turbo/pull/3865
* https://github.com/vercel/turbo/pull/3850
* https://github.com/vercel/turbo/pull/3861
* https://github.com/vercel/turbo/pull/3823
* https://github.com/vercel/turbo/pull/3882

# Contributing
* Update profiling instructions for macOS
([#3837](https://github.com/vercel/turbo/pull/3837))
2023-02-21 15:53:33 -08:00
JJ Kasper
d6e560e486 Ensure next global is initialized correctly (vercel/turbo#3894)
This ensures our tests can run properly as they rely on the next global being present.
2023-02-21 21:36:49 +00:00
Will Binns-Smith
166b3d62cc loaders: use pre-compiled loader-runner distributed with Next.js (vercel/turbo#3823)
The benefit of this depends on
https://github.com/vercel/next.js/pull/45962, but it remains compatible
with apps including `loader-runner`.

This first attempts to require `loader-runner` from the app's installed
version of Next.js, falling back to requiring the package directly. We
should probably eventually remove this fallback once all compatible
versions of Next.js include the precompiled version, as that has a more
predictable version of the package.

Test Plan: Linked a local copy of Next.js including
https://github.com/vercel/next.js/pull/45962 to an app without
`loader-runner` that uses loaders and verified loaders ran.
2023-02-21 12:34:01 -08:00
Tim Neutkens
04c6c8cfca v13.1.7-canary.22 2023-02-21 19:50:53 +01:00
Justin Ridgewell
a1abeaf67b
build(cargo): update turbopack (#46013)Co-authored-by: JJ Kasper <jj@jjsweb.site> Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
# New Features
- https://github.com/vercel/turbo/pull/3771
- https://github.com/vercel/turbo/pull/3690

# Performance
- https://github.com/vercel/turbo/pull/3768

# Fixes
- https://github.com/vercel/turbo/pull/3795
- https://github.com/vercel/turbo/pull/3746
- https://github.com/vercel/turbo/pull/3832
- https://github.com/vercel/turbo/pull/3827
- https://github.com/vercel/turbo/pull/3847

# Other
- https://github.com/vercel/turbo/pull/3803
- https://github.com/vercel/turbo/pull/3685
- https://github.com/vercel/turbo/pull/3848

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-02-21 19:44:53 +01:00
Tobias Koppers
90675f2a7c add possible unknown mutation to objects and arrays (vercel/turbo#3882)
Before the static evaluation didn't consider the fact that objects and arrays can be mutated. So we can't just assume for sure that they have certain properties/items. Instead we add an unknown mutation alternative to handle that.

This avoids `if(obj.prop)` to be replaced with `if(true)` when prop is initialized with true. It might be modified in future.
2023-02-21 15:26:15 +00:00
Shu Ding
0ab8dcb09d
Fix client boundary defined in a module (#46171)
This PR fixes the bug where a client boundary (`"use client"`) is defined in a module (`"type": "module"`). Currently Next.js throws this error:

```
error - Error: Cannot find module 'private-next-rsc-mod-ref-proxy'
```

...that will be resolved with this PR.

The only limitation after this fix is, you can't have `export *` under a client boundary in a module. Added a error message for that.

NEXT-595

## 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-02-21 15:20:45 +00:00
Jiachi Liu
2f967ccd48
Detect invalid metadata exports errors in next-swc (#46077)
* Use next-swc to detect invalid metadata exports
* In client components page under app dir, metadata exports are not
available
* In server components page under app dir, metadata and gM exports can
be exported together

Move sync metadata / async metadata typing resolving test to UT

Closes NEXT-368

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-19 08:36:50 +01:00
Tim Neutkens
c4db007220 v13.1.7-canary.21 2023-02-18 20:36:22 +01:00
JJ Kasper
0bc4d568b3
v13.1.7-canary.20 2023-02-17 23:25:51 -08:00
JJ Kasper
2b18d5d6b3
v13.1.7-canary.19 2023-02-17 17:48:18 -08:00
Tobias Koppers
0345d9e120 alias @swc/helpers to the version within next.js (vercel/turbo#3865) 2023-02-17 21:23:43 +00:00
Tim Neutkens
4487abd73f v13.1.7-canary.18 2023-02-17 18:44:49 +01:00
Justin Ridgewell
3d90dcf03e Use IndexSet in IntrospectableChildrenVc (vercel/turbo#3853)
Another small cleanup stemming from the the `basePath` PR. Makes the
introspection ordering consistent, which is a nice usability win.

Co-authored-by: Alex Kirszenberg <1621758+alexkirsz@users.noreply.github.com>
2023-02-17 12:07:19 -05:00
Leah
866dfec256 make error overlay message scrollable (vercel/turbo#3861)
Before long messages would just be hidden:

![](https://uploads.linear.app/099ed59a-06c6-472f-9977-4798721bda90/6ea99100-27be-4192-adea-46ff2ed78cc8/860978fd-9ea5-456e-8c5a-48cecacf3e95)
2023-02-17 16:23:45 +00:00
github-actions[bot]
7400b3ba2b Update Google font-data.json (2023-02-17) (vercel/turbo#3850)
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

Co-authored-by: Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
2023-02-17 16:12:24 +00:00
JJ Kasper
7f41e4e8a1
v13.1.7-canary.17 2023-02-16 17:07:54 -08:00
Justin Ridgewell
ab49dc265a Use name-value tuples for headers (vercel/turbo#3848)
This is a small cleanup extracted out of the WIP `basePath` PR.
2023-02-17 00:34:48 +00:00
Leah
2f466eb40c strip UNC prefix on windows paths (vercel/turbo#3847) 2023-02-17 00:01:52 +00:00
Tim Neutkens
75b0987f9c v13.1.7-canary.16 2023-02-16 15:43:58 +01:00
Justin Ridgewell
81542ff759 Fix routing cases (vercel/turbo#3832)
This fixes 2 bugs that I've found:
1. If the `middleware.ts` file doesn't exist, then we get an unhelpful `unable to resolve relative "."` error during `next-edge` transition processing
   - This is fixed by not processing the `VirtualAssetVc` with the edge transition
2. If you're using an older Next version, then the router doesn't have a `type` field
   - Because the `type` field is empty, we hit neither the `rewrite` nor `none` cases and fall through to the middleware case, returning an empty response with no body.
   - This is fixed by treating `{ url: string, headers: … }` as `{ type: 'rewrite', url: string, headers: … }`
2023-02-16 08:55:14 +00:00
Leah
22939fe98d set correct CWD for node processes (vercel/turbo#3746) 2023-02-16 08:01:00 +00:00
Justin Ridgewell
2872010c27 Next Router Middleware Support (vercel/turbo#3690)
This updates our Next.js router, passing the `edgeInfo` manifest generated from the `middleware.js` file (or any other configured page extension).

Fixes WEB-277
Fixes WEB-370
2023-02-16 03:44:55 +00:00
Tobias Koppers
8de5b4e0d0 add CompileTimeInfo struct for passing compile time info (vercel/turbo#3685)
extracted from https://github.com/vercel/turbo/pull/3670

Refactoring to allow to pass more compile time info next to the environment to modules.
e. g. we want to pass `process.env.NODE_ENV = "development"` in future
2023-02-15 19:03:41 +00:00
Alex Kirszenberg
09af739aa0 Add support for CSS module composes: and fix CSS precedence issues (vercel/turbo#3771)
Adds support for the CSS module `composes:` rule.

This also fixes a large issue with our chunk ordering and CSS precedence, where the BFS order of our chunks did not match the expected topological ordering.
2023-02-15 10:36:09 +00:00
Tim Neutkens
79da1e7bce v13.1.7-canary.15 2023-02-15 11:13:27 +01:00
JJ Kasper
17aca74bd0
v13.1.7-canary.14 2023-02-14 19:12:32 -08:00
Will Binns-Smith
268c9e08fc Restore Issue Reporters (vercel/turbo#3803)
This restores issue reporters, addressing a bug that prevented turbo-trace from completing. This moves `ConsoleUiVc::new` into an async block to prevent it from stalling.

Test Plan: Verify `cargo run --bin node-file-trace -- print path/to/my/app` no longer stalls.
2023-02-14 19:10:12 +00:00
Tim Neutkens
93ee752d41 v13.1.7-canary.13 2023-02-14 19:15:27 +01:00
LongYinan
e3843c9712
Upgrade turbopack (#45861)
The `experimental.turbotrace.memoryLimit` is not actually working, we
need to use `turbo_malloc` as the global allocator to make it work.

~~Block by:~~
- https://github.com/swc-project/swc/pull/6940
- https://github.com/vercel/turbo/pull/3772

## This PR also upgrades `turbopack-230213.2` to `turbopack-230214.1`

- https://github.com/vercel/turbo/pull/3767
- https://github.com/vercel/turbo/pull/3772
- https://github.com/vercel/turbo/pull/3762
- https://github.com/vercel/turbo/pull/3741
- https://github.com/vercel/turbo/pull/3796
2023-02-14 18:51:15 +01:00
Tobias Koppers
e12e4760ce fix export * warning for client pages (vercel/turbo#3795)
This gets rid of this warning when using a client component as page:

```
warning - [analyze] [project-with-next]/src/app/client/page.jsx  unexpected export *
  export * used with module [project-with-next]/src/app/client/page.jsx which has no exports
  Typescript only: Did you want to export only types with `export type { ... } from "..."`?
```

* fix export * warning for client pages
* Detect `__turbopack_export_value__` as CJS style exports
* fix `__turbopack_cjs__` name
* flag turbopackHelper in client proxy
2023-02-14 14:38:55 +00:00
LongYinan
c881b16e49 Revert "Issue Reporters (vercel/turbo#3707)" (vercel/turbo#3796)
This reverts commit a8612abf5edbde3013d6fcf8845976f422cb2ffc.

This commit makes the `turbotrace` hanging, x-ref:
https://vercel.slack.com/archives/C02UJN0A1UL/p1676369060652879
2023-02-14 20:53:56 +08:00
Alex Kirszenberg
4460521e70 Fix the router when Next.js returns no result (vercel/turbo#3741)
I changed the return type of the Next.js router in https://github.com/vercel/next.js/pull/45668 to account for cases where the router does and does not find a matching rewrite.
2023-02-14 12:33:07 +00:00
Tim Neutkens
5422f3c553 v13.1.7-canary.12 2023-02-14 10:11:41 +01:00
LongYinan
ca14667a0e Split swc_core/allocator_node out of __swc_core_binding_napi (vercel/turbo#3772)
We only can use `turbo_malloc`  in `next.js` without `swc_node_base` included
2023-02-14 03:23:54 +00:00
Justin Ridgewell
3b1aa1c941
build(cargo): update turbopack (#45863)
# New Features
- https://github.com/vercel/turbo/pull/3695
- https://github.com/vercel/turbo/pull/3696

# Performance
- https://github.com/vercel/turbo/pull/3738
- https://github.com/vercel/turbo/pull/3714
- https://github.com/vercel/turbo/pull/3739

# Fixes
- https://github.com/vercel/turbo/pull/3718
- https://github.com/vercel/turbo/pull/3618
- https://github.com/vercel/turbo/pull/3736

# Other Changes
- https://github.com/vercel/turbo/pull/3731
- https://github.com/vercel/turbo/pull/3733
- https://github.com/vercel/turbo/pull/3629
- https://github.com/vercel/turbo/pull/3769
- https://github.com/vercel/turbo/pull/3707
- https://github.com/vercel/turbo/pull/3737
- https://github.com/vercel/turbo/pull/3770

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-02-13 14:40:58 -08:00
Tim Neutkens
cabace0c21 v13.1.7-canary.11 2023-02-13 21:45:44 +01:00
Donny/강동윤
6ea64002aa
fix(next-swc): Enable ignoreDynamic for auto_cjs (#45836)
This PR enables `ignoreDynamic` for common js modules which is detected
by `auto_cjs` pass.


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


---

I verified that with this change the test reproduction does not fail
with import error.

---------
2023-02-13 10:48:39 -08:00
chicoworry
61712322cf Fix typo (vercel/turbo#3763)
Just a small type I belive :)
2023-02-13 13:22:55 -05:00
Alex Kirszenberg
4682034c78 Make stringify_str and stringify_module_id use Serialize (vercel/turbo#3770)
Both `stringify_str` and `stringify_module_id` are now simply `stringify_js`. We could skip this and go directly to `serde_json`, but this hides the dependency behind turbopack-ecmascript.
2023-02-13 16:51:53 +00:00
Tobias Koppers
0e3bb903e3 fix integration tests on windows (vercel/turbo#3737)
For windows it's important that the browser is dropped so that the test can
complete. To do that we need to cancel the spawned task below (which will
drop the browser). For this we are using a JoinSet which cancels all tasks
when dropped.
2023-02-13 16:16:15 +00:00
Will Binns-Smith
5926753a2f Issue Reporters (vercel/turbo#3707)
Big thanks to @jridgewell for helping me out with a number of Rust-isms
with this change.

This expands `handle_issues` and the `NextDevServerBuilder` to accept an
arbitrary `IssueReporter` -- a trait implementing `report_issues` which
receives captured issues to send somewhere.

This replaces using a fixed `ConsoleUi` to send issues to stdout/stderr,
though `ConsoleUi` now implements `IssueReporter` and is the default
implementation of an issue reporter if no other is provided. It also
moves the responsibility of detecting fatal errors out of `ConsoleUi`
and into `handle_issues` itself.

This lays the foundation for alternative reporters, such as a test
reporter to snapshot or assert against issues emitted, or a
newline-delimited JSON reporter for other tools to consume.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-02-13 08:07:19 -08:00
Alex Kirszenberg
6fb1402d87 Add support for ctx.params in getStaticProps/getServerSideProps (vercel/turbo#3696)
Dynamic segments should be passed a single string, while catch-all segments should be passed a list of strings.

Furthermore, ctx.params was previously undefined because we weren't passing it forward through the render options.
2023-02-13 12:07:34 +00:00
Tim Neutkens
4270adfd16 v13.1.7-canary.10 2023-02-11 12:06:15 +01:00
Tim Neutkens
1fe827516f v13.1.7-canary.9 2023-02-11 10:40:23 +01:00
Tobias Koppers
a43d02d15a improve node_modules as externals handling (vercel/turbo#3736)
Run after_resolve with original request

try to resolve original request with node.js options to determine if it can be external

typescript extends need to resolve with bare node.js resolving to avoid custom resolve options

add special pnpm logic to improve externals when pnpm is used
2023-02-10 22:34:01 +00:00
Nicholas Yang
37ccaf0ca0 fix: Made native-tls our default feature for ease of dev workflows (vercel/turbo#3748) 2023-02-10 15:52:48 -05:00
LongYinan
ac7f2b6fe7
Make turbotrace run after the webpack build (#45621)
- [x] Depends on https://github.com/vercel/next.js/pull/45776

Turbotrace occupies too many memories while running; this PR makes it
run after the webpack build is finished, it can reduce the memory
hogging by webpack and turbotrace, thus avoiding OOM

The `maxFiles` option in turbotrace is removed because there is
`memoryLimit` option takes over its role.

Close WEB-556
2023-02-10 20:58:55 +01:00
Alex Kirszenberg
114ef6b8c0 Add req.cookies to API requests (vercel/turbo#3695)
This PR does a little bit more than what it says on the box. Before, we were parsing URL queries and request headers, only to serialize them some other way afterwards. The reason why we were parsing headers and queries is because we sometimes need to filter them. However, we don't need that for router/page SSR/page API. This PR makes it so we avoid parsing on Turbopack's side through `rawHeaders` and `rawQuery`.
2023-02-10 17:35:49 +00:00
LongYinan
946ccb00fc
Update turbopack to 230209.02 (#45776)Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
# New Features
- https://github.com/vercel/turbo/pull/3540
- https://github.com/vercel/turbo/pull/3549
- https://github.com/vercel/turbo/pull/3465
- https://github.com/vercel/turbo/pull/3550
- https://github.com/vercel/turbo/pull/3495
- https://github.com/vercel/turbo/pull/3624
- https://github.com/vercel/turbo/pull/3600
- https://github.com/vercel/turbo/pull/3676
- https://github.com/vercel/turbo/pull/3689

# Fixes

- https://github.com/vercel/turbo/pull/3437
- https://github.com/vercel/turbo/pull/3542
- https://github.com/vercel/turbo/pull/3531
- https://github.com/vercel/turbo/pull/3552
- https://github.com/vercel/turbo/pull/3551
- https://github.com/vercel/turbo/pull/3597
- https://github.com/vercel/turbo/pull/3644
- https://github.com/vercel/turbo/pull/3623
- https://github.com/vercel/turbo/pull/3634
- https://github.com/vercel/turbo/pull/3574
- https://github.com/vercel/turbo/pull/3673
- https://github.com/vercel/turbo/pull/3675
- https://github.com/vercel/turbo/pull/3723
- https://github.com/vercel/turbo/pull/3677
- https://github.com/vercel/turbo/pull/3717
- https://github.com/vercel/turbo/pull/3701

# Performance Improvements

- https://github.com/vercel/turbo/pull/3361 
- https://github.com/vercel/turbo/pull/3619

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-10 17:40:19 +01:00
Tobias Koppers
2bf64a5a9c update to 13.1.7-canary.8 (vercel/turbo#3712) 2023-02-10 15:31:45 +00:00
Tobias Koppers
792ca8755d fix incorrect segment path (vercel/turbo#3739)
fixes app dir with `/(basic)/about` routes
2023-02-10 14:40:37 +00:00
Alex Kirszenberg
fab373da1b Enable HMR updates even when critical issues occur (vercel/turbo#3714)
This enables HMR updates, even when the update message also contains
critical issues.

There were some inconsistencies with the logic previously, so I'm not
sure whether this fix is fully correct. More on that in PR comments.
2023-02-10 13:30:57 +01:00
Tobias Koppers
c039615006 share asset and chunking context between server, server data and client navigation (vercel/turbo#3738)
This improves the performance for client-side navigation as it can reuse the modules from the initial navigation. Same for server data requests.
2023-02-10 12:10:52 +00:00
Leah
3679862c21 match next.js client side routing (buildManifest rewrites & devPagesManifest HMR) (vercel/turbo#3701) 2023-02-09 22:37:27 +01:00
Tobias Koppers
40a49f44bf set nextExport flag for page rendering (vercel/turbo#3717)
Otherwise `router.isReady` will never be true for pages without gSSP, gSP or gIP
2023-02-09 20:30:01 +00:00
Will Binns-Smith
337ac59101 Accept next/font/google as well as @next/font/google (vercel/turbo#3723)
Aligning with https://github.com/vercel/next.js/pull/45707, this allows users to import fonts from `next/font/google` as well as `@next/font/google`.

Test Plan: Adjusted tests to use `next/font/google` and added another test to verify `@next/font/google` continues to work.
2023-02-09 18:15:46 +00:00
JJ Kasper
d73cceb20d
v13.1.7-canary.8 2023-02-08 22:07:11 -08:00
Will Binns-Smith
1197edc8ab Combine next.config.js Turbopack options into a nested object (vercel/turbo#3689)
This combines Turbopack-specific options into a nested object
`experimental.turbopack`, exposing `loaders` and `resolveAlias`
properties.

x-ref:
631b637f42 (r1098123643)

Test Plan: Integration tests for loaders and resolveAlias.
2023-02-08 16:25:43 -08:00
Tobias Koppers
44f23bd5da improve error reporting of JSON parsing (vercel/turbo#3676)
also make source context generation more reusable

This adds a source context snippet of the JSON that failed parsing and
the json path to the error.

```
An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json)
  at Execution of module_factory failed
  at Execution of JsonChunkItem::content failed
  at Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26
  at nested.?
     1 | {
     2 |   "nested": {
       |                          v
     3 |     "this-is": "invalid" // lint-staged will remove trailing commas, so here's a comment
       |                          ^
     4 |   }
     5 | }
```
2023-02-08 10:17:42 +01:00
Shu Ding
7150a87fa8
More explicit errors for invalid exports in SWC (#45679
NEXT-476

## 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-02-07 16:28:06 -08:00
Tobias Koppers
f83691f700 refactor ResolveResult to allow mixing special and assets in alternatives (vercel/turbo#3675)
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-02-07 23:56:06 +01:00
Shu Ding
63d7705f87
Fix directive parsing in SWC (#45671)
The server directive is allowed to have other directives and comments
above. This PR fixes the transform with tests added for failing cases.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] 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-02-07 23:48:15 +01:00
Leah
f65d709b56 detect missing trait methods at compile time (vercel/turbo#3657)
Leaves the default implementations of a trait "in place" and implements
the "cross-trait" resolving differently

we get back the normal rust error messages when you don't have every
method implemented 🎉
2023-02-07 17:06:19 +01:00
Alex Kirszenberg
17fba45a54 Export __N_SSG and __N_SSP from the error component (vercel/turbo#3574)
`export *` would be preferable once supported.
2023-02-07 09:39:49 +00:00
JJ Kasper
eb16c6f94a
v13.1.7-canary.7 2023-02-06 18:12:32 -08:00
Will Binns-Smith
f43c3588be Rename experimental.resolveAlias to experimental.turbopackResolveAlias (vercel/turbo#3651)
Following discussion at https://github.com/vercel/next.js/pull/45560,
this renames `experimental.resolveAlias` to
`experimental.turbopackResolveAlias` to make it clear that this option
is only available in Turbopack.

Test Plan: `cargo test -p next-dev-tests`
2023-02-06 16:22:36 -08:00
Justin Ridgewell
9694fc4f7c Import Next's CJS AsyncLocalStorage modules (vercel/turbo#3634)
The node evaluation always renders with `type: "commonjs"` and `require()` calls, so we'll always import the CJS files. But here we're importing the ESM files. That means we have 2 distinct instances of `requestAsyncStorage` in our node instance, and they cannot properly communicate with the other.

Fixes WEB-543
2023-02-06 22:47:29 +00:00
github-actions[bot]
38c78b65d5 Update Google font-data.json (2023-02-06) (vercel/turbo#3614)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: wbinnssmith <wbinnssmith@users.noreply.github.com>
2023-02-06 10:28:35 -08:00
Tim Neutkens
c76380fa25 v13.1.7-canary.6 2023-02-06 15:42:44 +01:00
Alex Kirszenberg
035d36fd77 Support for getStaticPaths.fallback = false (vercel/turbo#3600)
Adds support for `getStaticPaths` returning `{ fallback: false }` by
building out all static paths and checking whether the resolved path is
included in that list.

`buildStaticPaths` requires the `next.config.js` path, as well as other
config options such as locale. I created WEB-546 to track being able to
pass them to the handlers.
2023-02-06 09:56:55 +01:00
Donny/강동윤
45d5732349
Improve swc transforms (#45594) 2023-02-05 23:00:14 +00:00
Shu Ding
dc0aea5418
Fix SWC test (#45574)
This PR fixes several test cases related to closure handling. Idents
declared in the module scope shouldn't be included in the closure.

NEXT-456

## 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-02-05 19:23:29 +01:00
JJ Kasper
99166f8231
v13.1.7-canary.5 2023-02-04 10:31:16 -08:00
Tobias Koppers
5d532b6b75 add helper for walking a tree concurrently and deterministic (vercel/turbo#3619)
Similar to our `try_join` helper this adds a
`try_flat_map_recursive_join` helper, which allows to async expand a
tree structure into all nodes. It will call the async mapper function
concurrently to allow parallelism. It will handle circular and duplicate
references and return all nodes in a determinstic way (breath-first).
2023-02-03 20:31:45 +01:00
Tobias Koppers
aa3422a56f always allow to close the error overlay (vercel/turbo#3624)
It's difficult to test an app, if a single error blocks using the whole
page.

Therefore, error overlay should always be closeable.
2023-02-03 19:10:47 +01:00
Tobias Koppers
bb0977cf77 initial work for compile-time evaluation (vercel/turbo#3495)
Allows to skip unreachable code based on compile-time constant
conditions

e. g.

```
if (!process.turbopack) {
  require("will-not-be-processed");
}
```

* add if() and process.turbopack fixes WEB-491
* Removes unreachable code fixes WEB-498
* evaluate some logical operations `&&`, `||`, `??`, `!`
* fix arguments handling fixes WEB-529
* nested effects for function called with closures
* handle closures when array methods are used fixes WEB-538
* evaluates `process.turbopack` fixes WEB-496
2023-02-03 17:34:17 +01:00
Will Binns-Smith
0851ce9885 Move integration test entries to input/ (vercel/turbo#3590)
Moves all next-dev integration test code into a parent `input/`
directory, like our snapshot tests. This prepares for introducing
`issues` snapshots to next-dev integration tests.

Test Plan: CI
2023-02-03 11:26:47 +01:00
Tobias Koppers
8cd9781f24 update next.js to 13.1.7-canary.2 (vercel/turbo#3595) 2023-02-02 18:23:42 +01:00
JJ Kasper
3fa4798831
v13.1.7-canary.4 2023-02-02 08:54:44 -08:00
Alex Kirszenberg
5dce8dc0e2 Share request resolving logic between http and update servers (vercel/turbo#3597)
With the addition of the Next.js routing layer at the root of our
content sources, we need the update server to also be able to follow
Next.js rewrites, like the HTTP server.

This requires the following:
* Rewrites need to be able to indicate a source where to "resume" after
rewriting. Otherwise, we would enter an infinite loop of the Next.js
layer rewriting to the Next.js layer.
* The resolving logic from `process_request_with_content_source` needs
to be extracted into its own function, so it may be called both from the
HTTP server (which expects fully resolved `ReadRef`s) and the update
server (which needs a `VersionedContentVc`): this is where
`resolve_source_request` comes in.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-02-02 15:08:06 +01:00
Shu Ding
1248f6fff6
Update SWC transform to attach the export name (#45494)
NEXT-413

## 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-02-02 13:28:00 +01:00
Tobias Koppers
4a2d7cac53 improve error reporting for fatal errors (vercel/turbo#3550)
This adds the turbo-tasks function name as `context` of all fatal errors
propagated from executing or reading turbo-tasks functions.

That should help in debugging fatal errors.
2023-02-02 06:53:36 +01:00
JJ Kasper
308d1834e9
v13.1.7-canary.3 2023-02-01 17:32:58 -08:00
JJ Kasper
97796586b1
v13.1.7-canary.2 2023-02-01 10:49:34 -08:00
Leah
0e28913e17 show turbopack warnings in error overlay (vercel/turbo#3465) 2023-02-01 18:45:39 +01:00
Leah
9056eaf71b external node_modules for SSR (vercel/turbo#3361)
Adds resolve plugins (currently only running `after_resolve`, could add
`resolve` later)

Had to fix `ResolveResult::merge_alternatives` because it merged two
external results into `Unresolvable`
2023-02-01 17:26:10 +01:00
LongYinan
221692b32e
build(cargo): update turbopack to turbopack-230201.1 (#45454)
### Features
- https://github.com/vercel/turbo/pull/3514
- https://github.com/vercel/turbo/pull/3530
- https://github.com/vercel/turbo/pull/3510
- https://github.com/vercel/turbo/pull/3497

### Bug fixes
- https://github.com/vercel/turbo/pull/3545
- https://github.com/vercel/turbo/pull/3522
- https://github.com/vercel/turbo/pull/3525
- https://github.com/vercel/turbo/pull/3518
- https://github.com/vercel/turbo/pull/3501
2023-02-01 16:36:43 +01:00
Alex Kirszenberg
862a0a1535 Wrap CSS chunk items in a @layer (vercel/turbo#3542)
In Turbopack, as a consequence of our lazy compilation model, CSS chunks
can contain duplicate CSS chunk items. This can cause issues with
precedence. Take the following example:

Initial CSS chunk:
```css
/* ... */

/* chunk item A */
h1 {
  font-size: 2rem;
}

/* ... */

/* other chunk item */
h1 {
  font-size: 4rem;
}

/* ... */
```

Dynamic CSS chunk (loaded after the first page load completes)
```css
/* ... */

/* chunk item A */
h1 {
  font-size: 2rem;
}

/* ... */
```

In this example, when the page first loads, the following rule will be
applied:
```css
h1 {
  font-size: 4rem;
}
```

But as soon as the dynamic CSS chunk loads, the following rule will be
applied instead:
```css
h1 {
  font-size: 2rem;
}
```

However, from the order of rules in the initial load, we know that the
former should still apply.

We can remedy this particular issue by wrapping each CSS chunk item into
its own
[`@layer`](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer)
(thanks @sokra for the idea!). This ensures that when a CSS chunk item
is re-encountered at a later time, it is automatically de-duplicated
thanks to the inherent CSS layering algorithm.

This is not an issue in Next.js as we can't have duplicated CSS chunk
items.
2023-02-01 13:58:46 +01:00
Tobias Koppers
d5de3a409b add worker condition to edge compilation (vercel/turbo#3549)
some packages expect `worker` or `browser` condition to work on edge
runtime
2023-02-01 08:06:32 +01:00
Will Binns-Smith
1b2a24058f font/google test: update cssmodule classnames (vercel/turbo#3568)
#3437 wasn't up to date with main when it was merged.

Test Plan: CI
2023-01-31 18:04:56 -08:00
Will Binns-Smith
817e089a30 turbopackLoaders: accept basic loader options (vercel/turbo#3540)
Fixes WEB-525

This allows webpack loaders defined by `experimental.turbopackLoaders` in `next.config.js` to pass serializable options to loaders.

It expands `turbopackLoaders` to accept not just loader names for a given extension, but also `{loader: string, options: Object}`. These options are verified to be serializable and passed to `loader-runner` and exposed as `getOptions()` to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing `class Foo {}; new Foo()` as an option value and verified the error was displayed.
2023-01-31 20:44:00 +00:00
Tim Neutkens
fb62d7e8cf v13.1.7-canary.1 2023-01-31 21:12:06 +01:00
Will Binns-Smith
eccd34fc75 css modules: use a terser selector format that requires less escaping (vercel/turbo#3437)
Fixes WEB-447.

Previously, generated classnames would include literal `/` characters,
which need escaping when generating selectors. While users should still
escape selectors, this avoids it for this case and makes generated code
easier to read. This format is also more aligned with what webpack-based
css modules generates.

This also removes the square character as a separator, since it breaks
words and makes double-clicking for selection more difficult.
2023-01-31 10:13:55 -08:00
Alex Kirszenberg
779bb9e06a Return a 404 status code when a data route is .notFound (vercel/turbo#3545)
Returning a 404 status code is required for the client-side router to
redirect to the error page.
2023-01-31 17:43:01 +01:00
JJ Kasper
5730dd7a8e
v13.1.7-canary.0 2023-01-30 17:36:24 -08:00
Will Binns-Smith
7409489910 @next/font/google: css variable followup (vercel/turbo#3514)
This addresses feedback from vercel/turbo#3505
2023-01-30 21:32:09 +00:00
Will Binns-Smith
c6701e1e79 Align ids and data attributes with Next.js's redbox (vercel/turbo#3522)
Next.js's integration test suite depends on these ids and data attributes to select against items in running test pages. This gets us passing some of those tests.
2023-01-30 07:37:25 +00:00
Leah
786dd71bf1 add pageExtensions support to appDir (vercel/turbo#3510)
The previous PR vercel/turbo#3499 only implemented support for `pages` directory.

The `app` directory previously had no validation at all, it's added with
this PR.

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-01-28 22:09:11 +01:00
Justin Ridgewell
aa0fb57093 Fix infinite loop caused by error page rendering (vercel/turbo#3525)
The new error paths introduced in vercel/turbo#3448 both write their outputs to
`.next/server/pages/`, which conflicts with:
- The main pages source
- Each other

The infinite loop is very fun:
1. We need a `NodeJsPoolVc` to render pages
2. To get a `NodeJsPoolVc`, you need to write your files onto disk
    - So a pool is dependent on the contents of those files
3. When we render an error page, we need to write those files to disk
4. The error page shares the same file entrypoint as the main page
source

So, to render an error, we write the entrypoint, which is shared with
main source. This alone is pretty bad, because it will invalidate our
page source's node pool (and kill those processes). But, the loop is
triggered by a more subtle bug:

When we write a file, we read it to see if the contents have changed.
Writing creates a dependency on the read! So when the error page is
written to disk, it invalidated the read we preformed when we wrote the
main page. That invalidated the main page (and it's node pool), and so
we rendered again. That wrote the main page's code to disk, invalidating
the read of the error page performed when we wrote the error page. ♾️

(I'll be opening more PRs…)
2023-01-28 21:04:07 +01:00
JJ Kasper
be86fcf6d5
v13.1.6 2023-01-27 18:25:45 -08:00
JJ Kasper
6e73650833
v13.1.6-canary.3 2023-01-27 17:49:58 -08:00
Alex Kirszenberg
9a5695c72b Add headers to app routes IPC (vercel/turbo#3518) 2023-01-27 15:56:25 -05:00
JJ Kasper
8324b4f030
v13.1.6-canary.2 2023-01-27 10:51:08 -08:00
Alex Kirszenberg
822bb5d15c Handle getStaticProps.redirect (vercel/turbo#3497)
This PR adds support for returning `redirect: { destination, permanent,
statusCode }` from `getStaticProps`.
2023-01-27 14:39:10 +01:00
Alex Kirszenberg
0cf02c89ed Handle 404 page when getStaticProps.notFound = true or the route is not found (vercel/turbo#3448)
This specifically supports the case where `getStaticProps.notFound =
true` or a matching route is not found, but not the case where
`getStaticPaths.fallback = false` and the route is not enumerated;

This separate case will be implemented in another PR.
2023-01-27 14:38:20 +01:00
Tobias Koppers
6416dcc276 enable and fix backtracing for fatal errors in tasks (vercel/turbo#3504)
Enables the anyhow backtrace feature to capture backtraces for errors
too when `RUST_BACKTRACE` is enabled.

When running in release mode compiling with
`CARGO_PROFILE_RELEASE_DEBUG=1` is recommended to get debug info into
the errors.
2023-01-27 08:49:21 +01:00
Will Binns-Smith
c1217ad3e3 @next/font/google: support setting a css variable for fonts (vercel/turbo#3505)
Fixes WEB-501

Fixes https://github.com/vercel/turbo/issues/3139

This adds proper support for the [`variable`
property](https://nextjs.org/docs/api-reference/next/font#variable) when
constructing fonts. This results in:

* defining a selector in the css module for a classname defining the css
custom property (css variable), whose value is the font family
* adding a `variable` property to the resulting js object whose value is
the classname used in the selector above

Test Plan: Added an integration test.
2023-01-27 08:48:15 +01:00
Justin Ridgewell
eb1ca3fb70 Review fixes for Next routing (vercel/turbo#3501)
This completes a few review requests from vercel/turbo#3446.
2023-01-26 21:02:54 -05:00
Will Binns-Smith
806c9eeb6c
build(cargo): update turbopack to turbopack-230126.1 (#45322)
**Note**: This requires https://github.com/vercel/next.js/pull/45314,
otherwise the following error is shown, but does not block builds:

```
error - [build] examples/create-app
  Error evaluating Node.js code
  TypeError: makeResolver is not a function
    at getResolveRoute (path/to/next.js/examples/create-app/.next/build/chunks/router.js:21:18)
    at async Module.route (path/to/next.js/examples/create-app/.next/build/chunks/router.js:24:36)
    at async Module.run (path/to/next.js/examples/create-app/.next/build/chunks/[turbopack-node]_ipc_evaluate.ts.js:19:39)
```

### Features

- https://github.com/vercel/turbo/pull/3446
- https://github.com/vercel/turbo/pull/3396
- https://github.com/vercel/turbo/pull/3499

### Bug fixes

- https://github.com/vercel/turbo/pull/3433

### Misc

- https://github.com/vercel/turbo/pull/3479
2023-01-26 14:42:48 -08:00
Wyatt Johnson
57ba24e39a
Improved pnpm clean (#45312)
When incompatibilities with upgrades to `swc` occur between releases,
these changes expand the existing `pnpm clean` script to additionally
run any `clean` script under any of the lerna packages. In this case, a
new script was created under `packages/next-swc` that removes
`packages/next-swc/native/*`, allowing the default to automatically use
the WASM build.

Users wanting to reset their repository can now run:

```sh
pnpm clean
```

Future packages or outputs that are built should have their `clean`
script remove them to allow for easy repository resetting.
2023-01-26 13:24:19 -08:00
Justin Ridgewell
c474d53ac1 Handle routing by calling Next.js code (vercel/turbo#3446)
This implements routing by using a-yet-to-be-implemented API exposed by
Next.js. The API follows something similar to:

```typescript
type MakeResolver = (config: NextConfig) => Resolver;
type Resolver = (IncomingMessage, ServerResponse) => Promise<void> | void;

import { makeResolver } from "next/dist/...";
const resolver  = makeResolver(nextConfig as object);

// Later, once we have a request we'd like to route:
// We don't care what the promise resolved to, we just want it to settle.
await resolver(req, res);
```

The resolver can do 1 of 3 things with this:
1. ~~Return a redirect response~~ Removed
2. Return a rewrite response
3. Stream a middleware response

> ~~1. Return a redirect response~~

<details>

First, ensure a `x-nextjs-route-result: 1` header is present on the
response. Then return a JSON encoded body:

```typescript
{
  url: string,
  statusCode: u16,
  headers: Record<string, string>
  isRedirect: true
}
```

The Rust server will then respond with a redirect using to the
appropriate location.

</details>

> 2. Return a rewrite response

First, ensure a `x-nextjs-route-result: 1` header is present on the
response. Then return a JSON encoded body:

```typescript
{
  url: string,
  headers: Record<string, string>
}
```

The Rust server will use this updated URL to request content from our
handlers.

> 3. Stream a middleware response

Ensure `x-nextjs-route-result` header **is not present** on the
response. All headers will be sent back, and the body will be streamed
back to the browser.

- - -

TODO:
- ~~Do `headers` actually matter to a `redirect`~~ Yes?
- ~~Does `statusCode` actually matter to a `rewrite`?~~ No
- ~~We can't handle streaming body responses yet.~~ Mocked by buffering.

Fixes WEB-228

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-01-26 21:15:48 +01:00
Leah
dc13baf6e7 add support for pageExtensions in next.config.js (vercel/turbo#3499) 2023-01-26 20:14:35 +00:00
github-actions[bot]
ff69c0f4e0 Update Google font-data.json (2023-01-26) (vercel/turbo#3479)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: wbinnssmith <wbinnssmith@users.noreply.github.com>
2023-01-26 10:07:13 -08:00
Leah
767dccb9c5 decode magic identifiers in error overlay (vercel/turbo#3433) 2023-01-26 17:50:20 +01:00
Tobias Koppers
8b42ea51de add edge compilation, runtime config parsing and edge apis (vercel/turbo#3396) 2023-01-26 12:55:51 +01:00
Will Binns-Smith
3e0231735b
build(cargo): update turbopack to turbopack-230125.1 (#45283) 2023-01-25 19:38:38 -08:00
Tobias Koppers
991de97b75 partially support next metadata (vercel/turbo#3464)
This adds support for metadata in pages and layouts.

Full metadata support also needs support for implicit metadata with
files named `icon.ico` etc.

This PR also improves the test suite and adds a basic test case for app
dir support
2023-01-25 19:25:33 +01:00
Shu Ding
2725a379bb
Attach exports information in SWC transforms (#45261)
Fixes NEXT-414

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] 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-01-25 12:51:59 +01:00
Shu Ding
ac0b6d2a71
Update transform exports and tests (#45251)
<!--
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 that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] 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-01-25 10:44:13 +01:00
github-actions[bot]
639ac4ff60 Update Google font-data.json (2023-01-25) (vercel/turbo#3463)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: wbinnssmith <wbinnssmith@users.noreply.github.com>
2023-01-25 08:26:02 +01:00
JJ Kasper
6a51edc35d
v13.1.6-canary.1 2023-01-24 20:00:52 -08:00
Alex Kirszenberg
7902145858 Fix data requests for dynamic routes (vercel/turbo#3435)
In addition to the fix, I've extracted the path regex/params matching logic from `turbopack-node` to `next-core`. `turbopack-node` now only declares a value trait which `next-core` implements.
2023-01-24 18:30:23 +00:00
Tobias Koppers
b256922644 refactor content sources to avoid evaluating content before serving (vercel/turbo#3334)
fixes WEB-141

This changes the ContentSource API.

Before a ContentSource returned a tuple of specificity and content.
Now it returns a tuple of specificity and a get_content function.

The old way made it very inefficient to combine multiple ContentSource.
All combined ContentSources were ask before, all returned specificity
and content, and they are ordered after that. That required to compute
all contents, even if it is not really used after ordering.

Now we order specificity and a get_content function and only compute the
content (by calling get_content) with the final result.

It also changes how data needs are expressed in the `get_content`
function. Instead of asking it over and over again with more data, it
statically returns the needed data with `vary` and the `get` function is
only called with that data. This is technically more limited than the
old way, but one can workaround that if needed. But practically we
probably never need that. On the other hand it improves the number of
function calls, since the `vary` method is only called once and the
`get` only once per request. Before data needs required at least 2 `get`
calls per request.
2023-01-24 16:16:33 +01:00
Hannes Bornö
6b5f5d2f9f
Add build time error if error.js is missing "use client" (#44961) 2023-01-24 09:57:40 +01:00
JJ Kasper
752136e84b
v13.1.6-canary.0 2023-01-23 15:04:49 -08:00
JJ Kasper
4e6ea4aaf2
v13.1.5 2023-01-23 11:32:41 -08:00
JJ Kasper
8dac22ad56
v13.1.5-canary.3 2023-01-23 10:40:13 -08:00
JJ Kasper
70282b7269
v13.1.5-canary.2 2023-01-21 21:24:01 -08:00
Tim Neutkens
ff50621228 v13.1.5-canary.1 2023-01-21 21:10:33 +01:00
Tim Neutkens
f970827db9 v13.1.5-canary.0 2023-01-21 17:11:49 +01:00
LongYinan
53be72be37
build(cargo): update turbopack (#45126)
### Features
- https://github.com/vercel/turbo/pull/3409

### Bug Fixes
- https://github.com/vercel/turbo/pull/3399
- https://github.com/vercel/turbo/pull/3412

### Chore
- https://github.com/vercel/turbo/pull/3398
- https://github.com/vercel/turbo/pull/3391
- https://github.com/vercel/turbo/pull/3350
2023-01-21 12:11:12 +00:00
Justin Ridgewell
98c9d723ff Handle empty pageData during HMR (vercel/turbo#3412)
Our `pageData` HMR process treated an undefined response as an error condition, but if the page doesn't have a `getXyzProps` exported method, then this is the default response. This prevented us from having any pages without page props.

The new code just sends down an empty object, which seems to work for establishing the connection. HMR updates are sent down (and seem to trigger restarts, at least from what I tested with `getStaticProps`).

Fixes WEB-445
2023-01-21 06:47:38 +00:00
JJ Kasper
0a5d27287f
v13.1.4 2023-01-20 14:59:00 -08:00