Commit Graph

1409 Commits

Author SHA1 Message Date
Tobias Koppers e8885417c7 [Turbopack] fix unresolvable typo (#71414)
### What?

Typo
2024-10-18 09:51:20 +02:00
Hendrik Liebau 8dfb58f8fe Skip unnecessary work in server action transforms for client modules (#71417)
The hoisting of the proxy expressions only needs to be done for the
server layer. We can skip this part completely when we know we're
compiling a module for the client layer.
2024-10-17 17:22:41 +00:00
Hendrik Liebau ac9ee5dd8f Adjust transforms for cached functions imported from client components (#71401)
This fixes the server reference ID generation in client modules so that
they can be import and called from client components. In addition,
support for cached functions with decoupled export declarations is
added.
2024-10-17 07:10:17 +00:00
Shu Ding 6158c1fe38 Fix default export and exported function expressions handling of cache directive transform (#71334)
This PR fixes the transform of handling `export default async function()
{}` and `export const foo = async function() {}` cases (both are
exported `fnExpr`, instead of `fnDecl`) in a `"use cache"` annotated
file.
2024-10-16 11:31:33 +02:00
Shu Ding 1255f20e34 Improve Server Reference transform to support closure variables from nested directives (#71332)
This adds support of collecting and binding encrypted closure variables
to references of `"use cache"` functions. These closures can be mixed
with `"use server"` in any order, too.

Check the tests for more information.
2024-10-16 11:30:54 +02:00
Hendrik Liebau 01117b24dc Add Turbopack support for 'use cache' in route handlers (#71306)
Adds the following missing pieces to Turbopack:
- apply server action transforms to route handler modules
- generate client reference manifests for route handler app endpoints
- make `experimental.cacheLife` config serialisable, to be injected into
the edge route handler modules
    - the `nextConfig` injection was already implemented in:
    #71258
2024-10-15 22:05:34 +02:00
Hendrik Liebau 2f16722f71 Add support for 'use cache' in route handlers using the Edge runtime (#71258)
Same as #70897, but for the Edge runtime. The changes are based on what
we're already doing for app pages that are using the Edge runtime.
2024-10-15 11:19:46 +00:00
Tobias Koppers bff036b0f7 improve code style of string operation in MiddlewareEndpoint (#70780)
### Why?

Avoiding allocations
2024-10-15 09:26:35 +02:00
Tobias Koppers e814d045c8 [Turbopack] use FxHasher for IndexMap/Set and DashMap (#71251)
### What?

* introduce and use use FxIndexMap and FxIndexSet everywhere instead of
IndexMaps
* use FxHashing in DashMaps
2024-10-14 16:52:44 +02:00
Niklas Mischkulnig 18e16185fd Turbopack: Refactor resolver to accept bool instead of severity (#71254)
I pulled out the core change from
https://github.com/vercel/next.js/pull/71155

- Refactor resolve functions to accept a `is_optional` boolean instead
of an explicit severity
- Add `ResolveOptions::loose_errors` to only emit warnings instead of
errors

Not sure if `loose_errors` is the best name. `warn_instead_of_errors`,
`emit_warnings_only` ?
2024-10-14 16:39:13 +02:00
Donny/강동윤 9b9dbe47d7 feat(turbopack): Remove special exports (#71126)
### What?

This PR removes special exports from tree shaking to apply it to more
modules

### Why?

Previously tree shaking pass simply gave up if there's a special export.

### How?
2024-10-14 20:34:31 +09:00
Donny/강동윤 92e84f4d51 feat(turbopack): Minify CSS files while building (#71130)
### What?

Enable minification of CSS when building for production.

### Why?

It's generally required.
2024-10-12 09:55:32 +00:00
Benjamin Woodruff 57a4e5c93b codemod(turbopack): Rewrite a few instances of Vc as ResolvedVc (#70927)
First PR generated by
https://github.com/vercel/turbopack-resolved-vc-codemod (private repo,
hacky low-quality throw-away code)

<img
src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/1b2b3800-5016-44b8-8868-98c76b58823e.png"
width="400">

The codemod is only able to "fix" compilation errors by rewriting
function arguments as `ResolvedVc`, so it's very limited right now, but
it's able to make some progress.

The codemod uses ast-grep's JS API to make all the changes:
https://ast-grep.github.io/guide/api-usage/js-api.html

I also evaluated gritql, but it didn't seem sufficient for this codemod:
[Internal
discussion](https://vercel.slack.com/archives/C03EWR7LGEN/p1727755062182179?thread_ts=1727709174.550549&cid=C03EWR7LGEN)

It turns out that a lot of these structs are actually dead code, so
#70987 is a follow-up to delete them.
2024-10-11 11:23:52 -07:00
Jiachi Liu 1b89b4b988 feat: block compilation on codemod comments and ask to remove (#71103)
Co-authored-by: 강동윤 (Donny) <kdy1997.dev@gmail.com>
2024-10-11 19:37:38 +02:00
Donny/강동윤 a2bfe3f8b9 fix(turbopack): Fix NextEcmascriptClientReferenceTransition (#70603)
### What?

Fix logic in `NextEcmascriptClientReferenceTransition`, which does not
fit for tree shaking logic.


### Why?



### How?


- Closes PACK-3263
2024-10-11 15:41:19 +00:00
Hendrik Liebau 490704430b Add source map support for server components/actions in the browser (#71042)
This PR adds support for showing the original server sources of server
components and server actions in the browser's developer tools.

To accomplish that, we're building on top of #69190, #70563, and #70564,
in which we prepared the proper generation of the source maps.

This PR completes the feature, by wiring up `findSourceMapURL` (see
https://github.com/facebook/react/pull/30741) with a new dev server
middleware that serves those source map files to the browser.

Another change we had to make is disabling the dead-code elimination of
server actions in client bundles (see #70103), but only in development
mode. This optimization is primarily intended for production bundles, so
the change should not pose a problem.

With that, it's now possible to jump directly into the server sources
from the browser's dev tools, e.g. for component stacks of server logs
that are replayed in the browser, or when inspecting server action props
in the React DevTools.
2024-10-11 13:53:39 +00:00
Donny/강동윤 3902b4b0ca build: Update swc_core to v0.106.3 (#70687)
### What?

Update SWC crates to
https://github.com/swc-project/swc/commit/d30b5ed695b1cfcf1bc8d376982661c765a57518

### Why?

To keep in sync with the main SWC repository
2024-10-11 08:23:03 +00:00
Tobias Koppers 1caa15115e [Turbopack] make filesystem tasks session dependent instead of invalidating on startup (#70945)
### What?

Before we did invalidate all filesystem tasks when an incremental build starts. But that has a performance linear to the number of filesystem tasks. We like to avoid that.

This PR refactors that and introduces a new dirty state, which means "task is dirty in general, but considered as clean for a certain session". All filesystem tasks are marked this way. When an incremental build starts we only increment the session id, which makes all filesystem tasks considered as dirty. No looping over all filesystem tasks to make them dirty anymore.

### Why?

Most of the cost before was spend in updating the task aggregation when task where marked dirty. This requires to restore a lot of aggregated tasks. This cost has moved to the point when the filesystem task is recomputed. So it's per page. This has benefits for next dev which doesn't build all pages.
2024-10-11 07:32:16 +02:00
Tobias Koppers 96a7efabef [Turbopack] allow to disable tree shaking (#71114)
### What?

This fixes `experimental.turbo.treeShaking: false` and allows to disable tree shaking
2024-10-10 21:02:28 +00:00
Shu Ding f6afb0e09e Fix SWC cache transform on the client layer (#71095)
This PR fixes the cache function transform on the client layer, which
should be transpiled into a Server Reference with proper sourcemap
parameters, similar to Server Actions.
2024-10-10 19:03:14 +00:00
Tobias Koppers b8db5e2e7c change default module id strategy back to dev (#71052)
### What?

Disable deterministic module ids by default until the performance issue
is solved.
2024-10-10 18:27:33 +00:00
Will Binns-Smith 13f8fcbb6b [Turbopack] Implement support for webpack’s stats.json (#70996)
This allows bundle analyzer tools to visualize and explore the output of
Next.js apps built with Turbopack.

Like Turbopack’s support for manifest files, this creates individual
stats files per entry point and merges them into a single stats file for
the app.

To do:

- [x] Make opt-in and build-only
- [x] Apply to pages router

Test Plan: `TURBOPACK_BUILD=1 TURBOPACK=1 pnpm build && pnpm dlx
webpack-bundle-analyzer .next/server/webpack-stats.
json .`
2024-10-10 04:55:37 +00:00
JJ Kasper dc92b51e9c Remove windows i686 next-swc build target (#71041)
After https://github.com/vercel/next.js/pull/70995 investigated how much
our windows 32 bit build is actually leveraged and it seems it is not at
all. Also it seems Windows itself is [ending support for 32
bit](https://community.f-secure.com/total-en/kb/articles/29675-support-for-windows-10-32-bit-ending-on-september-30-2024#:~:text=Other%20Languages&text=F%2DSecure%20will%20stop%20supporting,a%20new%20version%20of%20Windows)
arch so no reason for us to continue supporting it.

Build and deploy workflow run:
https://github.com/vercel/next.js/actions/runs/11260148483
x-ref: [slack
thread](https://vercel.slack.com/archives/C04KC8A53T7/p1728431976293749)
2024-10-09 11:15:49 -07:00
Niklas Mischkulnig 2a89504351 Turbopack: find client references layout segment optimization (#70792)
Closes PACK-3273

Before
![Bildschirmfoto 2024-10-04 um 16 13 15
Kopie](https://github.com/user-attachments/assets/6157e94c-bf49-4a59-9341-99244916d3be)

After
![Bildschirmfoto 2024-10-04 um 16 15
02](https://github.com/user-attachments/assets/6ee2d4e3-66f5-42a3-ba37-a3d7e0467cb1)
2024-10-09 11:04:56 +02:00
Tobias Koppers 3f01d2fc6e [Turbopack] add persistentCaching config option (#70904)
### What?

add experimental option to enable persistent caching
2024-10-08 20:22:52 +02:00
Benjamin Woodruff e5d0e38e12 refactor(turbopack/next-{api,core}): Remove remaining uses of vc generics in non-test code (#70816)
After this change, `cargo check` on a branch that deletes vc generics
support compiles successfully.

## Why?

Rather than extended support for `Vc` generics to `ResolvedVc`, I plan
to remove support for them entirely. That means fixing all the callsites
(there's not many).

Removing this is needed to get us to a point where 100% of structs can
be `ResolvedValue`, because structs using these fields cannot otherwise
be ported over to `ResolvedVc`.

## Okay, but Why?

Explained here:
https://github.com/vercel/turborepo/pull/8843#issuecomment-2253158412

I expect removing support for this will decrease the overall size of the
codebase, as the logic for supporting generics is rather complicated.
2024-10-07 16:24:47 -07:00
Benjamin Woodruff f70006ea16 refactor(turbopack/next-core): Remove uses of generic vc collections (#70815)
Removes the uses of generic vc collections in
`next-core/src/app_structure.rs` and it's callsites.

## Why?

Rather than extended support for `Vc` generics to `ResolvedVc`, I plan
to remove support for them entirely. That means fixing all the callsites
(there's not many).

Removing this is needed to get us to a point where 100% of structs can
be `ResolvedValue`, because structs using these fields cannot otherwise
be ported over to `ResolvedVc`.

## Okay, but Why?

Explained here:
https://github.com/vercel/turborepo/pull/8843#issuecomment-2253158412

I expect removing support for this will decrease the overall size of the
codebase, as the logic for supporting generics is rather complicated.
2024-10-07 15:05:54 -07:00
Will Binns-Smith 189f2da207 Update Rust toolchain to nightly-2024-10-04 (#70803)
This:

- Updates the toolchain file
- Adds `#![feature(arbitrary_self_types_pointers)]` as necessary
- Removes opt-ins for now-stable features like
`option_get_or_insert_default`
- Removes now-detectable dead code
2024-10-07 21:54:44 +00:00
Benjamin Woodruff cbf32150a5 fix(turbo-tasks): Implement TaskInput for ResolvedVc` (#70814)
`TaskInput` isn't needed/used for a bare `ResolvedVc`, as we'll expose
`ResolvedVc` arguments as `Vc`, but it is useful for structs that
contain `ResolvedVc` and want to derive `TaskInput`.

This PR also ports `next_core::app_structure::Entrypoint` to use
`ResolvedVc` as a way of testing this.
2024-10-07 13:53:35 -07:00
Jiachi Liu 79bc150e95 Fix missing await of params in metadata route (#70900) 2024-10-07 17:57:28 +02:00
Jiwon Choi bba71906c4 feat(next): throw when twitter-image or opengraph-image file size exceeds (#70353)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-10-07 13:46:14 +00:00
Tobias Koppers d1ec45e94c [Turbopack] Preparations for persisting (#70468)
### What?

parallel filesystem invalidation

use turbo_tasks spawn blocking
2024-10-07 12:02:48 +02:00
Hendrik Liebau a572740f46 Create spans for createServerReference and registerServerReference (#70564)
Creating proper source location spans for `createServerReference` and
`registerServerReference` is the next step in enabling source mapping of
server actions. With the added e2e test app, we can already verify that
this works by mocking `findSourceMapURL`.

Properly implementing `findSourceMapURL` will be the last missing piece
to complete the puzzle.

<img width="751" alt="server action go to definition"
src="https://github.com/user-attachments/assets/bfe26e92-c497-40d0-ab39-ba0febbd412f">

<img width="751" alt="server action source"
src="https://github.com/user-attachments/assets/daaecf4e-0bd7-44ab-b082-68a24cdf33f9">

<img width="1039" alt="source map viz server"
src="https://github.com/user-attachments/assets/9b2fc944-29e9-4ed4-82a9-8a27f82e913c">

<img width="1039" alt="source map viz client"
src="https://github.com/user-attachments/assets/7fc2f86c-8e74-49e6-be59-9edf5494eb57">
2024-10-04 17:31:04 +02:00
Niklas Mischkulnig 9e86040bcf Turbopack: next/dynamic layout segment optimization (#70708)
Closes PACK-3274

This deduplicates work by only searching for `next/dynamic` once per
layout segment.

- `collect_next_dynamic_imports` is a turbotask now, executed once per
layout segment
- `collect_next_dynamic_imports` also takes a list of visited modules,
to prevent revisiting

Before
<img width="1722" alt="Bildschirmfoto 2024-10-01 um 15 28 34"
src="https://github.com/user-attachments/assets/0db86796-289e-4d8a-95b9-4164bcaabc71">

After
<img width="1728" alt="Bildschirmfoto 2024-10-02 um 15 17 10"
src="https://github.com/user-attachments/assets/bfb99b03-26d8-4c0f-b97e-f9e437f7fc4c">
2024-10-04 15:54:46 +02:00
Hendrik Liebau 5975ae0e5d Unwrap registerServerReference function (#70563)
In the same vein as #69190, where we already unwrapped `createServerReference`, we now also unwrap `registerServerReference`, which is required for React to select the right call stack frame when generating source locations for server actions (see facebook/react#30741).

Whereas unwrapping of `createServerReference` was required for server actions that are imported into client components, unwrapping `registerServerReference` is needed for server actions that are passed from server components to client components.

This does not fully enable the source mapping just yet. For this to work end-to-end, the next step is to generate proper spans in the SWC transform, which will be done in the next PR.
2024-10-04 13:09:03 +02:00
Tobias Koppers 3b9889e1d8 [Turbopack] add new backend (#69667)
### What?

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

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

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

### Why?

* Reduced memory usage
* preparation for persistent caching
2024-10-04 09:57:55 +02:00
Benjamin Woodruff 6993467a5e refactor(turbo-tasks-fs): Use ResolvedVc instead of Vc in structs (#70576)
This is a handmade refactor of `turbo-tasks-fs` to switch every struct's
field from `Vc<T>` to `ResolvedVc<T>`.

I chose `turbo-tasks-fs` because it's reasonably small, but very widely
used, and it has a representative mix of code patterns.

In the process of creating this PR, I wrote up a guide of the steps
required to refactor this, in the hope that we can automate most of
these steps for most code:
https://vercel.notion.site/Codemod-Notes-for-Vc-T-ResolvedVc-T-10ee06b059c480688ebffe5eb983db25
2024-10-03 21:08:23 -07:00
Hendrik Liebau 52a167aa38 Refactor: split up maybe_hoist_and_create_proxy (and cache variant) (#70556) 2024-10-03 02:53:28 +02:00
Tobias Koppers 043dbc85c8 [Turbopack] HMR invalidation improvements (#70494)
### What?

* round chunk item sizes to cause less changes to chunking
* pick individual values from compile time info to avoid invalidating on
change
* pick next config keys for more granular caching
* split completions into a tree

---------

Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
2024-10-02 11:27:48 +02:00
hrmny 35a053a91a feat(turbopack): add support for polling file watcher (#69684)
### What?
The normal file watcher doesn't work inside a docker container, the
workaround is to enable a polling file watcher, which was supported in
webpack but not turbopack so far.

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


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

Closes PACK-3206
Fixes #68255
2024-10-01 19:48:05 +02:00
Niklas Mischkulnig 47b9fc6128 Turbopack: Allow ESM externals in SSR (#70258)
Closes PACK-3244
Closes https://github.com/vercel/next.js/issues/69562

Await the module in both environments (SSR/browser), if it's async in at
least one of them.

We can't and don't want to make the browser module async (artifically)
if the SSR module is async (due to ESM externals).

The only concern regarding `async` not always being true in the manifest
was that we don't want to await in non TLA cases (e.g. CJS exporting a
promise, etc...).
But the SSR module being ESM with TLA and the browser module being CJS
with a Promise export is exceedingly unlikely.
2024-10-01 14:41:21 +02:00
Josh Story 17a7dc2ef3 Update dynamicIO experiment to use React canary (#70571)
Initially the non-PPR `dynamicIO` implementation used some experimental
React APIs. This change updates the technique to only depend on APIs in
the canary channel and updates the packaging rules to only not opt into
experimental react when dynamicIO is enabled. Other experimental flags
can still opt you into experimental react such as PPR.
2024-09-30 09:40:25 -07:00
Shu Ding 5c235de03f Improve the RSC directive transform (#70562)
This PR extends the cache directive to accept an additional type
parameter which defaults to `"default"`.

Several follow-ups:
- Accept different syntaxes (like places of spaces) and typo detection;
- Have a limited set of valid options with better errors.
2024-09-28 02:03:10 +00:00
Shu Ding 2fc641efb6 Unwrap createServerReference, and pass additional parameters (#69190)
For https://github.com/facebook/react/pull/30741

This PR adds several additional parameters to the
`createServerReference` calls generated by the Server Reference SWC
transform, to later enable React to map server actions that are imported
into client components back to their server locations (dev mode only).

Currently the inner `findSourceMapURL` function is not yet implemented.

In a follow-up we will unwrap `registerServerReference` as well, which
is needed for server actions in the react server layer.

---------

Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
2024-09-27 07:52:21 +02:00
Benjamin Woodruff e1ea01defe codemod(turbopack): Remove unused Result<...> return types from #[turbo_task::function]s (#70492)
The `#[turbo_tasks::function]` macro always exposes a `impl
Future<Output = Result<ReadRef<T>>>`, regardless of the function's
actual return type.

We only need to use a `Result<...>` return type when the function can
fail. If it's infallible, this just adds noise.

I left a bunch of these behind in #70412, plus I think we had a lot of
these independent of that PR. This cleans them up.

```yaml
language: rust
id: remove_unused_result_return_type

utils:
  last-expression-inside-block:
    any:
      - inside: # single-line blocks just have the expression as the only child
          kind: block
        nthChild:
          position: 1
          reverse: true
      - inside: # multi-line blocks wrap their final expression in an expression_statement
          kind: expression_statement
          inside:
            kind: block
          nthChild:
            position: 1
            reverse: true
  ok-expression:
    kind: call_expression
    any:
      - pattern: Ok($_ARG)
      - pattern: $$$::Ok($_ARG)
  ok-expression-capturing:
    kind: call_expression
    any:
      - pattern: Ok($ARG)
      - pattern: $$$::Ok($ARG)
  # ast-grep does not appear to allow utils to be recursive, split out "simple blocks", and limit supported nesting
  simple-block-with-implicit-ok-return:
    kind: block
    has:
      nthChild:
        position: 1
        reverse: true
      matches: ok-expression
  simple-expression-ok-value:
    any:
      - matches: simple-block-with-implicit-ok-return
      - kind: if_expression
        all:
          - has:
              field: consequence
              matches: simple-block-with-implicit-ok-return
          - has:
              field: alternative
              has:
                matches: simple-block-with-implicit-ok-return
      - kind: match_expression
        has:
          field: body
          not:
            has:
              kind: match_arm
              has:
                field: value
                not:
                  any:
                    - matches: ok-expression
                    - matches: simple-block-with-implicit-ok-return
  block-with-implicit-ok-return:
    any:
      - matches: simple-block-with-implicit-ok-return
      - kind: block
        has:
          nthChild:
            position: 1
            reverse: true
          any:
            - kind: expression_statement 
              has:
                matches: simple-expression-ok-value
            - matches: simple-expression-ok-value # single-line blocks don't
  result-return-type:
    pattern:
      context: fn func() -> Result<$INNER_RET_TY> {}
      selector: generic_type
  infallible-fn:  # this function only appears to return `Ok(...)`, it does not use try_expression (`?`) or `anyhow::bail!(...)`
    kind: function_item
    not:
      has:
        field: body
        any:
          - not:
              matches: block-with-implicit-ok-return
          - has:
              stopBy:
                kind: function_item
              any:
                - kind: try_expression
                - pattern: "?"
                  inside:
                    kind: macro_invocation
                    stopBy: end
                - pattern: bail!($$$)
                - pattern: $$$::bail!($$$)
                - kind: return_expression
                  not:
                    has:
                      matches: ok-expression

rule:
  all:
    - pattern: $FUNC
    - kind: function_item
      has:
        field: return_type
        matches: result-return-type
      follows:
        pattern:
          context: |
            #[turbo_tasks::function]
          selector: attribute_item
        stopBy:
          not:
            kind: attribute_item
    - matches: infallible-fn

rewriters:  # this rewriter is far from perfect, and might rewrite too much
  - id: rewrite-return-type
    rule:
      matches: result-return-type
      inside:
        kind: function_item
        field: return_type
    fix: $INNER_RET_TY
  - id: unwrap-ok-values
    rule:
      all:
        - matches: ok-expression-capturing
        - any:
          - matches: last-expression-inside-block
          - inside:
              kind: return_expression
          - inside:
              kind: match_arm
    fix: $ARG

transform:
  NEW_FUNC:
    rewrite:
      rewriters:
        - rewrite-return-type
        - unwrap-ok-values
      source: $FUNC

fix: $NEW_FUNC

ignores:
  - "**/turbo-tasks-testing/**"
  - "**/turbo-tasks-memory/tests/**"
```

```
sg scan -U -r ../codemod_remove_unused_result_return_type.yml && cargo fix --lib --allow-dirty && cargo fmt
```

I used `cargo fix` in this case to auto-remove the now-unused
`anyhow::Result` imports.

I manually fixed clippy lints that now violated the `let_and_return`
lint rule (using a separate commit inside this PR), as `cargo clippy
--fix` seemed to hang when processing our `build.rs` files?
2024-09-26 15:35:07 +02:00
Benjamin Woodruff bb1617b30f codemod(turbopack): Remove unused async function modifier keywords (#70474)
I left a bunch of these behind in #70412 . This cleans them up.

The only remaining work after this is removing unused `Result<...>`s
from return types.

ast-grep config:

```yaml
language: rust
id: remove_unused_async_keyword

rule:
  pattern: async
  inside:
    kind: function_modifiers
    inside:
      kind: function_item
      follows:
        pattern:
          context: |
            #[turbo_tasks::function]
          selector: attribute_item
        stopBy:
          not:
            kind: attribute_item
      has:
        field: body
        not:
          has:
            any:
              - kind: await_expression
              - pattern:
                  context: foo!($$$ await $$$)
                  selector: token_tree
                inside:
                  kind: macro_invocation
                  stopBy: end
            stopBy:
              any:
                - kind: function_item
                - kind: async_block
                - kind: closure_expression

fix: ""

# these files have intentionally async functions
ignores:
  - "**/turbo-tasks-testing/**"
  - "**/turbo-tasks-memory/tests/**"
```

Applied with:

```
sg scan -U -r ../codemod_remove_unused_async_keyword.yml . && cargo fmt
```
2024-09-25 19:08:39 -07:00
Donny/강동윤 5fd1d537c1 feat(next-swc): lint for ssr: false in server components (#70378)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-09-25 20:40:33 +02:00
Benjamin Woodruff 94c4e5dade codemod(turbopack): Inline trivial uses of let this = self (#70431)
A follow-up to the #70431 codemod diff, which leave behind a lot of
trivial `let this = self;` statements.

Using the following ast-grep rule config:

```yaml
language: rust
id: inline_trivial_this

utils:
  block-with-this:
    all:
    - pattern: $BLOCK
    - kind: block
    - has:
        all:
          - pattern: let this = $SELF;
          - any:
            - pattern: let this = self;
            - pattern: let this = &self.0;

rule:
  matches: block-with-this

rewriters:
  - id: remove-let-this
    rule:
      pattern: let this = $SELF;
    fix: ""
  - id: inline-this-auto-deref
    rule:
      pattern: this
      inside:
        kind: field_expression
    transform:
      SELF_AUTO_DEREF:
        replace:
          source: $SELF
          replace: "&?(?<INNER>.*)"
          by: "$INNER"
    fix: $SELF_AUTO_DEREF
  - id: inline-this
    rule:
      pattern: this
    fix: $SELF

transform:
  NEW_BLOCK:
    rewrite:
      source: $BLOCK
      rewriters:
        - remove-let-this
        - inline-this-auto-deref
        - inline-this

fix:
  $NEW_BLOCK
```

Applied with

```
sg scan -U -r ../codemod_inline_trivial_this.yml .
```
2024-09-25 10:15:40 -07:00
Sebastian "Sebbie" Silbermann 1cb6faaee1 Extend support of Pages router to React 18 (#70219) 2024-09-25 19:08:13 +02:00
Niklas Mischkulnig 7e32b38b89 Turbopack: fix another case of edge runtime warnings (#70455)
Closes PACK-3276
2024-09-25 17:16:25 +02:00