Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(turbopack): Remove swc_css #72602

Merged
merged 12 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ pub async fn get_client_module_options_context(
let tree_shaking_mode_for_foreign_code = *next_config
.tree_shaking_mode_for_foreign_code(next_mode.is_development())
.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 @@ -355,7 +354,6 @@ pub async fn get_client_module_options_context(
enable_webpack_loaders,
enable_mdx_rs,
css: CssOptionsContext {
use_swc_css,
minify_type: if *next_config.turbo_minify(mode).await? {
MinifyType::Minify
} else {
Expand Down
12 changes: 0 additions & 12 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ pub struct ExperimentalTurboConfig {
pub rules: Option<FxIndexMap<RcStr, RuleConfigItemOrShortcut>>,
pub resolve_alias: Option<FxIndexMap<RcStr, JsonValue>>,
pub resolve_extensions: Option<Vec<RcStr>>,
pub use_swc_css: Option<bool>,
pub tree_shaking: Option<bool>,
pub module_id_strategy: Option<ModuleIdStrategy>,
pub minify: Option<bool>,
Expand Down Expand Up @@ -1156,17 +1155,6 @@ impl NextConfig {
))
}

#[turbo_tasks::function]
pub fn use_swc_css(&self) -> Vc<bool> {
Vc::cell(
self.experimental
.turbo
.as_ref()
.and_then(|turbo| turbo.use_swc_css)
.unwrap_or(false),
)
}

#[turbo_tasks::function]
pub fn optimize_package_imports(&self) -> Vc<Vec<RcStr>> {
Vc::cell(
Expand Down
2 changes: 0 additions & 2 deletions crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ pub async fn get_server_module_options_context(
let tree_shaking_mode_for_foreign_code = *next_config
.tree_shaking_mode_for_foreign_code(next_mode.is_development())
.await?;
let use_swc_css = *next_config.use_swc_css().await?;
let versions = RuntimeVersions(Default::default()).cell();

// ModuleOptionsContext related options
Expand Down Expand Up @@ -519,7 +518,6 @@ pub async fn get_server_module_options_context(
},
execution_context: Some(execution_context),
css: CssOptionsContext {
use_swc_css,
..Default::default()
},
tree_shaking_mode: tree_shaking_mode_for_user_code,
Expand Down
3 changes: 1 addition & 2 deletions crates/next-core/src/next_shared/transforms/styled_jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ pub async fn get_styled_jsx_transform_rule(
target_browsers: Vc<RuntimeVersions>,
) -> Result<Option<ModuleRule>> {
let enable_mdx_rs = next_config.mdx_rs().await?.is_some();
let use_swc_css = *next_config.use_swc_css().await?;
let versions = *target_browsers.await?;

let transformer = StyledJsxTransformer::new(!use_swc_css, versions);
let transformer = StyledJsxTransformer::new(versions);
Ok(Some(get_ecma_transform_rule(
Box::new(transformer),
enable_mdx_rs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ The following options are available for the `turbo` configuration:
| `resolveAlias` | Map aliased imports to modules to load in their place. |
| `resolveExtensions` | List of extensions to resolve when importing files. |
| `moduleIdStrategy` | Assign module IDs |
| `useSwcCss` | Use `swc_css` instead of `lightningcss` for Turbopack |
| `treeShaking` | Enable tree shaking for the turbopack dev server and build. |
| `memoryLimit` | A target memory limit for turbo, in bytes. |

Expand Down
1 change: 0 additions & 1 deletion packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
)
.optional(),
resolveExtensions: z.array(z.string()).optional(),
useSwcCss: z.boolean().optional(),
treeShaking: z.boolean().optional(),
persistentCaching: z
.union([z.number(), z.literal(false)])
Expand Down
5 changes: 0 additions & 5 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ export interface ExperimentalTurboOptions {
*/
rules?: Record<string, TurboRuleConfigItemOrShortcut>

/**
* Use swc_css instead of lightningcss for Turbopack
*/
useSwcCss?: boolean

/**
* A target memory limit for turbo, in bytes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
const nextConfig = {
experimental: {
useLightningcss: true,
turbo: {
useSwcCss: false,
},
},
}

Expand Down
1 change: 0 additions & 1 deletion turbopack/crates/turbopack-cli/src/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ async fn get_client_module_options_context(
StyledComponentsTransformer::new(&StyledComponentsTransformConfig::default()),
) as _)),
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(StyledJsxTransformer::new(
!module_options_context.css.use_swc_css,
versions,
)) as _)),
]),
Expand Down
6 changes: 0 additions & 6 deletions turbopack/crates/turbopack-css/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ turbopack-swc-utils = { workspace = true }
parcel_sourcemap = "2.1.1"
smallvec = { workspace = true }
swc_core = { workspace = true, features = [
"css_ast",
"css_codegen",
"css_compat",
"css_modules",
"css_parser",
"css_visit",
"ecma_ast",
"common",
"common_concurrent",
Expand Down
14 changes: 3 additions & 11 deletions turbopack/crates/turbopack-css/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ use crate::{
};

#[turbo_tasks::function]
fn modifier(use_swc_css: bool) -> Vc<RcStr> {
if use_swc_css {
Vc::cell("swc css".into())
} else {
Vc::cell("css".into())
}
fn modifier() -> Vc<RcStr> {
Vc::cell("css".into())
}

#[turbo_tasks::value]
Expand All @@ -41,7 +37,6 @@ pub struct CssModuleAsset {
import_context: Option<Vc<ImportContext>>,
ty: CssModuleAssetType,
minify_type: MinifyType,
use_swc_css: bool,
}

#[turbo_tasks::value_impl]
Expand All @@ -53,7 +48,6 @@ impl CssModuleAsset {
asset_context: Vc<Box<dyn AssetContext>>,
ty: CssModuleAssetType,
minify_type: MinifyType,
use_swc_css: bool,
import_context: Option<Vc<ImportContext>>,
) -> Vc<Self> {
Self::cell(CssModuleAsset {
Expand All @@ -62,7 +56,6 @@ impl CssModuleAsset {
import_context,
ty,
minify_type,
use_swc_css,
})
}

Expand All @@ -85,7 +78,6 @@ impl ParseCss for CssModuleAsset {
this.import_context
.unwrap_or_else(|| ImportContext::new(vec![], vec![], vec![])),
this.ty,
this.use_swc_css,
))
}
}
Expand Down Expand Up @@ -118,7 +110,7 @@ impl Module for CssModuleAsset {
let mut ident = self
.source
.ident()
.with_modifier(modifier(self.use_swc_css))
.with_modifier(modifier())
.with_layer(self.asset_context.layer());
if let Some(import_context) = self.import_context {
ident = ident.with_modifier(import_context.modifier())
Expand Down
Loading
Loading