From a0348cde2bd259e765119e55fb9b4f24385c7ca1 Mon Sep 17 00:00:00 2001 From: ahabhgk Date: Tue, 13 Aug 2024 12:50:33 +0800 Subject: [PATCH 1/5] refactor: remove html minify --- Cargo.lock | 280 ------------------ Cargo.toml | 4 +- crates/node_binding/binding.d.ts | 7 - crates/rspack_ast/Cargo.toml | 6 - crates/rspack_ast/src/ast/css.rs | 53 ---- crates/rspack_ast/src/ast/mod.rs | 1 - crates/rspack_ast/src/lib.rs | 11 - crates/rspack_ast_viewer/Cargo.toml | 25 -- crates/rspack_ast_viewer/LICENSE | 22 -- crates/rspack_ast_viewer/README.md | 63 ---- crates/rspack_ast_viewer/src/main.rs | 111 ------- crates/rspack_binding_options/Cargo.toml | 1 - .../src/options/raw_builtins/mod.rs | 11 - .../raw_builtins/raw_swc_css_minimizer.rs | 62 ---- crates/rspack_core/Cargo.toml | 6 - crates/rspack_plugin_html/src/parser.rs | 6 +- .../Cargo.toml | 23 -- .../src/lib.rs | 154 ---------- .../src/swc_css_compiler.rs | 118 -------- .../builtin-plugin/SwcCssMinimizerPlugin.ts | 26 -- packages/rspack/src/builtin-plugin/index.ts | 1 - packages/rspack/src/exports.ts | 1 - 22 files changed, 5 insertions(+), 987 deletions(-) delete mode 100644 crates/rspack_ast/src/ast/css.rs delete mode 100644 crates/rspack_ast_viewer/Cargo.toml delete mode 100644 crates/rspack_ast_viewer/LICENSE delete mode 100644 crates/rspack_ast_viewer/README.md delete mode 100644 crates/rspack_ast_viewer/src/main.rs delete mode 100644 crates/rspack_binding_options/src/options/raw_builtins/raw_swc_css_minimizer.rs delete mode 100644 crates/rspack_plugin_swc_css_minimizer/Cargo.toml delete mode 100644 crates/rspack_plugin_swc_css_minimizer/src/lib.rs delete mode 100644 crates/rspack_plugin_swc_css_minimizer/src/swc_css_compiler.rs delete mode 100644 packages/rspack/src/builtin-plugin/SwcCssMinimizerPlugin.ts diff --git a/Cargo.lock b/Cargo.lock index ea3a72cbbf1..ce4e49ad1a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,37 +103,6 @@ version = "1.0.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1f8f5a6f3d50d89e3797d7593a50f96bb2aaa20ca0cc7be1fb673232c91d72" -[[package]] -name = "argh" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7af5ba06967ff7214ce4c7419c7d185be7ecd6cc4965a8f6e1d8ce0398aad219" -dependencies = [ - "argh_derive", - "argh_shared", -] - -[[package]] -name = "argh_derive" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56df0aeedf6b7a2fc67d06db35b09684c3e8da0c95f8f27685cb17e08413d87a" -dependencies = [ - "argh_shared", - "proc-macro2", - "quote", - "syn 2.0.63", -] - -[[package]] -name = "argh_shared" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5693f39141bda5760ecc4111ab08da40565d1771038c4a0250f03457ec707531" -dependencies = [ - "serde", -] - [[package]] name = "arrayref" version = "0.3.7" @@ -1732,49 +1701,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" -[[package]] -name = "lexical" -version = "6.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7aefb36fd43fef7003334742cbf77b243fcd36418a1d1bdd480d613a67968f6" -dependencies = [ - "lexical-core", -] - -[[package]] -name = "lexical-core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" -dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", -] - -[[package]] -name = "lexical-parse-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" -dependencies = [ - "lexical-parse-integer", - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-parse-integer" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" -dependencies = [ - "lexical-util", - "static_assertions", -] - [[package]] name = "lexical-sort" version = "0.3.1" @@ -1784,36 +1710,6 @@ dependencies = [ "any_ascii", ] -[[package]] -name = "lexical-util" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" -dependencies = [ - "static_assertions", -] - -[[package]] -name = "lexical-write-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" -dependencies = [ - "lexical-util", - "lexical-write-integer", - "static_assertions", -] - -[[package]] -name = "lexical-write-integer" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" -dependencies = [ - "lexical-util", - "static_assertions", -] - [[package]] name = "libc" version = "0.2.155" @@ -3005,17 +2901,6 @@ dependencies = [ "swc_node_comments", ] -[[package]] -name = "rspack_ast_viewer" -version = "0.1.0" -dependencies = [ - "anyhow", - "argh", - "regex", - "swc_core", - "swc_error_reporters", -] - [[package]] name = "rspack_base64" version = "0.1.0" @@ -3076,7 +2961,6 @@ dependencies = [ "rspack_plugin_schemes", "rspack_plugin_size_limits", "rspack_plugin_split_chunks", - "rspack_plugin_swc_css_minimizer", "rspack_plugin_swc_js_minimizer", "rspack_plugin_warn_sensitive_module", "rspack_plugin_wasm", @@ -3625,7 +3509,6 @@ dependencies = [ "sugar_path", "swc_core", "swc_html", - "swc_html_minifier", "tracing", "urlencoding", ] @@ -3904,21 +3787,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "rspack_plugin_swc_css_minimizer" -version = "0.1.0" -dependencies = [ - "rayon", - "regex", - "rspack_core", - "rspack_error", - "rspack_hook", - "rspack_regex", - "rspack_util", - "swc_core", - "tracing", -] - [[package]] name = "rspack_plugin_swc_js_minimizer" version = "0.1.0" @@ -4788,13 +4656,6 @@ dependencies = [ "swc_allocator", "swc_atoms", "swc_common", - "swc_css_ast", - "swc_css_codegen", - "swc_css_minifier", - "swc_css_modules", - "swc_css_parser", - "swc_css_utils", - "swc_css_visit", "swc_ecma_ast", "swc_ecma_codegen", "swc_ecma_parser", @@ -4813,118 +4674,6 @@ dependencies = [ "vergen", ] -[[package]] -name = "swc_css_ast" -version = "0.143.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd74b0674c9ab8eebfaada987afc2c1da9bb83519851d253e6c55fe81a7b5d50" -dependencies = [ - "is-macro", - "string_enum", - "swc_atoms", - "swc_common", -] - -[[package]] -name = "swc_css_codegen" -version = "0.154.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8e731ef1e9f1399548fcaaf2bc5c154d16adc29546a2e7120d692ae4260487" -dependencies = [ - "auto_impl", - "bitflags 2.5.0", - "rustc-hash 1.1.0", - "serde", - "swc_atoms", - "swc_common", - "swc_css_ast", - "swc_css_codegen_macros", - "swc_css_utils", -] - -[[package]] -name = "swc_css_codegen_macros" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de2ece8c7dbdde85aa1bcc9764c5f41f7450d8bf1312eac2375b8dc0ecbc13d7" -dependencies = [ - "proc-macro2", - "quote", - "swc_macros_common", - "syn 2.0.63", -] - -[[package]] -name = "swc_css_minifier" -version = "0.119.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ca5bb8750e08558b4afd838f72728fb0645d35ede8626a14c25b95ae7b4604e" -dependencies = [ - "serde", - "swc_atoms", - "swc_common", - "swc_css_ast", - "swc_css_utils", - "swc_css_visit", -] - -[[package]] -name = "swc_css_modules" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d9a9eeb446f4985454c0742e44b4ab8fef4d935d96b11bbb277102a7167207" -dependencies = [ - "rustc-hash 1.1.0", - "serde", - "swc_atoms", - "swc_common", - "swc_css_ast", - "swc_css_codegen", - "swc_css_parser", - "swc_css_visit", -] - -[[package]] -name = "swc_css_parser" -version = "0.153.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98be1caea76ea9b38ddf9d9940f133aa491e9bc0c254745cfa7e685dbc2b28b" -dependencies = [ - "lexical", - "serde", - "swc_atoms", - "swc_common", - "swc_css_ast", -] - -[[package]] -name = "swc_css_utils" -version = "0.140.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47ab39714e7f531b892385aeb562e326f525efe738c3294d0d7f16c25fbca982" -dependencies = [ - "once_cell", - "serde", - "serde_json", - "swc_atoms", - "swc_common", - "swc_css_ast", - "swc_css_visit", -] - -[[package]] -name = "swc_css_visit" -version = "0.142.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80600a79fb14fe45ab7b92bb4baf2f34767942c732de19c3d691c2f51bd7a155" -dependencies = [ - "serde", - "swc_atoms", - "swc_common", - "swc_css_ast", - "swc_visit", -] - [[package]] name = "swc_ecma_ast" version = "0.117.4" @@ -5686,35 +5435,6 @@ dependencies = [ "syn 2.0.63", ] -[[package]] -name = "swc_html_minifier" -version = "0.142.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e700e9ea6f29c41849136496652f9cc4ec83e3ad97a64023114eef82e056823c" -dependencies = [ - "once_cell", - "serde", - "serde_json", - "swc_atoms", - "swc_cached", - "swc_common", - "swc_css_ast", - "swc_css_codegen", - "swc_css_minifier", - "swc_css_parser", - "swc_ecma_ast", - "swc_ecma_codegen", - "swc_ecma_minifier", - "swc_ecma_parser", - "swc_ecma_transforms_base", - "swc_ecma_visit", - "swc_html_ast", - "swc_html_codegen", - "swc_html_parser", - "swc_html_utils", - "swc_html_visit", -] - [[package]] name = "swc_html_parser" version = "0.42.2" diff --git a/Cargo.toml b/Cargo.toml index e783c9652ed..0c1b2acb300 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,8 +75,8 @@ swc_core = { version = "0.99.5", default-features = false } swc_ecma_minifier = { version = "=0.200.3", default-features = false } swc_error_reporters = { version = "=0.20.0" } swc_html = { version = "=0.145.0" } -swc_html_minifier = { version = "=0.142.2" } -swc_node_comments = { version = "=0.23.0" } +# swc_html_minifier = { version = "=0.142.2" } +swc_node_comments = { version = "=0.23.0" } [workspace.metadata.release] diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index e7557595454..bb6b4bc89ef 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -267,7 +267,6 @@ export enum BuiltinPluginName { CopyRspackPlugin = 'CopyRspackPlugin', HtmlRspackPlugin = 'HtmlRspackPlugin', SwcJsMinimizerRspackPlugin = 'SwcJsMinimizerRspackPlugin', - SwcCssMinimizerRspackPlugin = 'SwcCssMinimizerRspackPlugin', LightningCssMinimizerRspackPlugin = 'LightningCssMinimizerRspackPlugin', BundlerInfoRspackPlugin = 'BundlerInfoRspackPlugin', CssExtractRspackPlugin = 'CssExtractRspackPlugin', @@ -1715,12 +1714,6 @@ export interface RawStatsOptions { colors: boolean } -export interface RawSwcCssMinimizerRspackPluginOptions { - test?: string | RegExp | (string | RegExp)[] - include?: string | RegExp | (string | RegExp)[] - exclude?: string | RegExp | (string | RegExp)[] -} - export interface RawSwcJsMinimizerOptions { compress: any mangle: any diff --git a/crates/rspack_ast/Cargo.toml b/crates/rspack_ast/Cargo.toml index 0ad41dd79fb..64d45aa79ce 100644 --- a/crates/rspack_ast/Cargo.toml +++ b/crates/rspack_ast/Cargo.toml @@ -21,12 +21,6 @@ swc_core = { workspace = true, features = [ "ecma_transforms_module", "swc_ecma_codegen", "swc_ecma_visit", - "css_ast", - "css_codegen", - "css_parser", - "css_utils", - "css_visit", - "css_modules", ] } swc_error_reporters = { workspace = true } swc_node_comments = { workspace = true } diff --git a/crates/rspack_ast/src/ast/css.rs b/crates/rspack_ast/src/ast/css.rs deleted file mode 100644 index 2d61118452d..00000000000 --- a/crates/rspack_ast/src/ast/css.rs +++ /dev/null @@ -1,53 +0,0 @@ -use std::{fmt, hash::Hash, sync::Arc}; - -use swc_core::common::SourceMap; -use swc_core::css::ast::Stylesheet as SwcStylesheet; - -pub struct Context { - pub source_map: Arc, -} - -impl Context { - pub fn new(source_map: Arc) -> Self { - Self { source_map } - } -} - -impl fmt::Debug for Context { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("Context").finish() - } -} - -#[derive(Debug, Clone)] -pub struct Ast { - root: SwcStylesheet, - context: Arc, -} - -impl Hash for Ast { - fn hash(&self, state: &mut H) { - self.root.hash(state); - } -} - -impl Ast { - pub fn new(root: SwcStylesheet, source_map: Arc) -> Self { - Self { - root, - context: Arc::new(Context::new(source_map)), - } - } - - pub fn get_context(&self) -> &Context { - &self.context - } - - pub fn get_root(&self) -> &SwcStylesheet { - &self.root - } - - pub fn get_root_mut(&mut self) -> &mut SwcStylesheet { - &mut self.root - } -} diff --git a/crates/rspack_ast/src/ast/mod.rs b/crates/rspack_ast/src/ast/mod.rs index 65fa523e1ae..21445d24558 100644 --- a/crates/rspack_ast/src/ast/mod.rs +++ b/crates/rspack_ast/src/ast/mod.rs @@ -1,2 +1 @@ -pub mod css; pub mod javascript; diff --git a/crates/rspack_ast/src/lib.rs b/crates/rspack_ast/src/lib.rs index c29cbd9b517..4e66f5739a6 100644 --- a/crates/rspack_ast/src/lib.rs +++ b/crates/rspack_ast/src/lib.rs @@ -1,7 +1,5 @@ mod ast; -pub use crate::ast::css; -use crate::ast::css::Ast as CssAst; pub use crate::ast::javascript; use crate::ast::javascript::Ast as JsAst; @@ -11,21 +9,12 @@ use crate::ast::javascript::Ast as JsAst; #[derive(Debug, Clone, Hash)] pub enum RspackAst { JavaScript(JsAst), - Css(CssAst), } impl RspackAst { pub fn as_javascript(&self) -> Option<&JsAst> { match self { RspackAst::JavaScript(program) => Some(program), - RspackAst::Css(_) => None, - } - } - - pub fn as_css(&self) -> Option<&CssAst> { - match self { - RspackAst::Css(stylesheet) => Some(stylesheet), - RspackAst::JavaScript(_) => None, } } } diff --git a/crates/rspack_ast_viewer/Cargo.toml b/crates/rspack_ast_viewer/Cargo.toml deleted file mode 100644 index c9dabb30d59..00000000000 --- a/crates/rspack_ast_viewer/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -description = "rspack ast viewer" -edition = "2021" -license = "MIT" -name = "rspack_ast_viewer" -publish = false -version = "0.1.0" -[[bin]] -name = "rspack-ast-viewer" -path = "src/main.rs" - -[dependencies] -anyhow = { workspace = true } -argh = "0.1.12" -regex = { workspace = true } -swc_core = { workspace = true, features = [ - "ecma_ast", - "ecma_parser", - "css_ast", - "css_parser", - "common", - "ecma_transforms", - "ecma_visit", -] } -swc_error_reporters = { workspace = true } diff --git a/crates/rspack_ast_viewer/LICENSE b/crates/rspack_ast_viewer/LICENSE deleted file mode 100644 index c6f19c719dd..00000000000 --- a/crates/rspack_ast_viewer/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2022-present Bytedance, Inc. and its affiliates. - - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/crates/rspack_ast_viewer/README.md b/crates/rspack_ast_viewer/README.md deleted file mode 100644 index b6d51b78ca8..00000000000 --- a/crates/rspack_ast_viewer/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# rspack-ast-viewer - -Print AST generated by SWC. - -## Options - -- -k, --keep-span: keep span information from the AST (default: false) - -## Example - -Input: - -```bash -echo "var a = 123" | cargo run -p rspack_ast_viewer -``` - -Output: - -``` -Module( - Module { - body: [ - Stmt( - Decl( - Var( - VarDecl { - kind: "var", - declare: false, - decls: [ - VarDeclarator { - name: Ident( - BindingIdent { - id: Ident { - sym: Atom('abc' type=inline), - optional: false, - }, - type_ann: None, - }, - ), - init: Some( - Lit( - Num( - Number { - value: 123.0, - raw: Some( - "123", - ), - }, - ), - ), - ), - definite: false, - }, - ], - }, - ), - ), - ), - ], - shebang: None, - }, -) -``` diff --git a/crates/rspack_ast_viewer/src/main.rs b/crates/rspack_ast_viewer/src/main.rs deleted file mode 100644 index d64a4adedcb..00000000000 --- a/crates/rspack_ast_viewer/src/main.rs +++ /dev/null @@ -1,111 +0,0 @@ -use std::{io::Read, sync::Arc}; - -use anyhow::{Context, Result}; -use argh::FromArgs; -use swc_core::{ - self, - common::{errors::HANDLER, FileName, Globals, Mark, GLOBALS}, - ecma::{ - ast::*, - parser::{parse_file_as_module, Syntax, TsSyntax}, - transforms::base::resolver, - visit::VisitMutWith, - }, -}; -use swc_error_reporters::handler::try_with_handler; - -#[derive(FromArgs)] -/// rspack ast viewer -struct Args { - /// module type: "js" | "css" (default: "js") - #[argh(option, short = 't')] - ty: Option, - - /// whether to keep span (default: false) - #[argh(switch, short = 'k')] - keep_span: bool, -} - -enum ModuleType { - JavaScript, -} - -fn from_str_fn(ty: &str) -> ModuleType { - match ty.to_ascii_lowercase().as_str() { - "js" => ModuleType::JavaScript, - "css" => todo!("CSS module type is not supported yet"), - _ => panic!("Unknown module type: {ty}"), - } -} - -fn handle_javascript(input: String, keep_span: bool) -> Result<()> { - let cm: Arc = Default::default(); - let fm = cm.new_source_file(Arc::new(FileName::Anon), input); - let mut errors = Default::default(); - - let ast = try_with_handler(cm, Default::default(), |handler| { - GLOBALS - .set(&Globals::default(), || { - let unresolved_mark = Mark::new(); - let top_level_mark = Mark::new(); - - HANDLER.set(handler, || { - parse_file_as_module( - &fm, - Syntax::Typescript(TsSyntax { - tsx: true, - decorators: true, - ..Default::default() - }), - EsVersion::EsNext, - None, - &mut errors, - ) - .map(Program::Module) - .map(|mut program| { - program.visit_mut_with(&mut resolver(unresolved_mark, top_level_mark, false)); - program - }) - }) - }) - .map_err(|err| anyhow::anyhow!("{err:?}")) - })?; - - if !errors.is_empty() { - anyhow::bail!("{errors:?}") - } - - let output = { - let output = format!("{ast:#?}"); - - if keep_span { - output - } else { - let reg = regex::Regex::new(r#"\s*span: Span \{[^}]*?\},"#)?; - reg.replace_all(&output, "").into_owned() - } - }; - - println!("{output}"); - - Ok(()) -} - -fn main() -> Result<()> { - let args: Args = argh::from_env(); - let module_type = args - .ty - .as_ref() - .map(|ty| from_str_fn(ty)) - .unwrap_or(ModuleType::JavaScript); - let keep_span = args.keep_span; - - let mut input = String::new(); - std::io::stdin() - .read_to_string(&mut input) - .context("Failed to read from stdin")?; - - match module_type { - ModuleType::JavaScript => handle_javascript(input, keep_span), - } -} diff --git a/crates/rspack_binding_options/Cargo.toml b/crates/rspack_binding_options/Cargo.toml index 1085e4b2746..7a20df2137a 100644 --- a/crates/rspack_binding_options/Cargo.toml +++ b/crates/rspack_binding_options/Cargo.toml @@ -61,7 +61,6 @@ rspack_plugin_runtime_chunk = { version = "0.1.0", path = "../rspack_p rspack_plugin_schemes = { version = "0.1.0", path = "../rspack_plugin_schemes" } rspack_plugin_size_limits = { version = "0.1.0", path = "../rspack_plugin_size_limits" } rspack_plugin_split_chunks = { version = "0.1.0", path = "../rspack_plugin_split_chunks" } -rspack_plugin_swc_css_minimizer = { version = "0.1.0", path = "../rspack_plugin_swc_css_minimizer" } rspack_plugin_swc_js_minimizer = { version = "0.1.0", path = "../rspack_plugin_swc_js_minimizer" } rspack_plugin_warn_sensitive_module = { version = "0.1.0", path = "../rspack_plugin_warn_sensitive_module" } rspack_plugin_wasm = { version = "0.1.0", path = "../rspack_plugin_wasm" } diff --git a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs index 2b403cad898..c95fbe156f7 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs +++ b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs @@ -11,13 +11,11 @@ mod raw_mf; mod raw_progress; mod raw_runtime_chunk; mod raw_size_limits; -mod raw_swc_css_minimizer; mod raw_swc_js_minimizer; use napi::{bindgen_prelude::FromNapiValue, Env, JsUnknown}; use napi_derive::napi; use raw_lightning_css_minimizer::RawLightningCssMinimizerRspackPluginOptions; -use raw_swc_css_minimizer::RawSwcCssMinimizerRspackPluginOptions; use rspack_binding_values::entry::JsEntryPluginOptions; use rspack_core::{BoxPlugin, Plugin, PluginExt}; use rspack_error::Result; @@ -68,7 +66,6 @@ use rspack_plugin_runtime::{ use rspack_plugin_runtime_chunk::RuntimeChunkPlugin; use rspack_plugin_schemes::{DataUriPlugin, FileUriPlugin}; use rspack_plugin_size_limits::SizeLimitsPlugin; -use rspack_plugin_swc_css_minimizer::SwcCssMinimizerRspackPlugin; use rspack_plugin_swc_js_minimizer::SwcJsMinimizerRspackPlugin; use rspack_plugin_warn_sensitive_module::WarnCaseSensitiveModulesPlugin; use rspack_plugin_wasm::{ @@ -170,7 +167,6 @@ pub enum BuiltinPluginName { CopyRspackPlugin, HtmlRspackPlugin, SwcJsMinimizerRspackPlugin, - SwcCssMinimizerRspackPlugin, LightningCssMinimizerRspackPlugin, BundlerInfoRspackPlugin, CssExtractRspackPlugin, @@ -449,13 +445,6 @@ impl BuiltinPlugin { .boxed(); plugins.push(plugin); } - BuiltinPluginName::SwcCssMinimizerRspackPlugin => { - let plugin = SwcCssMinimizerRspackPlugin::new( - downcast_into::(self.options)?.try_into()?, - ) - .boxed(); - plugins.push(plugin); - } BuiltinPluginName::LightningCssMinimizerRspackPlugin => plugins.push( LightningCssMinimizerRspackPlugin::new( downcast_into::(self.options)?.try_into()?, diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_swc_css_minimizer.rs b/crates/rspack_binding_options/src/options/raw_builtins/raw_swc_css_minimizer.rs deleted file mode 100644 index e9a084c999c..00000000000 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_swc_css_minimizer.rs +++ /dev/null @@ -1,62 +0,0 @@ -use napi::{bindgen_prelude::Either3, Either}; -use napi_derive::napi; -use rspack_error::Result; -use rspack_napi::regexp::{JsRegExp, JsRegExpExt}; -use rspack_plugin_swc_css_minimizer::{ - SwcCssMinimizerRspackPluginOptions, SwcCssMinimizerRule, SwcCssMinimizerRules, -}; - -type RawSwcCssMinimizerRule = Either; -type RawSwcCssMinimizerRules = Either3>; -struct RawSwcCssMinimizerRuleWrapper(RawSwcCssMinimizerRule); -struct RawSwcCssMinimizerRulesWrapper(RawSwcCssMinimizerRules); - -#[derive(Debug)] -#[napi(object, object_to_js = false)] -pub struct RawSwcCssMinimizerRspackPluginOptions { - #[napi(ts_type = "string | RegExp | (string | RegExp)[]")] - pub test: Option, - #[napi(ts_type = "string | RegExp | (string | RegExp)[]")] - pub include: Option, - #[napi(ts_type = "string | RegExp | (string | RegExp)[]")] - pub exclude: Option, -} - -fn into_condition(c: Option) -> Option { - c.map(|test| RawSwcCssMinimizerRulesWrapper(test).into()) -} - -impl TryFrom for SwcCssMinimizerRspackPluginOptions { - type Error = rspack_error::Error; - - fn try_from(value: RawSwcCssMinimizerRspackPluginOptions) -> Result { - Ok(Self { - test: into_condition(value.test), - include: into_condition(value.include), - exclude: into_condition(value.exclude), - }) - } -} - -impl From for SwcCssMinimizerRule { - fn from(x: RawSwcCssMinimizerRuleWrapper) -> Self { - match x.0 { - Either::A(v) => Self::String(v), - Either::B(v) => Self::Regexp(v.to_rspack_regex()), - } - } -} - -impl From for SwcCssMinimizerRules { - fn from(value: RawSwcCssMinimizerRulesWrapper) -> Self { - match value.0 { - Either3::A(v) => Self::String(v), - Either3::B(v) => Self::Regexp(v.to_rspack_regex()), - Either3::C(v) => Self::Array( - v.into_iter() - .map(|v| RawSwcCssMinimizerRuleWrapper(v).into()) - .collect(), - ), - } - } -} diff --git a/crates/rspack_core/Cargo.toml b/crates/rspack_core/Cargo.toml index 23af0ddf78e..34ebfbf3c4e 100644 --- a/crates/rspack_core/Cargo.toml +++ b/crates/rspack_core/Cargo.toml @@ -59,12 +59,6 @@ swc_core = { workspace = true, features = [ "ecma_transforms_module", "swc_ecma_codegen", "swc_ecma_visit", - "css_ast", - "css_codegen", - "css_parser", - "css_utils", - "css_visit", - "css_modules", ] } swc_node_comments = { workspace = true } tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros", "test-util", "parking_lot"] } diff --git a/crates/rspack_plugin_html/src/parser.rs b/crates/rspack_plugin_html/src/parser.rs index 8bfc553da55..d130d40b3b2 100644 --- a/crates/rspack_plugin_html/src/parser.rs +++ b/crates/rspack_plugin_html/src/parser.rs @@ -11,9 +11,9 @@ use swc_html::{ }, parser::{error::Error, parse_file_as_document, parser::ParserConfig}, }; -use swc_html_minifier::minify_document; -pub use swc_html_minifier::option::MinifyOptions; +// use swc_html_minifier::minify_document; +// pub use swc_html_minifier::option::MinifyOptions; use crate::config::HtmlRspackPluginOptions; pub struct HtmlCompiler<'a> { @@ -55,7 +55,7 @@ impl<'a> HtmlCompiler<'a> { if minify { // Minify can't leak to user land because it doesn't implement `ToNapiValue` Trait GLOBALS.set(&Default::default(), || { - minify_document(ast, &MinifyOptions::default()); + // minify_document(ast, &MinifyOptions::default()); }) } diff --git a/crates/rspack_plugin_swc_css_minimizer/Cargo.toml b/crates/rspack_plugin_swc_css_minimizer/Cargo.toml deleted file mode 100644 index 6299cfd9ca7..00000000000 --- a/crates/rspack_plugin_swc_css_minimizer/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -description = "rspack css minifier plugin" -edition = "2021" -license = "MIT" -name = "rspack_plugin_swc_css_minimizer" -repository = "https://github.com/web-infra-dev/rspack" -version = "0.1.0" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -rayon = { workspace = true } -regex = { workspace = true } -rspack_core = { version = "0.1.0", path = "../rspack_core" } -rspack_error = { version = "0.1.0", path = "../rspack_error" } -rspack_hook = { version = "0.1.0", path = "../rspack_hook" } -rspack_regex = { version = "0.1.0", path = "../rspack_regex" } -rspack_util = { version = "0.1.0", path = "../rspack_util" } -swc_core = { workspace = true, features = ["css_codegen", "css_parser", "css_minifier"] } -tracing = { workspace = true } - -[package.metadata.cargo-shear] -ignored = ["tracing"] diff --git a/crates/rspack_plugin_swc_css_minimizer/src/lib.rs b/crates/rspack_plugin_swc_css_minimizer/src/lib.rs deleted file mode 100644 index 7d6a1659a0a..00000000000 --- a/crates/rspack_plugin_swc_css_minimizer/src/lib.rs +++ /dev/null @@ -1,154 +0,0 @@ -mod swc_css_compiler; - -use std::sync::LazyLock; - -use rayon::prelude::*; -use regex::Regex; -use rspack_core::{rspack_sources::MapOptions, Compilation, CompilationProcessAssets, Plugin}; -use rspack_error::Result; -use rspack_hook::{plugin, plugin_hook}; -use rspack_regex::RspackRegex; -use rspack_util::try_any_sync; -use swc_css_compiler::{SwcCssCompiler, SwcCssSourceMapGenConfig}; - -static CSS_ASSET_REGEXP: LazyLock = - LazyLock::new(|| Regex::new(r"\.css(\?.*)?$").expect("Invalid RegExp")); - -#[derive(Debug, Default)] -pub struct SwcCssMinimizerRspackPluginOptions { - pub test: Option, - pub include: Option, - pub exclude: Option, -} - -#[plugin] -#[derive(Debug, Default)] -pub struct SwcCssMinimizerRspackPlugin { - options: SwcCssMinimizerRspackPluginOptions, -} - -impl SwcCssMinimizerRspackPlugin { - pub fn new(options: SwcCssMinimizerRspackPluginOptions) -> Self { - Self::new_inner(options) - } -} - -#[plugin_hook(CompilationProcessAssets for SwcCssMinimizerRspackPlugin, stage = Compilation::PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE)] -async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> { - let minify_options = &self.options; - - compilation - .assets_mut() - .par_iter_mut() - .filter(|(filename, original)| { - if !CSS_ASSET_REGEXP.is_match(filename) { - return false; - } - - let is_matched = match_object(minify_options, filename).unwrap_or(false); - - if !is_matched || original.get_info().minimized { - return false; - } - - true - }) - .try_for_each(|(filename, original)| -> Result<()> { - if original.get_info().minimized { - return Ok(()); - } - - if let Some(original_source) = original.get_source() { - let input = original_source.source().to_string(); - let input_source_map = original_source.map(&MapOptions::default()); - let enable_source_map = input_source_map.is_some(); - let minimized_source = SwcCssCompiler::default().minify( - filename, - input, - input_source_map, - SwcCssSourceMapGenConfig { - enable: enable_source_map, - inline_sources_content: false, - emit_columns: true, - }, - )?; - original.set_source(Some(minimized_source)); - } - original.get_info_mut().minimized = true; - Ok(()) - })?; - - Ok(()) -} - -impl Plugin for SwcCssMinimizerRspackPlugin { - fn name(&self) -> &'static str { - "rspack.SwcCssMinimizerRspackPlugin" - } - - fn apply( - &self, - ctx: rspack_core::PluginContext<&mut rspack_core::ApplyContext>, - _options: &mut rspack_core::CompilerOptions, - ) -> Result<()> { - ctx - .context - .compilation_hooks - .process_assets - .tap(process_assets::new(self)); - Ok(()) - } - - // TODO: chunk hash -} - -#[derive(Debug, Clone, Hash)] -pub enum SwcCssMinimizerRule { - String(String), - Regexp(RspackRegex), -} - -impl SwcCssMinimizerRule { - pub fn try_match(&self, data: &str) -> rspack_error::Result { - match self { - Self::String(s) => Ok(data.starts_with(s)), - Self::Regexp(r) => Ok(r.test(data)), - } - } -} - -#[derive(Debug, Clone, Hash)] -pub enum SwcCssMinimizerRules { - String(String), - Regexp(rspack_regex::RspackRegex), - Array(Vec), -} - -impl SwcCssMinimizerRules { - pub fn try_match(&self, data: &str) -> rspack_error::Result { - match self { - Self::String(s) => Ok(data.starts_with(s)), - Self::Regexp(r) => Ok(r.test(data)), - Self::Array(l) => try_any_sync(l, |i| i.try_match(data)), - } - } -} - -pub fn match_object(obj: &SwcCssMinimizerRspackPluginOptions, str: &str) -> Result { - if let Some(condition) = &obj.test { - if !condition.try_match(str)? { - return Ok(false); - } - } - if let Some(condition) = &obj.include { - if !condition.try_match(str)? { - return Ok(false); - } - } - if let Some(condition) = &obj.exclude { - if condition.try_match(str)? { - return Ok(false); - } - } - Ok(true) -} diff --git a/crates/rspack_plugin_swc_css_minimizer/src/swc_css_compiler.rs b/crates/rspack_plugin_swc_css_minimizer/src/swc_css_compiler.rs deleted file mode 100644 index ee32f50472a..00000000000 --- a/crates/rspack_plugin_swc_css_minimizer/src/swc_css_compiler.rs +++ /dev/null @@ -1,118 +0,0 @@ -use std::sync::Arc; - -use rspack_core::rspack_sources::{self, SourceExt}; -use rspack_error::{error, Result}; -use swc_core::common::{input::SourceFileInput, source_map::SourceMapGenConfig, FileName}; -use swc_core::common::{Globals, GLOBALS}; -use swc_core::css::codegen::{ - writer::basic::{BasicCssWriter, BasicCssWriterConfig}, - CodeGenerator, CodegenConfig, Emit, -}; -use swc_core::css::minifier; -use swc_core::css::parser::{lexer::Lexer, parser::ParserConfig}; -use swc_core::css::{ast::Stylesheet, parser::parser::Parser}; - -#[derive(Default)] -pub struct SwcCssCompiler { - cm: Arc, -} - -impl SwcCssCompiler { - pub fn parse_file(&self, path: &str, source: String, config: ParserConfig) -> Result { - let fm = self - .cm - .new_source_file(Arc::new(FileName::Custom(path.to_string())), source); - - let lexer = Lexer::new(SourceFileInput::from(&*fm), None, config); - let mut parser = Parser::new(lexer, config); - let stylesheet = parser.parse_all(); - stylesheet.map_err(|e| error!("Css parsing failed {}", e.message())) - } - - fn codegen_impl( - &self, - ast: &Stylesheet, - gen_source_map: SwcCssSourceMapGenConfig, - minify: bool, - ) -> Result<(String, Option>)> { - let mut output = String::new(); - let mut src_map_buf: Option> = gen_source_map.enable.then(Vec::new); - let wr = BasicCssWriter::new( - &mut output, - src_map_buf.as_mut(), - BasicCssWriterConfig::default(), - ); - - let mut gen = CodeGenerator::new(wr, CodegenConfig { minify }); - gen.emit(ast).map_err(|e| error!(e.to_string()))?; - - if let Some(src_map_buf) = &mut src_map_buf { - let map = self - .cm - .build_source_map_with_config(src_map_buf, None, gen_source_map); - let mut raw_map = Vec::new(); - map - .to_writer(&mut raw_map) - .map_err(|e| error!(e.to_string()))?; - Ok((output, Some(raw_map))) - } else { - Ok((output, None)) - } - } - - pub fn minify( - &self, - filename: &str, - input_source: String, - input_source_map: Option, - gen_source_map: SwcCssSourceMapGenConfig, - ) -> Result { - let mut ast = self.parse_file(filename, input_source.clone(), Default::default())?; - // ignore errors since css in webpack is tolerant, and diagnostics already reported in parse. - GLOBALS.set(&Globals::default(), || { - minifier::minify(&mut ast, minifier::options::MinifyOptions::default()); - }); - let (code, source_map) = self.codegen_impl(&ast, gen_source_map, true)?; - if let Some(source_map) = source_map { - let source = rspack_sources::SourceMapSource::new(rspack_sources::SourceMapSourceOptions { - value: code, - name: filename, - source_map: rspack_sources::SourceMap::from_slice(&source_map) - .expect("should be able to generate source-map"), - original_source: Some(input_source), - inner_source_map: input_source_map, - remove_original_source: true, - }) - .boxed(); - Ok(source) - } else { - Ok(rspack_sources::RawSource::from(code).boxed()) - } - } -} - -#[derive(Debug, Clone)] -pub struct SwcCssSourceMapGenConfig { - pub enable: bool, - pub emit_columns: bool, - pub inline_sources_content: bool, -} - -impl SourceMapGenConfig for SwcCssSourceMapGenConfig { - fn file_name_to_source(&self, f: &FileName) -> String { - let f = f.to_string(); - if f.starts_with('<') && f.ends_with('>') { - f[1..f.len() - 1].to_string() - } else { - f - } - } - - fn inline_sources_content(&self, _: &FileName) -> bool { - self.inline_sources_content - } - - fn emit_columns(&self, _f: &FileName) -> bool { - self.emit_columns - } -} diff --git a/packages/rspack/src/builtin-plugin/SwcCssMinimizerPlugin.ts b/packages/rspack/src/builtin-plugin/SwcCssMinimizerPlugin.ts deleted file mode 100644 index 998a8185ec7..00000000000 --- a/packages/rspack/src/builtin-plugin/SwcCssMinimizerPlugin.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - BuiltinPluginName, - type RawSwcCssMinimizerRspackPluginOptions -} from "@rspack/binding"; - -import type { AssetConditions } from "../util/assetCondition"; -import { create } from "./base"; - -export type SwcCssMinimizerRspackPluginOptions = { - test?: AssetConditions; - exclude?: AssetConditions; - include?: AssetConditions; -}; - -export const SwcCssMinimizerRspackPlugin = create( - BuiltinPluginName.SwcCssMinimizerRspackPlugin, - ( - options?: SwcCssMinimizerRspackPluginOptions - ): RawSwcCssMinimizerRspackPluginOptions => { - return { - test: options?.test, - include: options?.include, - exclude: options?.exclude - }; - } -); diff --git a/packages/rspack/src/builtin-plugin/index.ts b/packages/rspack/src/builtin-plugin/index.ts index fff08a2370a..b1a2ef73aba 100644 --- a/packages/rspack/src/builtin-plugin/index.ts +++ b/packages/rspack/src/builtin-plugin/index.ts @@ -57,7 +57,6 @@ export * from "./SideEffectsFlagPlugin"; export * from "./SizeLimitsPlugin"; export * from "./SourceMapDevToolPlugin"; export * from "./SplitChunksPlugin"; -export * from "./SwcCssMinimizerPlugin"; export * from "./LightningCssMiminizerRspackPlugin"; export * from "./SwcJsMinimizerPlugin"; export * from "./WarnCaseSensitiveModulesPlugin"; diff --git a/packages/rspack/src/exports.ts b/packages/rspack/src/exports.ts index e713e6dbf2a..507ad95d2e0 100644 --- a/packages/rspack/src/exports.ts +++ b/packages/rspack/src/exports.ts @@ -248,7 +248,6 @@ export type { } from "./builtin-plugin"; export { HtmlRspackPlugin } from "./builtin-plugin"; export { SwcJsMinimizerRspackPlugin } from "./builtin-plugin"; -export { SwcCssMinimizerRspackPlugin } from "./builtin-plugin"; export { LightningCssMinimizerRspackPlugin } from "./builtin-plugin"; export { CopyRspackPlugin } from "./builtin-plugin"; export { SourceMapDevToolPlugin } from "./builtin-plugin"; From dd814ff25387083c602f8d8609150456c28f31f4 Mon Sep 17 00:00:00 2001 From: ahabhgk Date: Thu, 15 Aug 2024 17:30:59 +0800 Subject: [PATCH 2/5] disable css minify in html minify --- Cargo.lock | 230 ++++++++++-------- Cargo.toml | 14 +- crates/rspack_plugin_html/Cargo.toml | 2 +- crates/rspack_plugin_html/src/parser.rs | 25 +- .../src/ast/stringify.rs | 2 +- 5 files changed, 159 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce4e49ad1a5..30e6e8e7ce6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3509,6 +3509,7 @@ dependencies = [ "sugar_path", "swc_core", "swc_html", + "swc_html_minifier", "tracing", "urlencoding", ] @@ -4306,9 +4307,9 @@ dependencies = [ [[package]] name = "sourcemap" -version = "8.0.1" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "208d40b9e8cad9f93613778ea295ed8f3c2b1824217c6cfc7219d3f6f45b96d4" +checksum = "dab08a862c70980b8e23698b507e272317ae52a608a164a844111f5372374f1f" dependencies = [ "base64-simd 0.7.0", "bitvec", @@ -4469,9 +4470,9 @@ dependencies = [ [[package]] name = "swc" -version = "0.282.3" +version = "0.283.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76ba75c4eaace11f3b1f22f31fbba74bd5983bf7581caef939c2c7aa1af7f4f" +checksum = "9cb7fe4bd6a604528819c84fc9acc5d5ec1b3bd0d11d13ee5d8a77d49ff678fa" dependencies = [ "anyhow", "base64 0.21.7", @@ -4563,9 +4564,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.36.2" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1802b1642488aec58597dc55ea88992c165660d6e44e9838d4d93f7b78ab95f3" +checksum = "46741b5a4ff3e821f6bb8d6c1289549272e71a5e0d163dbbae9e16e771d8da76" dependencies = [ "ahash 0.8.11", "anyhow", @@ -4595,9 +4596,9 @@ dependencies = [ [[package]] name = "swc_compiler_base" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd217a48b2061a6fbb602450f347abed706246464f5a5ac24054502f2ab8923" +checksum = "c9b47fac27c2e84e033bdea294ac12f575322c81c9d5d44f423e3f11ff239a86" dependencies = [ "anyhow", "base64 0.21.7", @@ -4621,9 +4622,9 @@ dependencies = [ [[package]] name = "swc_config" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b67e115ab136fe0eb03558bb0508ca7782eeb446a96d165508c48617e3fd94" +checksum = "4740e53eaf68b101203c1df0937d5161a29f3c13bceed0836ddfe245b72dd000" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -4648,9 +4649,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "0.99.5" +version = "0.100.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631adff7d2bd3e52a1cf0aef3ad6cae2601dd08043efecc21145bd2e1a16a73e" +checksum = "66ff548cf185b9bb1ddaff5e5c74c1b79fb06b5f5e6f34a80d0faab211cb9972" dependencies = [ "swc", "swc_allocator", @@ -4676,9 +4677,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.117.4" +version = "0.118.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5da2f0310e8cd84b8c803095e75b2cbca872c71fc7f7404d4c9c8117d894960" +checksum = "ed6c1b94abbaf080a4e4ae47101a83d4eedef90d733dd98e32b361356d3f5e4b" dependencies = [ "bitflags 2.5.0", "bytecheck", @@ -4696,9 +4697,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.154.3" +version = "0.155.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808d1e5a3c923fe0fa6cd9c28af4ecb7e713b97231fe0914d89c00f6a7dca2e5" +checksum = "644514f303dcad13f7d1c244b50af798e0549f6eb8c53d64dd2ba9824266c868" dependencies = [ "memchr", "num-bigint", @@ -4727,9 +4728,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_bugfixes" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0729253b3f14e53fe300a7bb701144e319f539d1bcb1839eabab17a93d9fd6b2" +checksum = "b9f9cac39f19d6509db921f4b75934aaa64fc84b599416e5c1fcaed1c313132f" dependencies = [ "swc_atoms", "swc_common", @@ -4744,9 +4745,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_common" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4cc5d93c0517aba5a5cefed6770970a270960f9f3881c3234257244f29f9d81" +checksum = "f9acdf402b36f8e83084b10e119d7ba9d07e5229ef39e1343f147db816c7b73e" dependencies = [ "swc_common", "swc_ecma_ast", @@ -4757,9 +4758,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2015" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d705c2e9fa6a7024d1771fa6f8203f28762fbe0995db919a2f5a6cabd9c6b544" +checksum = "bd07cbb52c1ac41115c9ddd5a4d046a7388008bd950b61a48df7f7f490f19827" dependencies = [ "arrayvec", "indexmap 2.2.6", @@ -4783,9 +4784,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2016" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00a32d58418a36a2b41462197c5c4334ed24b21c73be31f2bd09203c0bb962db" +checksum = "209e347cdc3fb56632a1d882f981f3448f5f529c16d8da9d770207fffda4a8f6" dependencies = [ "swc_atoms", "swc_common", @@ -4800,9 +4801,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2017" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f7e60ec1d6a742de6ca35ddff7bc8a01e99ed53d1f68c352d4ea9a494d9b4d" +checksum = "8a564f1b5e852a0ac656626ba689d49dd2751ba5b980903154aebc971729959d" dependencies = [ "serde", "swc_atoms", @@ -4818,9 +4819,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2018" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9623c0aa17f9ec0bded894089b73aa3056f5205a0bf715955fbf36e6f63ae0f9" +checksum = "f577f098e7c3738ade709caadb17c9f3bd911ea2ee6cfacca561d12addcc5761" dependencies = [ "serde", "swc_atoms", @@ -4837,9 +4838,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2019" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8be9ff518dbca4cb96d3eebcc7c2fb23b73c5d0b5cfb81237ebab92f423a359" +checksum = "f9d52253dc2f83a3fca526c387c33e4ff9a8423b68c271414c9f870e1ced3231" dependencies = [ "swc_atoms", "swc_common", @@ -4853,9 +4854,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2020" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc6d451268aa73f105b2f663d20e7876ea4949c796bc25d62d58f598a776ea6" +checksum = "ed343932876fad34b1d4a13e30c55b94531e89916f45e7c04203bc49a29565b9" dependencies = [ "serde", "swc_atoms", @@ -4871,9 +4872,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2021" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c14bde6cfd6612cab24560f1db1aa26b0e09325d85a0c9cac3c84c196ea80397" +checksum = "0b6b28a2c109466eaa809d9b9a5b81dcbb4e269ba293a9c5c34aabc67b6427bc" dependencies = [ "swc_atoms", "swc_common", @@ -4887,9 +4888,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2022" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6454665fdfd1f74f1de8fd58dd2a4736903987b7ef840e1ad6f5e695555920c" +checksum = "ab3a644e271ea2a9df88e3e456c5c204c4916ef5136b7d946f9cd25607f47ec6" dependencies = [ "swc_atoms", "swc_common", @@ -4906,9 +4907,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es3" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5092a2e55629997e8dd5191d1183b33b64707576fe719c17302fbd5cd2f8ac7a" +checksum = "e55ffadc12067b21524bf7b5d6938021ee918f65f18937ed27245c23544bc910" dependencies = [ "swc_common", "swc_ecma_ast", @@ -4921,9 +4922,9 @@ dependencies = [ [[package]] name = "swc_ecma_ext_transforms" -version = "0.119.0" +version = "0.120.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45036094d488b0f01706b9a385116326dd7912d8001e9451c506be171154a680" +checksum = "ad03ee53c734eb74757d03c07ec71b1a982261830c9253ef3e2e4a089f9af25d" dependencies = [ "phf 0.11.2", "swc_atoms", @@ -4935,9 +4936,9 @@ dependencies = [ [[package]] name = "swc_ecma_lints" -version = "0.98.2" +version = "0.99.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e008805fad22a9ca42a24395e9e46bacbc4b464048dba259fa5cf69e95cadd2" +checksum = "20c11bcc9e3dc49929500c07c8b0c84a88064847d31e9ee16204b257e6bd315c" dependencies = [ "auto_impl", "dashmap 5.5.3", @@ -4955,9 +4956,9 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.48.1" +version = "0.49.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a201c65ccbaa0c80fbcfd5c90dcc0bfc7ae62ac596f2233651ac715caf5d2c12" +checksum = "55fa3d55045b97894bfb04d38aff6d6302ac8a6a38e3bb3dfb0d20475c4974a9" dependencies = [ "anyhow", "dashmap 5.5.3", @@ -4977,9 +4978,9 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.200.3" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d42f3f6f5e975f472e422195b5f20c6968ee23f195358737e180324d7eb0bb46" +checksum = "5d75a42254926bad8b7fa9390767a18ac608d99cfd5a3be675e4739c2cf7db1b" dependencies = [ "arrayvec", "indexmap 2.2.6", @@ -5013,9 +5014,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.148.1" +version = "0.149.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8204235f635274dba4adc30c47ac896fd126ddfc53b27210676722423cbb2e7" +checksum = "7c7a81df222f44212c72fec4879c0d182c6eac66fb0e180afd05e8be6d920663" dependencies = [ "either", "new_debug_unreachable", @@ -5035,9 +5036,9 @@ dependencies = [ [[package]] name = "swc_ecma_preset_env" -version = "0.213.2" +version = "0.214.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae5f069e49b3ed41fa8136913497fa05357c24be2a29d205094d716d2d541a0a" +checksum = "e85162c77f8c80b55e5aed3a5e5477b74a53ce9cca05dec6e3dabec1de0f49af" dependencies = [ "anyhow", "dashmap 5.5.3", @@ -5060,9 +5061,9 @@ dependencies = [ [[package]] name = "swc_ecma_quote_macros" -version = "0.59.2" +version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a702f9dc87391fecedd3fe7f942b74122adb456d10658efdefcf251ec34fcc6" +checksum = "9781802c95d3bb1b248ae2641fab85012782bb5236e32600e6e4a00adf90a2dc" dependencies = [ "anyhow", "proc-macro2", @@ -5077,9 +5078,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.235.0" +version = "0.236.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae99435503b117b96ffe1030976270c6ec6bdb6f5c62fcb2ce63674b48b1465" +checksum = "d289a83ab829d076d6c2bf2cc0beea7fbf0480ac47a415401f683181a65f4856" dependencies = [ "swc_atoms", "swc_common", @@ -5097,9 +5098,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.143.3" +version = "0.144.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df81c1cbb920d9c47abe6fb105363b0f78df2c8f6b0910c4fdd2ad7cbdfb23d" +checksum = "7c0a71579d030e12fd3cfbfc8712c4ce21afc526f2a759903c77d8df61950f5e" dependencies = [ "better_scoped_tls", "bitflags 2.5.0", @@ -5121,9 +5122,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_classes" -version = "0.132.1" +version = "0.133.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53291bcdfca4bd4c2546c3170d7f0ea1d4f22f6fce2a531265ead010a9a2ebdf" +checksum = "0f37ec04525798a09ce02e52dc15433acee2d86664da0b8ede55bb5cefd95384" dependencies = [ "swc_atoms", "swc_common", @@ -5135,9 +5136,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "0.169.2" +version = "0.170.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f689e03f059ebbff4455331d7e419933574fe409977f8c1d0005c480a89949e" +checksum = "4bb500b65423646da940e289ad37e7c88332d7194248c33fc63a9e768e104fe5" dependencies = [ "arrayvec", "indexmap 2.2.6", @@ -5183,9 +5184,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "0.186.3" +version = "0.187.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d55d9d19cb00dfb661d571fd5d8b18e75c6b3bb080968449e71f785ecced00" +checksum = "cc022be297cdc70d5e71720587c7e810401a958577d77830f3108411e73c466d" dependencies = [ "Inflector", "anyhow", @@ -5210,9 +5211,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.204.2" +version = "0.205.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7f9a903d6774d3f9005775badc25817296791ffed560f1b7e38aab62ca37ff" +checksum = "17446e46b75654901d962251ec4d0063423ee81759a325ed82fcf073308d97ca" dependencies = [ "dashmap 5.5.3", "indexmap 2.2.6", @@ -5235,9 +5236,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_proposal" -version = "0.177.1" +version = "0.178.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d84d062b05ae89982a76ff47881a5e15bbd02e9b3c68dc14a3f5eacf48abca" +checksum = "f9c7ddb3aae86f19eb9e41b0c62509d8e400c1dc79c0889df98f6df1ab893f3f" dependencies = [ "either", "rustc-hash 1.1.0", @@ -5255,9 +5256,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_react" -version = "0.189.2" +version = "0.190.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d411add563dd86d50b3db6e74e38def06587fa2fd370b430f71226688bfa6ded" +checksum = "c3e54a8c87d90812bf69b0f07931bb629111a3f24efe83b9190c3a40a5ebc25e" dependencies = [ "base64 0.21.7", "dashmap 5.5.3", @@ -5280,9 +5281,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_typescript" -version = "0.194.2" +version = "0.195.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1405b179495c3d9530f84778f8c27706c9a2bd7ec820cdd16264d275a2cac0c" +checksum = "f814b32ec83fde097df19e7346c429825390d156d0015f321f1f6434b6a06c0c" dependencies = [ "ryu-js", "serde", @@ -5297,9 +5298,9 @@ dependencies = [ [[package]] name = "swc_ecma_usage_analyzer" -version = "0.29.3" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f583b8db3cb9848537bd6f91c75398407e64332aee982337fe62ea4dec7e7b" +checksum = "bbb53b6fec4526660cc460f581b049a7f4bfb26b4b5d70aa0930c70abecf2f46" dependencies = [ "indexmap 2.2.6", "rustc-hash 1.1.0", @@ -5314,9 +5315,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.133.4" +version = "0.134.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6148af60d25da893aef037621e4869e9b580eb280e12f5a8d4f87fa5e4cd5da" +checksum = "cde8f1ef3f7bd53340c7bd679f1ec563a45225ac8fb63f22d6de1ff4b345475d" dependencies = [ "indexmap 2.2.6", "num_cpus", @@ -5334,9 +5335,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.103.3" +version = "0.104.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed8026e4d9abcb75d511bf7623d49e8e135f02f4f9a6bb7c115df8239cfe3d4f" +checksum = "c71f5f97db49b96208805104b381c5e117f55fad5f3d178e626c92934a4d0e36" dependencies = [ "new_debug_unreachable", "num-bigint", @@ -5360,9 +5361,9 @@ dependencies = [ [[package]] name = "swc_error_reporters" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02c81943772dc4fb0a6228360552d353fedc1a368ee6d80a5172ecb376b1796" +checksum = "0d049e9256abf29d9fc66d3db3ea44b6815a64ad565ce31e117a74ee96478bb3" dependencies = [ "anyhow", "miette 7.2.0", @@ -5373,9 +5374,9 @@ dependencies = [ [[package]] name = "swc_fast_graph" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f854cf8efc290aa927d31dab98b42011ff2341fecb2b27fdc817ef7b30ef3b" +checksum = "357e2c97bb51431d65080f25b436bc4e2fc1a7f64a643bc21a8353e478dc799f" dependencies = [ "indexmap 2.2.6", "petgraph", @@ -5385,9 +5386,9 @@ dependencies = [ [[package]] name = "swc_html" -version = "0.145.0" +version = "0.146.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4b21c5a91022f2435ef6fb8f4630f25af97526e362300d030f3617427a5542" +checksum = "6d32f3d3a03a287d7038f055200ba417d0476914e4df5d5330c46a29ee718acd" dependencies = [ "swc_html_ast", "swc_html_codegen", @@ -5397,9 +5398,9 @@ dependencies = [ [[package]] name = "swc_html_ast" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7377e0299974ea07e304d2174ec8064dfe73f85ca8245c0413fb6e36550611" +checksum = "9c425a3a19e94bd40f94da719691e19be6187a65e1fe6b294fd4d065e841c8e9" dependencies = [ "is-macro", "string_enum", @@ -5409,9 +5410,9 @@ dependencies = [ [[package]] name = "swc_html_codegen" -version = "0.45.2" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "437552583d590bbea0c3225185d3897e7aeb0c7b67d9c9bcad7393ea030cf0d3" +checksum = "1ade76d2999f98677284d1a961b41cf8f9405cfe492531164ead3d1c6796c768" dependencies = [ "auto_impl", "bitflags 2.5.0", @@ -5435,11 +5436,36 @@ dependencies = [ "syn 2.0.63", ] +[[package]] +name = "swc_html_minifier" +version = "0.143.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ed3ec02741044a5f528c3e390cfd9d46bb0954217ffee0bc5f7ff483bac794c" +dependencies = [ + "once_cell", + "serde", + "serde_json", + "swc_atoms", + "swc_cached", + "swc_common", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_minifier", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_visit", + "swc_html_ast", + "swc_html_codegen", + "swc_html_parser", + "swc_html_utils", + "swc_html_visit", +] + [[package]] name = "swc_html_parser" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dba7493c26d0771bd7b0a773cf904ca8bc28a42c67fc4ac88c1c49a07b645a7" +checksum = "d34cff1743fcfe3f83df6c4f65fa769f991d18372b38b578dc1192560f4b2037" dependencies = [ "swc_atoms", "swc_common", @@ -5449,9 +5475,9 @@ dependencies = [ [[package]] name = "swc_html_utils" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e267d500fdd5a6858dde432d641ff7b43ffdb7b426bd573dfd0e56679faa2b7d" +checksum = "5153f5769f3425ecb6ec5f9d26166b5a9e837732450e07db8c4fd9a2c809456f" dependencies = [ "once_cell", "serde", @@ -5462,9 +5488,9 @@ dependencies = [ [[package]] name = "swc_html_visit" -version = "0.36.1" +version = "0.37.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7661ad0288c4ae618ebb1d82d1887a5e521fd6c424a959aab264a8db3824649a" +checksum = "698542ee2b4069b2d7fa6f5be7e80d7b85cc39d03e8bd772fd75e6fb4a50aa12" dependencies = [ "serde", "swc_atoms", @@ -5486,9 +5512,9 @@ dependencies = [ [[package]] name = "swc_node_comments" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6321ba0ee01751e16cf37fed1424c631faa3e362f95b2057f80b5c26adc1e4f" +checksum = "d016ab18b432523b2a3c104ce3aaf7d869db46c0a41477dbfb6201ddc86c1eb0" dependencies = [ "dashmap 5.5.3", "swc_atoms", @@ -5508,9 +5534,9 @@ dependencies = [ [[package]] name = "swc_plugin_proxy" -version = "0.46.0" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19712a471479078252c013a33f24a6b9215630a1a75973a0c1532d7235f8abd2" +checksum = "07548e19126fbc58b16237e2c8b0075f037774dfdd691fe4c558ba898cfe784b" dependencies = [ "better_scoped_tls", "rkyv", @@ -5522,9 +5548,9 @@ dependencies = [ [[package]] name = "swc_plugin_runner" -version = "0.111.2" +version = "0.112.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fce660e19f9a9f954542056045c93f46f030393fe1e2eb49c824fa317a49390" +checksum = "b919c741b6fe28f9e23ad080aabafadf564ee1a737a4bce27bbba987da1ef4ce" dependencies = [ "anyhow", "enumset", @@ -5547,9 +5573,9 @@ dependencies = [ [[package]] name = "swc_timer" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cf01b1f8a318614f566145b0016b2a0e84ac66d78c1374cdc3438e06c27740" +checksum = "6b5fb6f8b8b85512aacbb3d7140a828666e0e0b1bcc69bf84000a0cd36306bab" dependencies = [ "tracing", ] @@ -5580,9 +5606,9 @@ dependencies = [ [[package]] name = "swc_typescript" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d9845b6dfbfb23aee9a990644a3c9560ef49243098149b5c8ef7ef4171f316" +checksum = "d5d043347b109a8aebfe01aaeada4af322304ea0f54ae8e5721df9afcb9305ca" dependencies = [ "swc_atoms", "swc_common", diff --git a/Cargo.toml b/Cargo.toml index 0c1b2acb300..b2dbc5640ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,13 +70,13 @@ napi-derive = { version = "2" } # Must be pinned with the same swc versions #rkyv = { version = "=0.7.44" } # synced with swc wasm plugin -swc_config = { version = "=0.1.14" } -swc_core = { version = "0.99.5", default-features = false } -swc_ecma_minifier = { version = "=0.200.3", default-features = false } -swc_error_reporters = { version = "=0.20.0" } -swc_html = { version = "=0.145.0" } -# swc_html_minifier = { version = "=0.142.2" } -swc_node_comments = { version = "=0.23.0" } +swc_config = { version = "=0.1.15" } +swc_core = { version = "=0.100.7", default-features = false } +swc_ecma_minifier = { version = "=0.201.0", default-features = false } +swc_error_reporters = { version = "=0.21.0" } +swc_html = { version = "=0.146.1" } +swc_html_minifier = { version = "=0.143.1", default-features = false } +swc_node_comments = { version = "=0.24.0" } [workspace.metadata.release] diff --git a/crates/rspack_plugin_html/Cargo.toml b/crates/rspack_plugin_html/Cargo.toml index 92dd1accc41..df8347be8f2 100644 --- a/crates/rspack_plugin_html/Cargo.toml +++ b/crates/rspack_plugin_html/Cargo.toml @@ -28,7 +28,7 @@ sha2 = "0.10.8" sugar_path = { workspace = true } swc_core = { workspace = true } swc_html = { workspace = true } -swc_html_minifier = { workspace = true } +swc_html_minifier = { workspace = true, features = ["custom-css-minifier"] } tracing = { workspace = true } urlencoding = { workspace = true } diff --git a/crates/rspack_plugin_html/src/parser.rs b/crates/rspack_plugin_html/src/parser.rs index d130d40b3b2..9be0d0acd65 100644 --- a/crates/rspack_plugin_html/src/parser.rs +++ b/crates/rspack_plugin_html/src/parser.rs @@ -11,9 +11,9 @@ use swc_html::{ }, parser::{error::Error, parse_file_as_document, parser::ParserConfig}, }; +use swc_html_minifier::option::MinifyOptions; +use swc_html_minifier::{minify_document_with_custom_css_minifier, MinifyCss}; -// use swc_html_minifier::minify_document; -// pub use swc_html_minifier::option::MinifyOptions; use crate::config::HtmlRspackPluginOptions; pub struct HtmlCompiler<'a> { @@ -55,7 +55,11 @@ impl<'a> HtmlCompiler<'a> { if minify { // Minify can't leak to user land because it doesn't implement `ToNapiValue` Trait GLOBALS.set(&Default::default(), || { - // minify_document(ast, &MinifyOptions::default()); + minify_document_with_custom_css_minifier( + ast, + &MinifyOptions::<()>::default(), + &NoopCssMinifier, + ); }) } @@ -83,3 +87,18 @@ pub fn html_parse_error_to_traceable_error(error: Error, fm: &SourceFile) -> rsp //Use this `Error` conversion could avoid eagerly clone source file. traceable_error.into() } + +struct NoopCssMinifier; + +impl MinifyCss for NoopCssMinifier { + type Options = (); + + fn minify_css( + &self, + _options: &swc_html_minifier::option::MinifyCssOption, + data: String, + _mode: swc_html_minifier::CssMinificationMode, + ) -> Option { + return Some(data); + } +} diff --git a/crates/rspack_plugin_javascript/src/ast/stringify.rs b/crates/rspack_plugin_javascript/src/ast/stringify.rs index d986c25770b..bba70bc88e4 100644 --- a/crates/rspack_plugin_javascript/src/ast/stringify.rs +++ b/crates/rspack_plugin_javascript/src/ast/stringify.rs @@ -108,7 +108,7 @@ pub fn print( let mut buf = vec![]; source_map - .build_source_map_with_config(&src_map_buf, input_source_map.cloned(), source_map_config) + .build_source_map_with_config(&src_map_buf, input_source_map, source_map_config) .to_writer(&mut buf) .unwrap_or_else(|e| panic!("{}", e.to_string())); // SAFETY: This buffer is already sanitized From 3821d2eb2c5276a39582e7406f0f8280d5bd13fd Mon Sep 17 00:00:00 2001 From: ahabhgk Date: Thu, 15 Aug 2024 18:27:36 +0800 Subject: [PATCH 3/5] fix --- Cargo.lock | 1 + crates/rspack_plugin_html/Cargo.toml | 1 + crates/rspack_plugin_html/src/parser.rs | 2 +- .../configCases/builtins/html-minify/index.js | 2 +- .../plugins/minify-exclude-css/a.css | 3 -- .../plugins/minify-exclude-css/a.js | 1 - .../plugins/minify-exclude-css/b.css | 3 -- .../plugins/minify-exclude-css/b.js | 1 - .../plugins/minify-exclude-css/index.js | 12 ------- .../minify-exclude-css/rspack.config.js | 29 ---------------- .../plugins/minify-exclude-css/test.config.js | 6 ---- .../verify-bundle-css-minify-swc/a.css | 4 --- .../verify-bundle-css-minify-swc/b-dir/b.css | 4 --- .../b-dir/c-dir/c.css | 3 -- .../verify-bundle-css-minify-swc/entry.css | 1 - .../verify-bundle-css-minify-swc/index.js | 33 ------------------- .../rspack.config.js | 23 ------------- .../test.config.js | 8 ----- packages/rspack/etc/api.md | 19 ----------- 19 files changed, 4 insertions(+), 152 deletions(-) delete mode 100644 packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.css delete mode 100644 packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.js delete mode 100644 packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.css delete mode 100644 packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.js delete mode 100644 packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/index.js delete mode 100644 packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/rspack.config.js delete mode 100644 packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/test.config.js delete mode 100644 packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/a.css delete mode 100644 packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/b.css delete mode 100644 packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/c-dir/c.css delete mode 100644 packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/entry.css delete mode 100644 packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/index.js delete mode 100644 packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/rspack.config.js delete mode 100644 packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/test.config.js diff --git a/Cargo.lock b/Cargo.lock index 30e6e8e7ce6..4527bc3a717 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3494,6 +3494,7 @@ dependencies = [ "anyhow", "dojang", "itertools 0.13.0", + "lightningcss", "path-clean 1.0.1", "rayon", "regex", diff --git a/crates/rspack_plugin_html/Cargo.toml b/crates/rspack_plugin_html/Cargo.toml index df8347be8f2..74af5b3cf08 100644 --- a/crates/rspack_plugin_html/Cargo.toml +++ b/crates/rspack_plugin_html/Cargo.toml @@ -13,6 +13,7 @@ testing = ["dep:schemars"] anyhow = { workspace = true } dojang = "0.1.6" itertools = { workspace = true } +lightningcss = { workspace = true } path-clean = { workspace = true } rayon = { workspace = true } regex = { workspace = true } diff --git a/crates/rspack_plugin_html/src/parser.rs b/crates/rspack_plugin_html/src/parser.rs index 9be0d0acd65..f177a401506 100644 --- a/crates/rspack_plugin_html/src/parser.rs +++ b/crates/rspack_plugin_html/src/parser.rs @@ -99,6 +99,6 @@ impl MinifyCss for NoopCssMinifier { data: String, _mode: swc_html_minifier::CssMinificationMode, ) -> Option { - return Some(data); + Some(data) } } diff --git a/packages/rspack-test-tools/tests/configCases/builtins/html-minify/index.js b/packages/rspack-test-tools/tests/configCases/builtins/html-minify/index.js index bed41afed04..c2ef6566577 100644 --- a/packages/rspack-test-tools/tests/configCases/builtins/html-minify/index.js +++ b/packages/rspack-test-tools/tests/configCases/builtins/html-minify/index.js @@ -4,5 +4,5 @@ const path = require("path"); it("html minify", () => { const htmlPath = path.join(__dirname, "./index.html"); const htmlContent = fs.readFileSync(htmlPath, "utf-8"); - expect(htmlContent.includes("\n")).toBe(false); + expect(htmlContent.includes("")).toBe(true); }); diff --git a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.css b/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.css deleted file mode 100644 index e7a19c34ec1..00000000000 --- a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.css +++ /dev/null @@ -1,3 +0,0 @@ -html { - margin: 0; -} diff --git a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.js b/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.js deleted file mode 100644 index 2e77b884a3c..00000000000 --- a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/a.js +++ /dev/null @@ -1 +0,0 @@ -require("./a.css"); diff --git a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.css b/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.css deleted file mode 100644 index e7a19c34ec1..00000000000 --- a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.css +++ /dev/null @@ -1,3 +0,0 @@ -html { - margin: 0; -} diff --git a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.js b/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.js deleted file mode 100644 index 4753b41b1c4..00000000000 --- a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/b.js +++ /dev/null @@ -1 +0,0 @@ -require("./b.css"); diff --git a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/index.js b/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/index.js deleted file mode 100644 index 596aa318cc3..00000000000 --- a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/index.js +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require("fs"); -const path = require("path"); - -it("[minify-exclude-css]: chunk a should be minified", () => { - const content = fs.readFileSync(path.resolve(__dirname, "a.css"), "utf-8"); - expect(content).not.toMatch("\n"); -}); - -it("[minify-exclude-css]: chunk b should not be minified", () => { - const content = fs.readFileSync(path.resolve(__dirname, "b.css"), "utf-8"); - expect(content).toMatch("\n"); -}); diff --git a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/rspack.config.js b/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/rspack.config.js deleted file mode 100644 index 689ba495e58..00000000000 --- a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/rspack.config.js +++ /dev/null @@ -1,29 +0,0 @@ -const rspack = require("@rspack/core"); -/** - * @type {import("@rspack/core").Configuration} - */ -module.exports = { - entry: { - a: "./a.js", - b: "./b.js", - main: "./index.js" - }, - output: { - filename: "[name].js" - }, - module: { - generator: { - "css/auto": { - exportsOnly: false - } - } - }, - optimization: { - minimize: true, - minimizer: [ - new rspack.SwcCssMinimizerRspackPlugin({ - exclude: [/b\.css/] - }) - ] - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/test.config.js b/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/test.config.js deleted file mode 100644 index 77c3ed9923c..00000000000 --- a/packages/rspack-test-tools/tests/configCases/plugins/minify-exclude-css/test.config.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import("../../../..").TConfigCaseConfig} */ -module.exports = { - findBundle: (i, options) => { - return ["main.js"]; - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/a.css b/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/a.css deleted file mode 100644 index add53ee8181..00000000000 --- a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/a.css +++ /dev/null @@ -1,4 +0,0 @@ -@import "./b-dir/b.css"; -a:nth-child(0):after { content: "a0"; } -a:nth-child(1):after { content: "a1"; } -a:nth-child(2):after { content: "a2"; } diff --git a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/b.css b/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/b.css deleted file mode 100644 index f0bc9c858fb..00000000000 --- a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/b.css +++ /dev/null @@ -1,4 +0,0 @@ -@import "./c-dir/c.css"; -b:nth-child(0):after { content: "b0"; } -b:nth-child(1):after { content: "b1"; } -b:nth-child(2):after { content: "b2"; } diff --git a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/c-dir/c.css b/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/c-dir/c.css deleted file mode 100644 index 57e0a3f859f..00000000000 --- a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/b-dir/c-dir/c.css +++ /dev/null @@ -1,3 +0,0 @@ -c:nth-child(0):after { content: "c0"; } -c:nth-child(1):after { content: "c1"; } -c:nth-child(2):after { content: "c2"; } diff --git a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/entry.css b/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/entry.css deleted file mode 100644 index ac366125e7e..00000000000 --- a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/entry.css +++ /dev/null @@ -1 +0,0 @@ -@import "./a.css"; \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/index.js b/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/index.js deleted file mode 100644 index 3326acc1bcc..00000000000 --- a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/index.js +++ /dev/null @@ -1,33 +0,0 @@ -const fs = __non_webpack_require__("fs"); -const path = __non_webpack_require__("path"); -const checkMap = __non_webpack_require__("../../../../../dist/helper/util/checkSourceMap.js").default; - -require("./entry.css"); - -it("verify css bundle source map", async () => { - const source = fs.readFileSync( - path.resolve(__dirname, "bundle0.css.map"), - "utf-8" - ); - const map = JSON.parse(source); - expect(map.sources).toEqual([ - "webpack:///./b-dir/c-dir/c.css", - "webpack:///./b-dir/b.css", - "webpack:///./a.css" - ]); - expect(map.file).toEqual("bundle0.css"); - const out = fs.readFileSync(path.resolve(__dirname, "bundle0.css"), "utf-8"); - expect( - await checkMap(out, source, { - '"a0"': "webpack:///a.css", - '"a1"': "webpack:///a.css", - '"a2"': "webpack:///a.css", - '"b0"': "webpack:///b-dir/b.css", - '"b1"': "webpack:///b-dir/b.css", - '"b2"': "webpack:///b-dir/b.css", - '"c0"': "webpack:///b-dir/c-dir/c.css", - '"c1"': "webpack:///b-dir/c-dir/c.css", - '"c2"': "webpack:///b-dir/c-dir/c.css" - }) - ).toBe(true); -}); diff --git a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/rspack.config.js b/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/rspack.config.js deleted file mode 100644 index dbc3f1e494d..00000000000 --- a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/rspack.config.js +++ /dev/null @@ -1,23 +0,0 @@ -const { rspack } = require("@rspack/core"); - -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - target: 'web', - node: false, - module: { - generator: { - "css/auto": { - exportsOnly: false - }, - }, - }, - devtool: "source-map", - optimization: { - minimize: true, - minimizer: [ - new rspack.SwcCssMinimizerRspackPlugin() - ] - }, - externals: ["source-map"], - externalsType: "commonjs" -}; diff --git a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/test.config.js b/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/test.config.js deleted file mode 100644 index 2ad4326c626..00000000000 --- a/packages/rspack-test-tools/tests/configCases/source-map/verify-bundle-css-minify-swc/test.config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - findBundle() { - return [ - 'bundle0.css', - 'bundle0.js', - ] - } -} diff --git a/packages/rspack/etc/api.md b/packages/rspack/etc/api.md index 6464b7e4b13..103f028d08a 100644 --- a/packages/rspack/etc/api.md +++ b/packages/rspack/etc/api.md @@ -9752,7 +9752,6 @@ declare namespace rspackExports { CssExtractRspackPluginOptions, HtmlRspackPlugin, SwcJsMinimizerRspackPlugin, - SwcCssMinimizerRspackPlugin, LightningCssMinimizerRspackPlugin, CopyRspackPlugin, SourceMapDevToolPlugin, @@ -14868,24 +14867,6 @@ export type StrictModuleExceptionHandling = z.infer Date: Thu, 15 Aug 2024 18:34:17 +0800 Subject: [PATCH 4/5] fix --- Cargo.lock | 1 - crates/rspack_plugin_html/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4527bc3a717..30e6e8e7ce6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3494,7 +3494,6 @@ dependencies = [ "anyhow", "dojang", "itertools 0.13.0", - "lightningcss", "path-clean 1.0.1", "rayon", "regex", diff --git a/crates/rspack_plugin_html/Cargo.toml b/crates/rspack_plugin_html/Cargo.toml index 74af5b3cf08..df8347be8f2 100644 --- a/crates/rspack_plugin_html/Cargo.toml +++ b/crates/rspack_plugin_html/Cargo.toml @@ -13,7 +13,6 @@ testing = ["dep:schemars"] anyhow = { workspace = true } dojang = "0.1.6" itertools = { workspace = true } -lightningcss = { workspace = true } path-clean = { workspace = true } rayon = { workspace = true } regex = { workspace = true } From 2e30acad3dd69e427999e4ba25e9066b5840dac0 Mon Sep 17 00:00:00 2001 From: ahabhgk Date: Thu, 15 Aug 2024 18:37:15 +0800 Subject: [PATCH 5/5] doc --- .../rspack.config.js | 2 +- packages/rspack/src/config/defaults.ts | 2 +- website/components/i18n/en.json | 2 +- website/components/i18n/zh.json | 2 +- .../swc-css-minimizer-rspack-plugin.mdx | 31 ------------------- website/docs/zh/config/optimization.mdx | 2 +- .../swc-css-minimizer-rspack-plugin.mdx | 16 ---------- website/project-words.txt | 2 -- 8 files changed, 5 insertions(+), 54 deletions(-) delete mode 100644 website/docs/en/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx delete mode 100644 website/docs/zh/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx diff --git a/packages/rspack-test-tools/tests/configCases/optimization/minimizer-swc-extract-comments/rspack.config.js b/packages/rspack-test-tools/tests/configCases/optimization/minimizer-swc-extract-comments/rspack.config.js index 1d915a37b2f..2792ac72327 100644 --- a/packages/rspack-test-tools/tests/configCases/optimization/minimizer-swc-extract-comments/rspack.config.js +++ b/packages/rspack-test-tools/tests/configCases/optimization/minimizer-swc-extract-comments/rspack.config.js @@ -1,4 +1,4 @@ -const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } = require("@rspack/core") +const { SwcJsMinimizerRspackPlugin } = require("@rspack/core") /** * @type {import("@rspack/core").Configuration} diff --git a/packages/rspack/src/config/defaults.ts b/packages/rspack/src/config/defaults.ts index f87163ee8a0..229b377e874 100644 --- a/packages/rspack/src/config/defaults.ts +++ b/packages/rspack/src/config/defaults.ts @@ -941,7 +941,7 @@ const applyOptimizationDefaults = ( D(optimization, "realContentHash", production); D(optimization, "minimize", production); D(optimization, "concatenateModules", production); - // IGNORE(optimization.minimizer): Rspack use `SwcJsMinimizerRspackPlugin` and `SwcCssMinimizerRspackPlugin` by default + // IGNORE(optimization.minimizer): Rspack use `SwcJsMinimizerRspackPlugin` and `LightningCssMinimizerRspackPlugin` by default A(optimization, "minimizer", () => [ new SwcJsMinimizerRspackPlugin(), new LightningCssMinimizerRspackPlugin() diff --git a/website/components/i18n/en.json b/website/components/i18n/en.json index db79df0d644..c75c6b5a5d6 100644 --- a/website/components/i18n/en.json +++ b/website/components/i18n/en.json @@ -9,7 +9,7 @@ "copy-plugin-desc": "Use [CopyRspackPlugin](/plugins/rspack/copy-rspack-plugin) instead", "mini-css-extract-plugin-desc": "Use [CssExtractRspackPlugin](/plugins/rspack/css-extract-rspack-plugin) instead", "terser-webpack-plugin-desc": "Rspack provides [SwcJsMinimizerRspackPlugin](/plugins/rspack/swc-js-minimizer-rspack-plugin) to deliver better performance", - "css-minimizer-webpack-plugin-desc": "Rspack provides [LightningCssMinimizerRspackPlugin](/plugins/rspack/lightning-css-minimizer-rspack-plugin) and [SwcCssMinimizerRspackPlugin](/plugins/rspack/swc-css-minimizer-rspack-plugin) to deliver better performance", + "css-minimizer-webpack-plugin-desc": "Rspack provides [LightningCssMinimizerRspackPlugin](/plugins/rspack/lightning-css-minimizer-rspack-plugin) to deliver better performance", "tsconfig-paths-webpack-plugin-desc": "Use [resolve.tsConfig](/config/resolve#resolvetsconfig) instead", "image-minimizer-webpack-plugin-desc": "Only supports using [loader](https://www.npmjs.com/package/image-minimizer-webpack-plugin#standalone-loader) standalone", "case-sensitive-paths-webpack-plugin-desc": "`useBeforeEmitHook` option not supported", diff --git a/website/components/i18n/zh.json b/website/components/i18n/zh.json index 6ecb037ed02..3f5aa6a4440 100644 --- a/website/components/i18n/zh.json +++ b/website/components/i18n/zh.json @@ -9,7 +9,7 @@ "copy-plugin-desc": "使用 [CopyRspackPlugin](/plugins/rspack/copy-rspack-plugin) 替代", "mini-css-extract-plugin-desc": "使用 [CssExtractRspackPlugin](/plugins/rspack/css-extract-rspack-plugin) 替代", "terser-webpack-plugin-desc": "Rspack 提供 [SwcJsMinimizerRspackPlugin](/plugins/rspack/swc-js-minimizer-rspack-plugin) 以带来更好的性能", - "css-minimizer-webpack-plugin-desc": "Rspack 提供 [LightningCssMinimizerRspackPlugin](/plugins/rspack/lightning-css-minimizer-rspack-plugin) 和 [SwcCssMinimizerRspackPlugin](/plugins/rspack/swc-css-minimizer-rspack-plugin) 以带来更好的性能", + "css-minimizer-webpack-plugin-desc": "Rspack 提供 [LightningCssMinimizerRspackPlugin](/plugins/rspack/lightning-css-minimizer-rspack-plugin) 以带来更好的性能", "tsconfig-paths-webpack-plugin-desc": "使用 [resolve.tsConfig](/config/resolve#resolvetsconfig) 替代", "case-sensitive-paths-webpack-plugin-desc": "不支持 `useBeforeEmitHook` 选项", "moment-locales-webpack-plugin-desc": "在 v0.7.0 已实现对该插件的支持,请升级 Rspack 版本来使用", diff --git a/website/docs/en/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx b/website/docs/en/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx deleted file mode 100644 index 1975c3a01b7..00000000000 --- a/website/docs/en/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx +++ /dev/null @@ -1,31 +0,0 @@ -import { ApiMeta } from '@components/ApiMeta.tsx'; - -# SwcCssMinimizerRspackPlugin - - - -This plugin can be used to compress CSS assets. See [optimization.minimizer](/config/optimization#optimizationminimizer). - -```js -module.exports = { - // ... - optimization: { - minimizer: [new rspack.SwcCssMinimizerRspackPlugin(options)], - }, -}; -``` - -- options - - - **Type:** - - ```ts - type SwcCssMinimizerRspackPluginOptions = { - test?: MinifyConditions; - exclude?: MinifyConditions; - include?: MinifyConditions; - }; - - type MinifyCondition = string | RegExp; - type MinifyConditions = MinifyCondition | MinifyCondition[]; - ``` diff --git a/website/docs/zh/config/optimization.mdx b/website/docs/zh/config/optimization.mdx index e542b563907..16530268003 100644 --- a/website/docs/zh/config/optimization.mdx +++ b/website/docs/zh/config/optimization.mdx @@ -93,7 +93,7 @@ module.exports = { }, }, }), - new rspack.SwcCssMinimizerRspackPlugin({ + new rspack.LightningCssMinimizerRspackPlugin({ minimizerOptions: { errorRecovery: false, }, diff --git a/website/docs/zh/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx b/website/docs/zh/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx deleted file mode 100644 index 96bc296c8eb..00000000000 --- a/website/docs/zh/plugins/rspack/swc-css-minimizer-rspack-plugin.mdx +++ /dev/null @@ -1,16 +0,0 @@ -import { ApiMeta } from '@components/ApiMeta.tsx'; - -# SwcCssMinimizerRspackPlugin - - - -此插件可以用来压缩 CSS 产物。参见 [optimization.minimizer](/config/optimization#optimizationminimizer)。 - -```js -module.exports = { - // ... - optimization: { - minimizer: [new rspack.SwcCssMinimizerRspackPlugin()], - }, -}; -``` diff --git a/website/project-words.txt b/website/project-words.txt index 41926896b0d..dc15c87f52c 100644 --- a/website/project-words.txt +++ b/website/project-words.txt @@ -146,8 +146,6 @@ statoscope struct suxin2017 svgr -swccssminimizerplugin -swccssminimizerrspackplugin swcjsminimizerplugin swcjsminimizerrspackplugin swcpack