Skip to content

Commit

Permalink
Improve swc transforms (#45083)
Browse files Browse the repository at this point in the history
x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1674048645326239

## 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)
  • Loading branch information
kdy1 authored Jan 20, 2023
1 parent c254b74 commit c30c14d
Show file tree
Hide file tree
Showing 10 changed files with 476 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/next-swc/crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub mod react_server_components;
#[cfg(not(target_arch = "wasm32"))]
pub mod relay;
pub mod remove_console;
pub mod server_actions;
pub mod shake_exports;
mod top_level_binding_collector;

Expand Down Expand Up @@ -122,6 +123,9 @@ pub struct TransformOptions {

#[serde(default)]
pub font_loaders: Option<next_font_loaders::Config>,

#[serde(default)]
pub server_actions: Option<server_actions::Config>,
}

pub fn custom_before_pass<'a, C: Comments + 'a>(
Expand Down Expand Up @@ -252,6 +256,11 @@ where
Some(config) => Either::Left(next_font_loaders::next_font_loaders(config.clone())),
None => Either::Right(noop()),
},
match &opts.server_actions {
Some(config) =>
Either::Left(server_actions::server_actions(&file.name, config.clone())),
None => Either::Right(noop()),
},
)
}

Expand Down
Loading

0 comments on commit c30c14d

Please sign in to comment.