Skip to content

Commit

Permalink
feat(turbopack): Enable lightningcss for turbopack by default (#62565)
Browse files Browse the repository at this point in the history
# Turbopack

* vercel/turborepo#7682 <!-- Will Binns-Smith -
Turbopack HMR: url-encode sourceURLs -->
* vercel/turborepo#7524 <!-- Donny/강동윤 -
feat(turbopack): Enable lightningcss for turbopack by default -->


### What?

Enable lightningcss by default, for `--turbo` mode.

### Why?

It's time to do it 😄 

### How?

Turbopack counterpart: vercel/turborepo#7524


Closes PACK-2600
  • Loading branch information
kdy1 authored Mar 11, 2024
1 parent 41019c2 commit d55699d
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 81 deletions.
70 changes: 35 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ swc_core = { version = "0.90.17", features = [
testing = { version = "0.35.20" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240308.3" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240311.1" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240308.3" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240311.1" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240308.3" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240311.1" }

# General Deps

Expand Down
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pub async fn get_client_module_options_context(
.cell()
});

let use_lightningcss = *next_config.use_lightningcss().await?;
let use_swc_css = *next_config.use_swc_css().await?;
let target_browsers = env.runtime_versions();

let mut next_client_rules =
Expand Down Expand Up @@ -321,7 +321,7 @@ pub async fn get_client_module_options_context(
),
],
custom_rules: next_client_rules,
use_lightningcss,
use_swc_css,
..module_options_context
}
.cell();
Expand Down
12 changes: 8 additions & 4 deletions packages/next-swc/crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ pub struct ExperimentalTurboConfig {
pub rules: Option<IndexMap<String, RuleConfigItem>>,
pub resolve_alias: Option<IndexMap<String, JsonValue>>,
pub resolve_extensions: Option<Vec<String>>,
pub use_swc_css: Option<bool>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)]
Expand Down Expand Up @@ -504,8 +505,6 @@ pub struct ExperimentalConfig {
/// (doesn't apply to Turbopack).
webpack_build_worker: Option<bool>,
worker_threads: Option<bool>,

use_lightningcss: Option<bool>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)]
Expand Down Expand Up @@ -836,9 +835,14 @@ impl NextConfig {
}

#[turbo_tasks::function]
pub async fn use_lightningcss(self: Vc<Self>) -> Result<Vc<bool>> {
pub async fn use_swc_css(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(
self.await?.experimental.use_lightningcss.unwrap_or(false),
self.await?
.experimental
.turbo
.as_ref()
.and_then(|turbo| turbo.use_swc_css)
.unwrap_or(false),
))
}
}
Expand Down
Loading

0 comments on commit d55699d

Please sign in to comment.