Commit graph

1392 commits

Author SHA1 Message Date
Tobias Koppers
2820f07875
add consistent import sorting/grouping to rustfmt (#47745)
### What?

Better auto format

### Why?

imports are inconsistently grouped and ordered

### How?

configure cargo fmt
2023-03-31 22:12:54 +00:00
JJ Kasper
f798c95f72 v13.2.5-canary.24 2023-03-31 20:58:12 +00:00
Justin Ridgewell
0413fea8ea
Turobpack: Implement Streaming App/API rendering (#47476)
Paired with https://github.com/vercel/turbo/pull/4329, this implements
streaming responses for App and API renders. This is accomplished by
sending an initial `headers` message (carrying the status code and
headers list), N `body-chunk` messages of bytes, and a final `body-end`
message to signal completion.

Once sent to Turbopack, these chunk messages will be streamed out of the
node rendering process directly into the HTTP server's response.

Closes WEB-27

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-31 20:58:04 +02:00
Leah
5cb370f517
remove next-core package.json dev script (#47746)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-31 17:58:17 +02:00
JJ Kasper
f090f321ee v13.2.5-canary.23 2023-03-31 13:53:10 +00:00
Alex Kirszenberg
5950e2b3b0
Small fixes to copy of Turbopack errors (#47734)
This also removes next-swc's Prettier configuration, which we weren't
following anyway.
2023-03-31 11:12:12 +00:00
Jiachi Liu
6563174176
Add NEXT_RUNTIME process env to turbopack (#47713)
Support `process.env.NEXT_RUNTIME` in turbopack, define it in node server / edge, leave client as undefined
2023-03-31 09:48:15 +00:00
OJ Kwon
a34f02b3d2
feat(next-swc): add compile-time heap profiler flag (#47729)
### What?

This PR adds an internal compile time flags for the `next-swc`, which exposes two runtime apis into next.js to initialize heap-profiling enabled memory allocator and teardown those once next.js exits. While there are newly added 2 js interfaces (`initHeapProfiler`, `teardownHeapProfiler`) underlying napi binary itself have compile time flags to actually  enable those feature: any user who runs npm-published next.js cannot enable this features with any kind of runtime configuration. Only manually built next-swc binary with specific flag can enable this. Since this is primarily for the CI testing workflow only, those flag / configs are not visibily exposed as well.


### Why?

It is for some experiments on the CI to see if it can observe some of memory pressure issues (WEB-593, WEB-804) while it is not easily reproducible on the local machines.
2023-03-31 08:37:17 +00:00
Wyatt Johnson
2642d0a83e
Combine Route Handlers with Route Modules (#47679)
Based on some suggestions from @sokra, this serves to unify the Route Handlers and Route Modules to provide a unified interface for defining route modules and handlers and defining their dependancies.
2023-03-31 04:52:48 +00:00
Justin Ridgewell
43872c7572
Turbopack: Fix images.remotePatterns port/protocol serialization (#47721)
By default, `serde-json` will transform a `None` into a `null` value, and Next's [default image loader][loader] will perform strict `=== undefined` [equality checks][checks] on the fields. Because `null !== undefined`, a missing `protocol` or `port` will always be checked, and `null` will never match either.

Fixes #46758
Fixes vercel/turbo#4347
Fixes WEB-770
fix NEXT-793 ([link](https://linear.app/vercel/issue/NEXT-793))

[loader]: 35cf930572/packages/next/src/shared/lib/image-loader.ts (L50)
[checks]: 35cf930572/packages/next/src/shared/lib/match-remote-pattern.ts (L5)
2023-03-31 03:26:38 +00:00
JJ Kasper
a6e504933b v13.2.5-canary.22 2023-03-31 00:57:10 +00:00
Leah
97b158cc81
Fix turbopack _devPagesManifest.json on next-site (#47427)
just took a bit of banging my head against the wall 👀

the `'dynamic route/page check'` route resolves `fsRoutes` (which leads to an object with `{pages: undefined}` because the route doesn't have the list of pages(?))

that route only gets enabled if you have fallback rewrites though
2023-03-30 21:44:02 +00:00
JJ Kasper
4803102a24 v13.2.5-canary.21 2023-03-30 05:16:37 +00:00
JJ Kasper
6e8ee78dfa
Fix rust-check 2023-03-29 20:27:01 -07:00
OJ Kwon
7e70ac64b3
build(next-swc): introduce turbo-binding (#47512)
<!-- 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 #

-->

### What?

Part of WEB-736.

This PR refactors imports to turbopack to turbo-binding, as same as we
used to do with next-binding. Current next-binding in this repo doesn't
make sense anymore and removed. There are no functional changes. This'll
reducwe surface for the imports and also will make easier to run
integration test over latest turbopack.

Note swc dependency is not reflected in this PR yet - following PR will
update those imports.
2023-03-29 20:25:11 -07:00
Leah
0ed46203aa
resolve browser modules for edge api in turbopack (#47604) 2023-03-30 01:58:51 +00:00
Tobias Koppers
f44e214ff1
provide Buffer polyfill to client and edge (#47610)
### What?

see also https://github.com/vercel/turbo/pull/4368

Polyfill Buffer

### Why?

Legacy reasons

fixes WEB-642
2023-03-29 21:33:30 +00:00
Wyatt Johnson
aca83d2a09
Move App Route handler logic into bundle (#47633)
Previously the app route handler was included in the server bundle, and called into user code to execute the underlying handler logic. This PR serves to move the handler code into the bundle so that the Node.js environment more closely matches the Edge environment.

This also updates the Rust code for the new loader.
fix NEXT-712 ([link](https://linear.app/vercel/issue/NEXT-712))
2023-03-29 19:31:30 +00:00
Leah
13f21520c2
show most recent error first in turbopack error overlay (#47414)
Also refactors the `Errors` state into a reducer, which makes things a bit easier to reason about (in my opinion)


I tried adding an ID to the issue, so we don't have to stringify the whole issue, but unfortunately that duplicates (parsing issues)

the reason is probably that files get parsed twice, once for the client and once for the server side
2023-03-29 16:05:31 +00:00
Leah
46151dd68b
fix typescript errors in next-core (#47607)
Fixes WEB-809
2023-03-29 02:53:32 +00:00
Tobias Koppers
18131c7dab v13.2.5-canary.20 2023-03-28 08:18:00 +00:00
Tobias Koppers
e5eba6181f
add test case for nested imports (#47580)
### What?

Test case for https://github.com/vercel/turbo/pull/4349

### Why?

It should continue working 

### How?

Test case added
2023-03-28 00:26:41 -07:00
Will Binns-Smith
80d6c69867
Document various structs and methods in next/font (#47588) 2023-03-28 04:56:52 +00:00
Will Binns-Smith
56ebe97ae4
Implement automatic font fallback support for next/font/local (#47463)
Fixes WEB-787.

This implements automatic font fallbacks for `next/font/local`. It uses the `allsorts` library to query font metrics across woff and ttf fonts.

Test Plan: Now passes 24 Next.js integration tests, up from 14.
2023-03-28 01:22:48 +00:00
OJ Kwon
553cf48acb
ci(workflow): run checks for the test specific features (#47572)
This PR is minor update to ci workflow to verify test-only features are
being compilable correctly.
2023-03-27 14:31:45 -07:00
Shu Ding
b28cd21ee5
Improve client boundary source type detection (#47532)Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Currently in a client boundary file, we only explicitly export
individual fields in ESM (`export foo`) when the source type is
`module`. However in most of the time SWC gives the `auto` source type.
This PR improves the type detection a bit so if it's `auto` and we do
see ESM exports collected, we assume it's ESM and re-export these
fields.

Fixes #41940, fix NEXT-796
([link](https://linear.app/vercel/issue/NEXT-796)).

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-27 19:16:23 +02:00
Will Binns-Smith
e3875d7421
next/font/local support for Turbopack (#47369)
Fixes WEB-249

Depends on vercel/turbo#4288

This implements support for `next/font/local` for Turbopack. It:

* Removes the compile-time feature restricting access to `next/font/local`
* Implements `NextFontLocalReplacerVc` and `NextFontLocalCssModuleReplacerVc`, similar to their `next/font/google` equivalents, and adds them as ImportMappings to handle requests for `next/font/local/target.css` and `@vercel/turbopack-next/internal/font/local/cssmodule.module.css` (these requests are created by the JavaScript returned by the requests for the `target.css` module)
* Implements fallback support for Times New Roman and Arial via `adjust_font_fallback` as the webpack implementation does. Font metric override adjustment will be added in a future PR.

Test Plan: New passes 14 next-font integration tests in the Next.js integration test suite, up from 8.
2023-03-27 16:30:25 +00:00
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