-
-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
2,295 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
crates/rspack_binding_options/src/options/raw_builtins/raw_css_extract.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::collections::HashMap; | ||
|
||
use napi_derive::napi; | ||
use rspack_plugin_extract_css::plugin::{CssExtractOptions, InsertType}; | ||
|
||
#[napi(object)] | ||
pub struct RawCssExtractPluginOption { | ||
pub filename: String, | ||
pub chunk_filename: String, | ||
pub ignore_order: bool, | ||
pub insert: Option<String>, | ||
pub attributes: HashMap<String, String>, | ||
pub link_type: Option<String>, | ||
pub runtime: bool, | ||
} | ||
|
||
impl From<RawCssExtractPluginOption> for CssExtractOptions { | ||
fn from(value: RawCssExtractPluginOption) -> Self { | ||
Self { | ||
filename: value.filename, | ||
chunk_filename: value.chunk_filename, | ||
ignore_order: value.ignore_order, | ||
insert: value | ||
.insert | ||
.map(|insert| { | ||
if insert.starts_with("function") || insert.starts_with("(") { | ||
InsertType::Fn(insert) | ||
} else { | ||
InsertType::Selector(insert) | ||
} | ||
}) | ||
.unwrap_or(InsertType::Default), | ||
attributes: value.attributes.into_iter().collect(), | ||
link_type: value.link_type, | ||
runtime: value.runtime, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[package] | ||
edition = "2021" | ||
license = "MIT" | ||
name = "rspack_plugin_extract_css" | ||
repository = "https://github.com/web-infra-dev/rspack" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
async-trait = { workspace = true } | ||
bitflags = { workspace = true } | ||
heck = "0.4.1" | ||
indexmap = { workspace = true } | ||
once_cell = { workspace = true } | ||
rayon = { workspace = true } | ||
regex = { workspace = true } | ||
rkyv = { workspace = true, features = ["indexmap", "validation"] } | ||
rspack_core = { path = "../rspack_core" } | ||
rspack_error = { path = "../rspack_error" } | ||
rspack_hash = { path = "../rspack_hash" } | ||
rspack_identifier = { path = "../rspack_identifier" } | ||
rspack_plugin_runtime = { path = "../rspack_plugin_runtime" } | ||
rustc-hash = { workspace = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_json = { workspace = true } | ||
sugar_path = { workspace = true } | ||
swc_core = { workspace = true, features = [ | ||
"css_ast", | ||
"css_codegen", | ||
"css_parser", | ||
"css_utils", | ||
"css_visit", | ||
"css_visit_path", | ||
"css_compat", | ||
"css_modules", | ||
"css_prefixer", | ||
"css_minifier", | ||
] } | ||
tokio = { workspace = true } | ||
tracing = { workspace = true } | ||
urlencoding = "2.1.2" | ||
ustr = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use rspack_core::{ | ||
AsContextDependency, AsDependencyTemplate, ConnectionState, Dependency, DependencyCategory, | ||
DependencyId, ModuleDependency, ModuleGraph, ModuleIdentifier, | ||
}; | ||
use rustc_hash::FxHashSet; | ||
|
||
use crate::css_module::DEPENDENCY_TYPE; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct CssDependency { | ||
pub id: DependencyId, | ||
pub identifier: String, | ||
pub content: String, | ||
pub context: String, | ||
pub media: String, | ||
pub supports: String, | ||
pub source_map: String, | ||
} | ||
|
||
impl CssDependency { | ||
pub(crate) fn new( | ||
identifier: String, | ||
content: String, | ||
context: String, | ||
media: String, | ||
supports: String, | ||
source_map: String, | ||
) -> Self { | ||
Self { | ||
id: DependencyId::new(), | ||
identifier, | ||
content, | ||
context, | ||
media, | ||
supports, | ||
source_map, | ||
} | ||
} | ||
} | ||
|
||
impl AsDependencyTemplate for CssDependency {} | ||
impl AsContextDependency for CssDependency {} | ||
|
||
impl Dependency for CssDependency { | ||
fn dependency_debug_name(&self) -> &'static str { | ||
"mini-extract-css-dependency" | ||
} | ||
|
||
fn id(&self) -> &DependencyId { | ||
&self.id | ||
} | ||
|
||
fn dependency_type(&self) -> &rspack_core::DependencyType { | ||
&DEPENDENCY_TYPE | ||
} | ||
|
||
fn category(&self) -> &DependencyCategory { | ||
&DependencyCategory::Unknown | ||
} | ||
|
||
fn get_module_evaluation_side_effects_state( | ||
&self, | ||
_module_graph: &ModuleGraph, | ||
_module_chain: &mut FxHashSet<ModuleIdentifier>, | ||
) -> ConnectionState { | ||
ConnectionState::TransitiveOnly | ||
} | ||
} | ||
|
||
impl ModuleDependency for CssDependency { | ||
fn request(&self) -> &str { | ||
&self.identifier | ||
} | ||
} |
Oops, something went wrong.